Commit 243ac512061da955dab8410b7b8bbb6f8215f5b7

Authored by Paul Fertser
Committed by Stéphane Raimbault
1 parent 22a68981

Implemented FC_REPORT_SLAVE_ID according to specs

Showing 1 changed file with 6 additions and 0 deletions
src/modbus.c
@@ -239,6 +239,8 @@ static unsigned int compute_response_length(modbus_param_t *mb_param, @@ -239,6 +239,8 @@ static unsigned int compute_response_length(modbus_param_t *mb_param,
239 case FC_READ_EXCEPTION_STATUS: 239 case FC_READ_EXCEPTION_STATUS:
240 length = 3; 240 length = 3;
241 break; 241 break;
  242 + case FC_REPORT_SLAVE_ID:
  243 + return MSG_LENGTH_UNDEFINED;
242 default: 244 default:
243 length = 5; 245 length = 5;
244 } 246 }
@@ -456,6 +458,8 @@ static uint8_t compute_query_length_header(int function) @@ -456,6 +458,8 @@ static uint8_t compute_query_length_header(int function)
456 function == FC_PRESET_MULTIPLE_REGISTERS) 458 function == FC_PRESET_MULTIPLE_REGISTERS)
457 /* Multiple write */ 459 /* Multiple write */
458 length = 5; 460 length = 5;
  461 + else if (function == FC_REPORT_SLAVE_ID)
  462 + length = 1;
459 else 463 else
460 length = 0; 464 length = 0;
461 465
@@ -471,6 +475,8 @@ static int compute_query_length_data(modbus_param_t *mb_param, uint8_t *msg) @@ -471,6 +475,8 @@ static int compute_query_length_data(modbus_param_t *mb_param, uint8_t *msg)
471 if (function == FC_FORCE_MULTIPLE_COILS || 475 if (function == FC_FORCE_MULTIPLE_COILS ||
472 function == FC_PRESET_MULTIPLE_REGISTERS) 476 function == FC_PRESET_MULTIPLE_REGISTERS)
473 length = msg[TAB_HEADER_LENGTH[mb_param->type_com] + 5]; 477 length = msg[TAB_HEADER_LENGTH[mb_param->type_com] + 5];
  478 + else if (function == FC_REPORT_SLAVE_ID)
  479 + length = msg[TAB_HEADER_LENGTH[mb_param->type_com] + 1];
474 else 480 else
475 length = 0; 481 length = 0;
476 482