summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/uds/uds.c7
-rw-r--r--src/uds/uds.h2
2 files changed, 9 insertions, 0 deletions
diff --git a/src/uds/uds.c b/src/uds/uds.c
index 443b05a0..b3f2cdad 100644
--- a/src/uds/uds.c
+++ b/src/uds/uds.c
@@ -1,5 +1,6 @@
#include <uds/uds.h>
#include <bitfield/bitfield.h>
+#include <canutil/read.h>
#include <string.h>
#include <limits.h>
#include <stddef.h>
@@ -241,3 +242,9 @@ DiagnosticResponse diagnostic_receive_can_frame(DiagnosticShims* shims,
}
return response;
}
+
+float diagnostic_payload_to_float(const DiagnosticResponse* response) {
+ return bitfield_parse_float(response->payload,
+ response->payload_length, 0,
+ response->payload_length * CHAR_BIT, 1.0, 0);
+}
diff --git a/src/uds/uds.h b/src/uds/uds.h
index 091d3c9f..78f70e15 100644
--- a/src/uds/uds.h
+++ b/src/uds/uds.h
@@ -83,6 +83,8 @@ DiagnosticResponse diagnostic_receive_can_frame(DiagnosticShims* shims,
const uint16_t arbitration_id, const uint8_t data[],
const uint8_t size);
+float diagnostic_payload_to_float(const DiagnosticResponse* response);
+
/* Public: Render a DiagnosticResponse as a string into the given buffer.
*
* TODO implement this