Explorar o código

Fix receiving of incorrect queries in write_single and mask_write_register

Thank you very much James Nutaro.
Stéphane Raimbault %!s(int64=11) %!d(string=hai) anos
pai
achega
2c132b0406
Modificáronse 1 ficheiros con 2 adicións e 2 borrados
  1. 2 2
      src/modbus.c

+ 2 - 2
src/modbus.c

@@ -1223,7 +1223,7 @@ static int write_single(modbus_t *ctx, int function, int addr, int value)
     rc = send_msg(ctx, req, req_length);
     if (rc > 0) {
         /* Used by write_bit and write_register */
-        uint8_t rsp[_MIN_REQ_LENGTH];
+        uint8_t rsp[MAX_MESSAGE_LENGTH];
 
         rc = _modbus_receive_msg(ctx, rsp, MSG_CONFIRMATION);
         if (rc == -1)
@@ -1389,7 +1389,7 @@ int modbus_mask_write_register(modbus_t *ctx, int addr, uint16_t and_mask, uint1
     rc = send_msg(ctx, req, req_length);
     if (rc > 0) {
         /* Used by write_bit and write_register */
-        uint8_t rsp[_MIN_REQ_LENGTH];
+        uint8_t rsp[MAX_MESSAGE_LENGTH];
 
         rc = _modbus_receive_msg(ctx, rsp, MSG_CONFIRMATION);
         if (rc == -1)