当前位置: 首页>>代码示例>>C#>>正文


C# StopBits类代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: SerialPortSettings

 /// <summary>
 /// Default constructor of SerialPortSettings.
 /// </summary>
 public SerialPortSettings()
 {
  m_baudRate=9600;
  m_dataBits=8;
  Parity=Parity.None;
  StopBits=StopBits.One;
 }
开发者ID:divadgagnon,项目名称:LAB_Soft,代码行数:10,代码来源:SerialPortSettings.cs

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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