• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Parity类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Parity的典型用法代码示例。如果您正苦于以下问题:C# Parity类的具体用法?C# Parity怎么用?C# Parity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Parity类属于命名空间,在下文中一共展示了Parity类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ParityDecode

        static public ushort ParityDecode(Parity aParity)
        {
            ushort zReturn;            

            switch (aParity)
            {
                case Parity.Even:
                    zReturn = 1;
                    break;
                case Parity.Mark:
                    zReturn = 2;
                    break;
                case Parity.None:
                    zReturn = 4;
                    break;
                case Parity.Odd:
                    zReturn = 0;
                    break;
                case Parity.Space:
                    zReturn = 3;
                    break;
                default:
                    throw new ArgumentOutOfRangeException();                    
            }

            return zReturn;
        }
开发者ID:MegaYanuardi,项目名称:GSMLibrary.Net,代码行数:27,代码来源:CharacterFramingCommand.cs


示例2: SerialTerminal

 public SerialTerminal(string portName, int baudRate, Parity parity, int dataBits, StopBits stopBits)
     : base(portName, baudRate, parity, dataBits, stopBits)
 {
     Open();
     Handshake = Handshake.XOnXOff;
     OperatingMode = IBM3151.OperatingModes.Echo;
 }
开发者ID:32bitkid,项目名称:FalloutTerminal,代码行数:7,代码来源:SerialTerminal.cs


示例3: SetComboBoxes

        public void SetComboBoxes(String comPortName, int baudRate, Parity parity, int dataBits, StopBits stopBits)
        {
            try
               {
                    cmbComPortName.Text = GetValidPortName(cmbComPortName.Text);
               }
               catch (Exception ex)
               {
                    MessageBox.Show(ex.ToString());
                    cmbComPortName.Text = "NONE";
               }

               cmbBaudRate.Text = baudRate.ToString();
               cmbParity.SelectedIndex = GetIndexOfValue(cmbParity.Items, parity.ToString());
               cmbDataBits.SelectedIndex = GetIndexOfValue(cmbDataBits.Items, dataBits.ToString());
               switch (stopBits)
               {
                    case StopBits.One:
                         cmbStopBits.SelectedIndex = GetIndexOfValue(cmbStopBits.Items, "1");
                         break;
                    case StopBits.OnePointFive:
                         cmbStopBits.SelectedIndex = GetIndexOfValue(cmbStopBits.Items, "1.5");
                         break;
                    case StopBits.Two:
                         cmbStopBits.SelectedIndex = GetIndexOfValue(cmbStopBits.Items, "2");
                         break;
                    case StopBits.None:
                         cmbStopBits.SelectedIndex = GetIndexOfValue(cmbStopBits.Items, "1");
                         break;
                    default:
                         cmbStopBits.SelectedIndex = GetIndexOfValue(cmbStopBits.Items, "1");
                         break;
               }
        }
开发者ID:mrpenguin7,项目名称:MessageProfilingActivityCommunicator,代码行数:34,代码来源:ComPortConfigForm.cs


示例4: Open

            /// <summary>
            /// Opens the serial port using the specified baud rate, parity bit, data bits, and stop bit.
            /// </summary>
            /// <param name="baudRate">The baud rate.</param>
            /// <param name="parity">One of the Parity values.</param>
            /// <param name="dataBits">The data bits value.</param>
            /// <param name="stopBits">One of the StopBits values.</param>
            public Windows.Foundation.IAsyncAction Open(
                uint baudRate,
                Parity parity,
                int dataBits,
                StopBits stopBits
            )
            {
                return Task.Run(async () =>
                {
                    this.baudRate  = baudRate;
                    this.parity    = parity;
                    this.dataBits  = dataBits;
                    this.stopBits  = stopBits;

                    if (this.cdcControl == null)
                    {
                        return;
                    }

                    // Do SetLineCoding
                    var len = await SetLineCoding(this.cdcControl.InterfaceNumber, this.baudRate, (byte)this.stopBits, (byte)this.parity, (byte)this.dataBits);
                    if (len != Constants.ExpectedResultSetLineCoding)
                    {
                        throw new System.NotSupportedException("SetLineCoding request is not supported.");
                    }

                    // Do SetControlLineState
                    len = await SetControlLineState(this.cdcControl.InterfaceNumber);
                    
                    return;

                }).AsAsyncAction();
            }
开发者ID:oldnewthing,项目名称:old-Windows8-samples,代码行数:40,代码来源:SerialPort.cs


