Esempio n. 1
0
int usrAppStartProc(void)
{
    struct CAN_RPACKET rcvePacket;
    while
    {
        CanRcvMsg(0,rcvePacket);
        CanRcvMsg(1,rcvePacket);
        CanRcvMsg(2,rcvePacket);
        CanRcvMsg(3,rcvePacket);
    }
}
hlcanopen::CanMsg Pci7841Card::read()
{
  CAN_PACKET canPacket;
  memset(&canPacket, 0, sizeof(canPacket));


  if (CanRcvMsg(handle, &canPacket) == 0) {
    if(getCanId(canPacket.CAN_ID) == 0) {
    } else {
      LOG(DEBUG) << "receiving data: " <<
        " -- COB-ID:  " << canPacket.CAN_ID <<
        " can-id:  " << getCanId(canPacket.CAN_ID) << " -- data: " <<
        packetDataToStr(canPacket);
    }
  } else {
    LOG(DEBUG) << "no data received ";
    memset(&canPacket, 0, sizeof(canPacket));
  }

   hlcanopen::CanMsg canMsg;
   canMsg.cobId = hlcanopen::COBId(getCanId(canPacket.CAN_ID), getCOBType(canPacket.CAN_ID));
   for(BYTE i =0; i < 8; i++) {
      canMsg[i] = canPacket.data[i];
   }

   return canMsg;
}