Esempio n. 1
0
      private static void ReceiveProcess(BusContext busContext)
      {
         for (;busContext.receiveThreadExecute; )
         {
            bool moreMsgs;
            TCLightMsg msg;
            TCLightTimestamp timeStamp;

            busContext.receiveEvent.WaitOne();

            do
            {
               CANResult receiveResult = CANResult.ERR_OK;
               receiveResult = PCANLight.ReadEx(busContext.activeHardware, out msg, out timeStamp);
               moreMsgs = !Convert.ToBoolean(receiveResult & CANResult.ERR_QRCVEMPTY);

               if ((CANResult.ERR_OK == receiveResult) && (null != busContext.receiverHandler))
               {
                  CanFrame frame = new CanFrame((int)msg.ID, msg.Data, (int)msg.Len);
                  busContext.receiverHandler(frame);
               }
            }
            while (false != moreMsgs);
         }
      }
Esempio n. 2
0
 private void BusReceiveHandler(CanFrame frame)
 {
    lock (this)
    {
       this.busReceiveQueue.Enqueue(frame);
    }
 }