示例5: Open

        public bool Open(string portName, int baudRate, int databits, Parity parity, StopBits stopBits)
        {
            //Ensure port isn't already opened:
            if (!sp.IsOpen)
            {
                //Assign desired settings to the serial port:
                sp.PortName = portName;
                sp.BaudRate = baudRate;
                sp.DataBits = databits;
                sp.Parity = parity;
                sp.StopBits = stopBits;
                //These timeouts are default and cannot be editted through the class at this point:
                sp.ReadTimeout = 2000;
                sp.WriteTimeout = 2000;
                try
                {
                    sp.Open();
                }
                catch (Exception err)
                {

                    return false;
                }

                return true;
            }
            else
            {

                return false;
            }
        }
开发者ID:goodwin3000,项目名称:ModBus_TCP_RTU_Proxy,代码行数:32,代码来源:MbDevice.cs


示例6: SerialConfig

 public SerialConfig(string cfg)
 {
     var parts = cfg.Split(new Char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
     this.initialConfig = cfg;
     int index = 0;
     if (!parts[index].StartsWith("COM"))
     {
         this.DeviceName = parts[index];
         index++;
     }
     this.PortName = parts[index]; index++;
     this.AutoConnect = Boolean.Parse(parts[index]); index++;
     this.Speed = UInt32.Parse(parts[index]); index++;
     this.DataBits = Byte.Parse(parts[index]); index++;
     this.Parity = (Parity)Byte.Parse(parts[index]); index++;
     this.StopBits = (StopBits)Byte.Parse(parts[index]); index++;
     //this.PacketType = (PacketType)Byte.Parse(parts[index]); index++;
     this.RxPacketType = (PacketType)Byte.Parse(parts[index]); index++;
     this.TxPacketType = (PacketType)Byte.Parse(parts[index]); index++;
     this.PacketType = this.RxPacketType;
     if (parts.Length > index)
     {
         this.ReceiverCRC = Byte.Parse(parts[index]); index++;
         this.TransmitterCRC = Byte.Parse(parts[index]); index++;
     }
     if (parts.Length > index)
     {
         this.DefaultDeviceAddr = Byte.Parse(parts[index]); index++;
     }
 }
开发者ID:WebManufacture,项目名称:Legacy.NET,代码行数:30,代码来源:SerialConfig.cs


示例7: SerialPortSetting

 /// <summary>
 /// 
 /// </summary>
 /// <param name="bardRate"></param>
 /// <param name="parity"></param>
 /// <param name="dataBits"></param>
 /// <param name="stopBits"></param>
 public SerialPortSetting(int baudRate, Parity parity, int dataBits, StopBits stopBits)
 {
     this.BaudRate = baudRate;
         this.Parity = parity;
         this.DataBits = dataBits;
         this.StopBits = stopBits;
 }
开发者ID:hkiaipc,项目名称:c2,代码行数:14,代码来源:SerialPortSetting.cs


示例8: RTU_Client

        public RTU_Client(string PortName, int BaudRate = 9600, Parity Parity = Parity.None, int DataBits = 8, StopBits StopBits = StopBits.One, int Timeout = 2500)
        {
            try
            {
                Port = new SerialPort(PortName, BaudRate, Parity, DataBits, StopBits);
            }
            catch (IOException ex)
            {
                throw new RTU_Exception("Ошибка настроек коммуникационного порта. " + ex.Message, ex);
            }
            ByteTimeout = 20;
            MaxCount = 5;
            this.Timeout = Timeout;

            this.Buffer = new List<byte>(256);


            ReqSendEvent += delegate { };
            ByteRecievedEvent += delegate { };

            try
            {
                Port.Open();
            }
            catch (Exception ex)
            {
                throw new RTU_Exception("Ошибка открытия коммуникационного порта. " + ex.Message, ex);
            }

        }
开发者ID:mrLunatic,项目名称:NET_Modbus,代码行数:30,代码来源:RTU+Client.cs


示例9: setportvalues

 public void setportvalues(UInt32 BaudRate, int DataBits, StopBits StopBits, Parity Parity)
 {
     vBaudRate = BaudRate;
     vDataBits = DataBits;
     vStopBits = StopBits;
     vParity = Parity;
 }
开发者ID:anbarrasu,项目名称:RdrClient,代码行数:7,代码来源:serialPortM.cs


示例10: initialize

 public static void initialize(string COM_port_Name, int baudRate, Parity parity, int dataBits, StopBits stopBits)
 {
     try
     {
         if (COM_port != null)
         {
             if (COM_port.IsOpen)
             {
                 COM_port.Close();
             }
         }
         COM_port = new SerialPort(COM_port_Name, baudRate, parity, dataBits, stopBits);
         COM_port.DataReceived += new SerialDataReceivedEventHandler(DataReceived);
         if (!COM_port.IsOpen)
         {
             COM_port.Open();
         }
         initialized = 1;
         Receiver.Interval = 10;
         Receiver.Elapsed += new System.Timers.ElapsedEventHandler(Receiver_time_out);
         Receiver.AutoReset = false;
         Synchro.Interval = 50;
         Synchro.Elapsed += new System.Timers.ElapsedEventHandler(Synchro_time_out);
         Synchro.AutoReset = false;
     }
     catch (Exception exception)
     {
         Error_messager.Invoke("Ошибка инициализации!\r\nRadist: \r\n" + exception.Message);
         initialized = 2;
     }
 }
开发者ID:dkflsrj,项目名称:processor-test,代码行数:31,代码来源:Radist.cs


示例11: RCRadio

 public RCRadio(string id, string port = "COM1", int baudRate = 115200, Parity parity = Parity.None, int dataBits = 8, StopBits stopBits = StopBits.One)
 {
     Port = new SerialPort(port, baudRate, parity, dataBits, stopBits);
     AutoPing = true;
     PingPeriod = 3000;
     DataQueue = new StringFifoQueue();
 }
开发者ID:ianlee74,项目名称:NETMFx,代码行数:7,代码来源:RCRadio.cs


示例12: PortManager

        public PortManager(String portName, int baudRate, Parity parity, int dataBits, StopBits stopBits, Form1 form )
        {
            if (this.port == null)
            {
                this.portName = portName;
                this.baudRate = baudRate;
                this.parity = parity;
                this.dataBits = dataBits;
                this.stopBits = stopBits;

                this.port = new SerialPort(portName, baudRate, parity, dataBits, stopBits);
                this.port.DtrEnable = true;
                this.port.RtsEnable = true;
                this.port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);

                Form = form;
            }
            else
            {
                this.port.BaudRate = baudRate;
                this.port.Parity = parity;
                this.port.DataBits = dataBits;
                this.port.StopBits = stopBits;
            }
        }
