Use new set_bitfield function to handle swapping endianness.
authorChristopher Peplin <chris.peplin@rhubarbtech.com>
Mon, 6 Jan 2014 19:54:15 +0000 (14:54 -0500)
committerChristopher Peplin <chris.peplin@rhubarbtech.com>
Mon, 6 Jan 2014 19:54:15 +0000 (14:54 -0500)
deps/bitfield-c
src/obd2/obd2.c

index 09dc97c..6f24309 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 09dc97c24f9f9a9c2638405167bffe339f666e2a
+Subproject commit 6f243098abadbde2e9b2e5b13a94029960ea2e51
index 402cc2f..fa20f91 100644 (file)
@@ -37,10 +37,8 @@ DiagnosticRequestHandle diagnostic_request(DiagnosticShims* shims,
     uint8_t payload[MAX_DIAGNOSTIC_PAYLOAD_SIZE];
     payload[MODE_BYTE_INDEX] = request->mode;
     if(request->pid_length > 0) {
-        // TODO need a set bit field that's more natural and checks endianness
-        // becauase we DO need to flip it
-        copy_bytes_right_aligned((uint8_t*)&request->pid, sizeof(request->pid),
-                PID_BYTE_INDEX, request->pid_length, payload, sizeof(payload));
+        set_bitfield(request->pid, PID_BYTE_INDEX * CHAR_BIT,
+                request->pid_length * CHAR_BIT, payload, sizeof(payload));
     }
     if(request->payload_length > 0) {
         memcpy(&payload[PID_BYTE_INDEX + request->pid_length],