From 243ac512061da955dab8410b7b8bbb6f8215f5b7 Mon Sep 17 00:00:00 2001 From: Paul Fertser Date: Mon, 7 Sep 2009 13:30:45 +0400 Subject: [PATCH] Implemented FC_REPORT_SLAVE_ID according to specs --- src/modbus.c | 6 ++++++ 1 file changed, 6 insertions(+), 0 deletions(-) diff --git a/src/modbus.c b/src/modbus.c index b4f437f..42a1be7 100644 --- a/src/modbus.c +++ b/src/modbus.c @@ -239,6 +239,8 @@ static unsigned int compute_response_length(modbus_param_t *mb_param, case FC_READ_EXCEPTION_STATUS: length = 3; break; + case FC_REPORT_SLAVE_ID: + return MSG_LENGTH_UNDEFINED; default: length = 5; } @@ -456,6 +458,8 @@ static uint8_t compute_query_length_header(int function) function == FC_PRESET_MULTIPLE_REGISTERS) /* Multiple write */ length = 5; + else if (function == FC_REPORT_SLAVE_ID) + length = 1; else length = 0; @@ -471,6 +475,8 @@ static int compute_query_length_data(modbus_param_t *mb_param, uint8_t *msg) if (function == FC_FORCE_MULTIPLE_COILS || function == FC_PRESET_MULTIPLE_REGISTERS) length = msg[TAB_HEADER_LENGTH[mb_param->type_com] + 5]; + else if (function == FC_REPORT_SLAVE_ID) + length = msg[TAB_HEADER_LENGTH[mb_param->type_com] + 1]; else length = 0; -- libgit2 0.21.4