Commit 2c132b040643e209c1978dfd660702f71aa76fce
1 parent
1a4fb4eb
Fix receiving of incorrect queries in write_single and mask_write_register
Thank you very much James Nutaro.
Showing
1 changed file
with
2 additions
and
2 deletions
src/modbus.c
| ... | ... | @@ -1223,7 +1223,7 @@ static int write_single(modbus_t *ctx, int function, int addr, int value) |
| 1223 | 1223 | rc = send_msg(ctx, req, req_length); |
| 1224 | 1224 | if (rc > 0) { |
| 1225 | 1225 | /* Used by write_bit and write_register */ |
| 1226 | - uint8_t rsp[_MIN_REQ_LENGTH]; | |
| 1226 | + uint8_t rsp[MAX_MESSAGE_LENGTH]; | |
| 1227 | 1227 | |
| 1228 | 1228 | rc = _modbus_receive_msg(ctx, rsp, MSG_CONFIRMATION); |
| 1229 | 1229 | if (rc == -1) |
| ... | ... | @@ -1389,7 +1389,7 @@ int modbus_mask_write_register(modbus_t *ctx, int addr, uint16_t and_mask, uint1 |
| 1389 | 1389 | rc = send_msg(ctx, req, req_length); |
| 1390 | 1390 | if (rc > 0) { |
| 1391 | 1391 | /* Used by write_bit and write_register */ |
| 1392 | - uint8_t rsp[_MIN_REQ_LENGTH]; | |
| 1392 | + uint8_t rsp[MAX_MESSAGE_LENGTH]; | |
| 1393 | 1393 | |
| 1394 | 1394 | rc = _modbus_receive_msg(ctx, rsp, MSG_CONFIRMATION); |
| 1395 | 1395 | if (rc == -1) | ... | ... |