Commit ef3e8740fc5303205cca8a445f5936ac19ab7589
1 parent
2e9da98c
Fix swapped test in compute_header_length (1d4241dff)
Showing
1 changed file
with
3 additions
and
5 deletions
src/modbus.c
| @@ -500,22 +500,20 @@ static uint8_t compute_header_length(int function, msg_type_t msg_type) | @@ -500,22 +500,20 @@ static uint8_t compute_header_length(int function, msg_type_t msg_type) | ||
| 500 | { | 500 | { |
| 501 | int length; | 501 | int length; |
| 502 | 502 | ||
| 503 | - if (msg_type == MSG_INDICATION) { | 503 | + if (msg_type == MSG_CONFIRMATION) { |
| 504 | if (function == FC_REPORT_SLAVE_ID) { | 504 | if (function == FC_REPORT_SLAVE_ID) { |
| 505 | - length = 0; | 505 | + length = 1; |
| 506 | } else { | 506 | } else { |
| 507 | /* Should never happen, the other header lengths are precomputed */ | 507 | /* Should never happen, the other header lengths are precomputed */ |
| 508 | abort(); | 508 | abort(); |
| 509 | } | 509 | } |
| 510 | - } else /* MSG_CONFIRMATION */ { | 510 | + } else /* MSG_INDICATION */ { |
| 511 | if (function <= FC_WRITE_SINGLE_COIL || | 511 | if (function <= FC_WRITE_SINGLE_COIL || |
| 512 | function == FC_WRITE_SINGLE_REGISTER) { | 512 | function == FC_WRITE_SINGLE_REGISTER) { |
| 513 | length = 4; | 513 | length = 4; |
| 514 | } else if (function == FC_WRITE_MULTIPLE_COILS || | 514 | } else if (function == FC_WRITE_MULTIPLE_COILS || |
| 515 | function == FC_WRITE_MULTIPLE_REGISTERS) { | 515 | function == FC_WRITE_MULTIPLE_REGISTERS) { |
| 516 | length = 5; | 516 | length = 5; |
| 517 | - } else if (function == FC_REPORT_SLAVE_ID) { | ||
| 518 | - length = 1; | ||
| 519 | } else if (function == FC_READ_AND_WRITE_REGISTERS) { | 517 | } else if (function == FC_READ_AND_WRITE_REGISTERS) { |
| 520 | length = 9; | 518 | length = 9; |
| 521 | } else { | 519 | } else { |