aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristopher Peplin <chris.peplin@rhubarbtech.com>2014-02-14 22:41:21 -0500
committerChristopher Peplin <chris.peplin@rhubarbtech.com>2014-02-14 22:41:21 -0500
commit14dc82b42c45ac58a1030f6c2c27952bb90c1648 (patch)
treeb77620305cb7e36ab821023a4f32ce34232109a3 /src
parent2a5be4ab15def6c876c7f70d0fa60cf6079166e7 (diff)
Show negative response codes in log output.
Diffstat (limited to 'src')
-rw-r--r--src/uds/uds.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/uds/uds.c b/src/uds/uds.c
index 400eedf0..5a45c0c6 100644
--- a/src/uds/uds.c
+++ b/src/uds/uds.c
@@ -305,13 +305,26 @@ float diagnostic_decode_obd2_pid(const DiagnosticResponse* response,
void diagnostic_response_to_string(const DiagnosticResponse* response,
char* destination, size_t destination_length) {
int bytes_used = snprintf(destination, destination_length,
- "arb_id: 0x%02x, mode: 0x%x, pid: 0x%x, ",
+ "arb_id: 0x%02x, mode: 0x%x, ",
response->arbitration_id,
- response->mode,
- response->pid);
- int remaining_space = destination_length - bytes_used;
+ response->mode);
+
+ if(response->has_pid) {
+ bytes_used += snprintf(destination + bytes_used,
+ destination_length - bytes_used,
+ "pid: 0x%x, ",
+ response->pid);
+ }
+
+ if(!response->success) {
+ bytes_used += snprintf(destination + bytes_used,
+ destination_length - bytes_used,
+ "negative response code: 0x%x, ",
+ response->negative_response_code);
+ }
+
if(response->payload_length > 0) {
- snprintf(destination + bytes_used, remaining_space,
+ snprintf(destination + bytes_used, destination_length - bytes_used,
"payload: 0x%02x%02x%02x%02x%02x%02x%02x",
response->payload[0],
response->payload[1],
@@ -321,7 +334,8 @@ void diagnostic_response_to_string(const DiagnosticResponse* response,
response->payload[5],
response->payload[6]);
} else {
- snprintf(destination + bytes_used, remaining_space, "no payload");
+ snprintf(destination + bytes_used, destination_length - bytes_used,
+ "no payload");
}
}