Test rx an empty CAN messages.
[apps/low-level-can-service.git] / src / isotp / isotp.c
index 67c644f..e233d38 100644 (file)
@@ -21,15 +21,16 @@ IsoTpShims isotp_init_shims(LogShim log, SendCanMessageShim send_can_message,
 
 void isotp_message_to_string(const IsoTpMessage* message, char* destination,
         size_t destination_length) {
-    char payload_string[message->size * 2 + 1];
-    memset(payload_string, 0, sizeof(payload_string));
-    for(int i = 0; i < message->size; i++) {
-        // TODO, bah this isn't working because snprintf hits the NULL char that
-        // it wrote the last time and stops cold
-        /* snprintf(&payload_string[i * 2], 2, "%02x", message->payload[i]); */
-    }
-    snprintf(destination, destination_length, "ID: 0x%02x, Payload: 0x%s",
-            message->arbitration_id, payload_string);
+    snprintf(destination, destination_length, "ID: 0x%02x, Payload: 0x%02x%02x%02x%02x%02x%02x%02x%02x",
+            message->arbitration_id,
+            message->payload[0],
+            message->payload[1],
+            message->payload[2],
+            message->payload[3],
+            message->payload[4],
+            message->payload[5],
+            message->payload[6],
+            message->payload[7]);
 }
 
 IsoTpMessage isotp_receive_can_frame(IsoTpShims* shims, IsoTpHandle* handle,
@@ -55,6 +56,9 @@ IsoTpMessage isotp_receive_can_frame(IsoTpShims* shims, IsoTpHandle* handle,
             return message;
         }
     } else if(handle->type == ISOTP_HANDLE_SENDING) {
+        // TODO this will need to be tested when we add multi-frame support,
+        // which is when it'll be necessary to pass in CAN messages to SENDING
+        // handles.
         if(handle->send_handle.receiving_arbitration_id != arbitration_id) {
             if(shims->log != NULL) {
                 shims->log("The arb ID 0x%x doesn't match the expected tx continuation ID 0x%x",