Ejemplo n.º 1
0
        public SP_DataChannel(string mac, string channelType)
            : base(mac, channelType)
        {
            //从配置中获取
            SerialPortConfig config = new SerialPortConfig("COM1", 9600, 8, "EVEN", "1");

            _client = new SerialPortClient(mac, config);
            _client.OnReceiveData += Receive;
            _client.Activate();
        }
Ejemplo n.º 2
0
        public SerialPortClient(string mac, SerialPortConfig config)
        {
            this._mac = mac;

            com          = new SerialPort();
            com.PortName = config.PortName;
            com.BaudRate = config.BaudRate;
            com.DataBits = config.DataBits;
            com.Parity   = config.Parity;
            com.StopBits = config.StopBits;
        }