Commit 243ac512061da955dab8410b7b8bbb6f8215f5b7
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 | 239 | case FC_READ_EXCEPTION_STATUS: |
| 240 | 240 | length = 3; |
| 241 | 241 | break; |
| 242 | + case FC_REPORT_SLAVE_ID: | |
| 243 | + return MSG_LENGTH_UNDEFINED; | |
| 242 | 244 | default: |
| 243 | 245 | length = 5; |
| 244 | 246 | } |
| ... | ... | @@ -456,6 +458,8 @@ static uint8_t compute_query_length_header(int function) |
| 456 | 458 | function == FC_PRESET_MULTIPLE_REGISTERS) |
| 457 | 459 | /* Multiple write */ |
| 458 | 460 | length = 5; |
| 461 | + else if (function == FC_REPORT_SLAVE_ID) | |
| 462 | + length = 1; | |
| 459 | 463 | else |
| 460 | 464 | length = 0; |
| 461 | 465 | |
| ... | ... | @@ -471,6 +475,8 @@ static int compute_query_length_data(modbus_param_t *mb_param, uint8_t *msg) |
| 471 | 475 | if (function == FC_FORCE_MULTIPLE_COILS || |
| 472 | 476 | function == FC_PRESET_MULTIPLE_REGISTERS) |
| 473 | 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 | 480 | else |
| 475 | 481 | length = 0; |
| 476 | 482 | ... | ... |