1 #include <isotp/receive.h>
3 void isotp_handle_single_frame(IsoTpHandler* handler, IsoTpMessage* message) {
4 isotp_complete_receive(handler, message);
7 void isotp_complete_receive(IsoTpHandler* handler, IsoTpMessage* message) {
8 handler->message_received_callback(message);
11 void isotp_receive_can_frame(IsoTpHandler* handler,
12 const uint16_t arbitration_id, const uint64_t data,
13 const uint8_t length) {
14 if(arbitration_id != handler->arbitration_id){
18 // TODO use CanMessage struct from canutil library - allocate payload buffer
20 IsoTpProtocolControlInformation pci = (IsoTpProtocolControlInformation)
21 getBitField(data, 0, 4, false);
23 IsoTpProtocolControlInformation pci = (IsoTpProtocolControlInformation)
24 getNibble(0, data, 64, LITTE_ENDIAN);
26 // TODO this is messed up! need a better API for grabbing bytes
27 uint8_t payload_length = getBitField(data, 4, 4, false);
28 uint8_t payload[payload_length];
29 uint64_t flipped_data = __builtin_bswap64(data);
30 if(payload_length > 0) {
31 memcpy(payload, &(((uint8_t*)&flipped_data)[1]), payload_length);
34 IsoTpMessage message = {
35 arbitration_id: arbitration_id,
42 isotp_handle_single_frame(handler, &message);
45 handler->shims->log("Only single frame messages are supported");