Пример #1
0
/**
 * If a message is available, read it and forward it to registered observers.
 */
void DeviceGEVCU::process() {
	static CAN_FRAME frame;
	if (bus->rx_avail()) {
		bus->get_rx_buff(frame);
		handleCanFrame(&frame);
	}
}
Пример #2
0
//----------------------------------------------------------------------------//
// onSocketReceive()                                                          //
// receive CAN message                                                        //
//----------------------------------------------------------------------------//
void QCanSocketCpFD::onSocketReceive()
{
   QByteArray        clCanDataT;
   QCanFrame         clCanFrameT;
   QCanFrameApi      clCanApiT;
   QCanFrameError    clCanErrorT;
   QCanData::Type_e  ubFrameTypeT;
   uint32_t          ulFrameCntT;
   uint32_t          ulFrameMaxT;


   ulFrameMaxT = framesAvailable();
   for(ulFrameCntT = 0; ulFrameCntT < ulFrameMaxT; ulFrameCntT++)
   {
      if (this->read(clCanDataT, &ubFrameTypeT) == true)
      {
         switch (ubFrameTypeT)
         {
            case QCanData::eTYPE_API:
               if (clCanApiT.fromByteArray(clCanDataT) == true)
               {
                  handleApiFrame(clCanApiT);
               }
               break;
               
            case QCanData::eTYPE_CAN:
               if (clCanFrameT.fromByteArray(clCanDataT) == true)
               {
                  handleCanFrame(clCanFrameT);
               }
               break;
               
            case QCanData::eTYPE_ERROR:
               if (clCanErrorT.fromByteArray(clCanDataT) == true)
               {
                  handleErrFrame(clCanErrorT);
               }
               break;
            default:

               break;
               
         }
      }
   }
}