From 6e6ffb3c8871f25b6df649dc35008ec075da0b2f Mon Sep 17 00:00:00 2001 From: Zac Nelson Date: Wed, 14 Sep 2016 09:54:47 -0700 Subject: Multi frame (#6) * increase payload size just for diag responses to support multi-frame responses. limited to 255 bytes for now. * not all diag requests with modes greater than 0xa have a 2 byte pid. need to check was pid_length should be based on the size of the pid. * remove line that does nothing. * add multi_frame field to DiagnosticResponse and update based on IsoTpMessage. Need this upstream for timeout calls specific to multi frame. * update isotp-c submodule. * update autoset_pid tests. check that pid_length is dynamically set based on pid value. adjust other tests to use 2-byte pid for enhanced diagnostic mode requests. * add test for multi-frame response. * update changelog. --- src/uds/uds.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/uds/uds.c') diff --git a/src/uds/uds.c b/src/uds/uds.c index 636bbfca..0114384d 100644 --- a/src/uds/uds.c +++ b/src/uds/uds.c @@ -53,7 +53,9 @@ static void setup_receive_handle(DiagnosticRequestHandle* handle) { static uint16_t autoset_pid_length(uint8_t mode, uint16_t pid, uint8_t pid_length) { if(pid_length == 0) { - if(pid > 0xffff || (mode != 0x3e && mode > 0xa)) { + if(mode <= 0xa || mode == 0x3e ) { + pid_length = 1; + } else if(pid > 0xffff || ((pid & 0xFF00) > 0x0)) { pid_length = 2; } else { pid_length = 1; @@ -69,7 +71,6 @@ static void send_diagnostic_request(DiagnosticShims* shims, if(handle->request.has_pid) { handle->request.pid_length = autoset_pid_length(handle->request.mode, handle->request.pid, handle->request.pid_length); - handle->request.pid_length = handle->request.pid_length; set_bitfield(handle->request.pid, PID_BYTE_INDEX * CHAR_BIT, handle->request.pid_length * CHAR_BIT, payload, sizeof(payload)); @@ -233,6 +234,7 @@ DiagnosticResponse diagnostic_receive_can_frame(DiagnosticShims* shims, DiagnosticResponse response = { arbitration_id: arbitration_id, + multi_frame: false, success: false, completed: false }; @@ -246,6 +248,7 @@ DiagnosticResponse diagnostic_receive_can_frame(DiagnosticShims* shims, IsoTpMessage message = isotp_continue_receive(&handle->isotp_shims, &handle->isotp_receive_handles[i], arbitration_id, data, size); + response.multi_frame = message.multi_frame; if(message.completed) { if(message.size > 0) { -- cgit 1.2.3-korg