compute_response_size() no entry for read_input_status()
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
libmodbus |
Fix Released
|
Medium
|
Stéphane Raimbault |
Bug Description
libmodbus1.2.2 :
When using modbus function 0x02 - Read Discrete Inputs the reply frame is the same length as for command 0x01.
compute_
I added it into modbus.c as per:
< --------------- snip ---------------->
static unsigned int compute_
{
int response_
int offset;
offset = mb_param-
switch (query[offset + 1]) {
case 0x01: /* function 0x01 and 0x02 have same response size. */
case 0x02: {
/* Header + nb values (code from force_multiple_
int coil_count = (query[offset + 4] << 8) | query[offset + 5];
} break;
< --------------- snip --------------->
Thanks for a really well put together library, I had started writing my own after looking at the 'other' libmodbus, then found this.
Got a bit further through my RTU stack coding, and found this also effects function 04, so I've added a similar fix for that, as per:
< --------------- snip --------------->
(coil_ count / 8) + ((coil_count % 8) ? 1 : 0);
} break;
case 0x03: /* function 0x03 and 0x04 have same response size. */
response_ size_computed = 3 +
case 0x04:
/* Header + 2 * nb values */
< --------------- snip --------------->
Cheers, Chris H.