/* * Check to see if a packet has been received. If so, read the packet and print * the packet payload to the serial monitor. */ void receiveCan(CanBus* bus) { // TODO what happens if we process until the queue is empty? if(!QUEUE_EMPTY(CanMessage, &bus->receiveQueue)) { CanMessage message = QUEUE_POP(CanMessage, &bus->receiveQueue); decodeCanMessage(bus, message.id, message.data); bus->lastMessageReceived = systemTimeMs(); } }
void CanMsgParser::processCanMessage(const intercom::DataMessage::CanMsg * can_msg, bool just_check) { /* lookup can_msg in message hash */ messageHashKey_t key = ntohl(can_msg->Id); message_t * dbc_msg = NULL; int i; /* loop over all bus assigments */ for(i = 0; i < busAssignment->n ; i++) { busAssignmentEntry_t * entry = &busAssignment->list[i]; /* check if bus matches */ if((entry->bus == -1) || (entry->bus == can_msg->Bus)) { dbc_msg = (message_t *)hashtable_search(entry->messageHash, &key); if(NULL != dbc_msg) { decodeCanMessage(dbc_msg, can_msg, just_check); break; /* end search if message was found */ } } } }