diff options
author | Christopher Peplin <chris.peplin@rhubarbtech.com> | 2014-02-14 19:02:16 -0500 |
---|---|---|
committer | Christopher Peplin <chris.peplin@rhubarbtech.com> | 2014-02-14 19:02:16 -0500 |
commit | 2d59b8750a91bed55c8a7ee8caf6eb28c9091c05 (patch) | |
tree | 5ffdfb2960559b588fa73140ac60ec73d70ad532 /src | |
parent | 2ec5044b09a9c5ff9ffa1531371cc5095e278d3d (diff) |
Clean up log output if a diag request has no payload.
Diffstat (limited to 'src')
-rw-r--r-- | src/uds/uds.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/uds/uds.c b/src/uds/uds.c index 412f077d..18f1147f 100644 --- a/src/uds/uds.c +++ b/src/uds/uds.c @@ -94,18 +94,27 @@ DiagnosticRequestHandle diagnostic_request(DiagnosticShims* shims, 1 + request->payload_length + request->pid_length, NULL); if(shims->log != NULL) { - shims->log("Sending diagnostic request: arb_id: 0x%02x, mode: 0x%x, pid: 0x%x, payload: 0x%02x%02x%02x%02x%02x%02x%02x, size: %d\r\n", + char message[128] = {0}; + int bytes_used = snprintf(message, sizeof(message), + "Sending diagnostic request: arb_id: 0x%02x, mode: 0x%x, pid: 0x%x, ", request->arbitration_id, request->mode, - request->pid, - request->payload[0], - request->payload[1], - request->payload[2], - request->payload[3], - request->payload[4], - request->payload[5], - request->payload[6], - request->payload_length); + request->pid); + int remaining_space = sizeof(message) - bytes_used; + if(request->payload_length > 0) { + snprintf(message + bytes_used, remaining_space, + "payload: 0x%02x%02x%02x%02x%02x%02x%02x", + request->payload[0], + request->payload[1], + request->payload[2], + request->payload[3], + request->payload[4], + request->payload[5], + request->payload[6]); + } else { + snprintf(message + bytes_used, remaining_space, "no payload"); + } + shims->log(message); } setup_receive_handle(&handle); |