Commit 614ff1dc36b1ad33fd27f0786ff733fcc92abf33
1 parent
8c09fb17
Fix unit test of report slave ID in RTU
Showing
1 changed file
with
4 additions
and
2 deletions
src/modbus.c
| @@ -344,8 +344,10 @@ static int receive_msg(modbus_t *ctx, int msg_length_computed, | @@ -344,8 +344,10 @@ static int receive_msg(modbus_t *ctx, int msg_length_computed, | ||
| 344 | /* It's useless to check the value of | 344 | /* It's useless to check the value of |
| 345 | msg_length_computed in this case (only | 345 | msg_length_computed in this case (only |
| 346 | defined values are used). */ | 346 | defined values are used). */ |
| 347 | - state = DATA; | ||
| 348 | - break; | 347 | + if (length_to_read != 0) { |
| 348 | + state = DATA; | ||
| 349 | + break; | ||
| 350 | + } /* else switch straight to DATA */ | ||
| 349 | case DATA: | 351 | case DATA: |
| 350 | length_to_read = compute_data_length(ctx, msg); | 352 | length_to_read = compute_data_length(ctx, msg); |
| 351 | msg_length_computed += length_to_read; | 353 | msg_length_computed += length_to_read; |