aboutsummaryrefslogtreecommitdiffstats
path: root/src/uds/uds.c
diff options
context:
space:
mode:
authorZac Nelson <znelson1@ford.com>2016-09-14 09:54:47 -0700
committerGitHub <noreply@github.com>2016-09-14 09:54:47 -0700
commit6e6ffb3c8871f25b6df649dc35008ec075da0b2f (patch)
tree6bd3834772278e919ea4cca2513112c8ea0e3496 /src/uds/uds.c
parentb2033dd734c689701d0e1c8518a04a3304a3c6c3 (diff)
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.
Diffstat (limited to 'src/uds/uds.c')
-rw-r--r--src/uds/uds.c7
1 files changed, 5 insertions, 2 deletions
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) {