示例#1
0
        private void DataReceived(int port)
        {
            Thread.Sleep(10);
            int len = SerialPortDevice.GetIqueue;

            if (len <= 0)
            {
                return;
            }
            byte[] by = SerialPortDevice.Read(len);
            try
            {
                by = m_Validation.Combination(by);
                if (by != null && ReceivedManager.ReceivedFunction != null)
                {
                    ReceivedManager.ReceivedFunction.DataReceived(by);
                }
            }
            catch (Exception ex)
            {
                Log4Helper.ErrorInfo(ex.Message, ex);
            }
            finally
            {
                by = null;
            }
        }
示例#2
0
 private static void SerialPortDataReceived(int port)
 {
     Thread.Sleep(10);
     byte[] by;
     try
     {
         int len = m_SerialPort.GetIqueue;
         if (len <= 0)
         {
             by = m_Validation.Combination(m_Bytes.ToArray());
             if (by != null)
             {
                 m_Over = true;
                 m_Bytes.Clear();
             }
             return;
         }
         by = m_SerialPort.Read(len);
         m_Bytes.AddRange(by);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
     }
 }