开发者ID:LucasPadovan,项目名称:altoscan,代码行数:25,代码来源:PortManager.cs


示例13: Start

 public static EM406aGPS Start(string portName, int baudRate = 4800, Parity parity = Parity.None, int dataBits = 8, StopBits stopBits = StopBits.One)
 {
     EM406aGPS gps = new EM406aGPS(portName, baudRate, parity, dataBits, stopBits);
     gps._thread = new Thread(gps.Run);
     gps._thread.Start();
     return gps;
 }
开发者ID:adamgilmore,项目名称:Bewarro,代码行数:7,代码来源:EM406aGPS.cs


示例14: PortInitInfo

 public PortInitInfo(int mBaudRate,Parity mParity, int mDataBits, StopBits mStopBits)
 {
     this._BaudRate    = mBaudRate;
     this._Parity      = mParity;
     this._DataBits    = mDataBits;
     this._StopBits    = mStopBits;
 }
开发者ID:wxgb9801,项目名称:Measurer,代码行数:7,代码来源:cProt.cs


示例15: SerialPort

 /// <summary>Initializes a new instance of the <see cref="SerialPort"/> class using the specified port name, baud rate, and parity bit.
 /// </summary>
 /// <param name="portName">The port to use (for example, COM1)</param>
 /// <param name="baudRate">The baud rate</param>
 /// <param name="parity">One of the <see cref="Parity"/> values</param>
 public SerialPort(string portName, int baudRate, Parity parity)
     : this()
 {
     PortName = portName;
     BaudRate = baudRate;
     Parity = parity;
 }
开发者ID:hanseartic,项目名称:interopcom,代码行数:12,代码来源:SerialPort.cs


