Example #1
0
        void serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            lock (lockObj)
            {
                if (OnReceiveData != null)
                {
                    int count = serialPort.BytesToRead;

                    serialPort.Read(rxBuffer, 0, count);

                    ReceiveEventArgs eventArgs = new ReceiveEventArgs(rxBuffer, 0, count);
                    eventArgs.PortName = (sender as SerialPort).PortName;

                    OnReceiveData(this, eventArgs);
                }
            }
        }
Example #2
0
 public virtual void OnReceived(object sender, ReceiveEventArgs e)
 {
 }
Example #3
0
 void portReceiver_OnReceiveData(object sender, ReceiveEventArgs e)
 {
     //将收到的串口数据放入队列
     dataQueue.EnqueueReceive(new EventArgsPackage(sender, e));
 }