示例16: BalanceReader

        /*
         *         public string ComPort = String.Empty;
        public int BaudRate = 110;
        public StopBits StopBits = StopBits.None;
        public int DataBits = 7;
        public Parity Parity = Parity.None;
         * */
        public BalanceReader(string comPort = "COM1", int baudRate = 9600, StopBits stopBits = StopBits.One,
            int dataBits = 7, Parity parity = Parity.Even, string sicsCommand = "SI", bool rts = false)
        {
            _sicsCommand = sicsCommand;

            if (comPort == String.Empty) comPort = "COM1";
            _port = new SerialPort
            {
                PortName = comPort,
                BaudRate = baudRate,
                StopBits = stopBits,
                DataBits = 7,
                Parity = Parity.Even,
                RtsEnable = rts
            };

            // from Page 39 of NewClassic Balances METTLER TOLEDO manual for MS-S / MS-L Models
            //_port.Handshake = Handshake.XOnXOff;

            if (_port.IsOpen == false)
            {
                try
                {
                    _port.Open();
                }
                catch (Exception)
                {
                    // port will not be open, therefore will become null
                }
            }

            _port.DataReceived += _port_DataReceived;
        }
开发者ID:ajarrott,项目名称:NewBalance,代码行数:40,代码来源:BalanceReader.cs


示例17: SetOptions

 public void SetOptions(int baudrate, Parity parity, int databits, StopBits stopbits)
 {
     this.baudrate = baudrate;
     this.parity = parity;
     this.databits = databits;
     this.stopbits = stopbits;
 }
开发者ID:koson,项目名称:jawsper-projects,代码行数:7,代码来源:SerialPortBridge.cs


示例18: SerialClass

 /// <summary>
 /// 构造函数,可以自定义串口的初始化参数
 /// </summary>
 /// <param name="comPortName">需要操作的COM口名称</param>
 /// <param name="baudRate">COM的速度</param>
 /// <param name="parity">奇偶校验位</param>
 /// <param name="dataBits">数据长度</param>
 /// <param name="stopBits">停止位</param>
 public SerialClass(string comPortName, int baudRate, Parity parity, int dataBits, StopBits stopBits)
 {
     _serialPort = new SerialPort(comPortName, baudRate, parity, dataBits, stopBits);
     _serialPort.RtsEnable = true;  //自动请求
     _serialPort.ReadTimeout = 3000;//超时
     setSerialPort();
 }
开发者ID:yaopengchao,项目名称:tcz,代码行数:15,代码来源:CSerialClass.cs


示例19: ComPort

        public ComPort(byte number, int baudrate, byte data_bits, byte parity, byte stop_bits, ushort write_timeout, ushort read_timeout, byte attemts)
        {
            m_name = "COM" + Convert.ToString(number);
            m_baudrate = baudrate;
            m_data_bits = data_bits;
            m_parity = (Parity)parity;
            m_stop_bits = (StopBits)stop_bits;
            m_write_timeout = write_timeout;
            m_read_timeout = read_timeout;
            m_attemts = attemts;

            try
            {
                m_Port = new SerialPort(m_name, m_baudrate, m_parity, m_data_bits, m_stop_bits);

                /*ELF: для работы с elf108*/
                m_Port.DtrEnable = true;
                m_Port.RtsEnable = true;
            }
            catch (Exception ex)
            {
                #if (DEBUG)
                    WriteToLog("Create " + m_name + ": " + ex.Message);
                #endif
            }
        }
开发者ID:Prizmer,项目名称:ps,代码行数:26,代码来源:Ports.cs


示例20: Start

        public void Start(string portName, int baudRate, Parity parity, int dataBits, StopBits stopBits)
        {
            if (!GetAvailablePorts().Contains(portName))
            {
                throw new Exception(string.Format("Unknown serial port: {0}", portName));
            }

            // Start the timer to empty the receive buffer (in case data smaller than MAX_RECEIVE_BUFFER is received)
            _bufferTimer = new Timer();
            _bufferTimer.Interval = BUFFER_TIMER_INTERVAL;
            _bufferTimer.Elapsed += _bufferTimer_Elapsed;
            _bufferTimer.Start();

            // Instantiate new serial port communication
            _serialPort = new SerialPort(portName, baudRate, parity, dataBits, stopBits);

            // Open serial port communication
            _serialPort.Open();

            // Check that it is actually open
            if (!_serialPort.IsOpen)
            {
                throw new Exception(string.Format("Could not open serial port: {0}", portName));
            }

            _serialPort.ReadTimeout = 100; // Milliseconds

            _readThread = new System.Threading.Thread(ReadThread);
            _readThreadRunning = true;
            _readThread.Start();
        }
开发者ID:whitestone-no,项目名称:open-serial-port-monitor,代码行数:31,代码来源:SerialReader.cs



注:本文中的Parity类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Parse类代码示例发布时间:2022-05-24
下一篇:
C# ParenthesizedExpression类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap