[PATCH] Fix failure in random-test-client

31 views
Skip to first unread message

Martin Galvan

unread,
May 4, 2016, 4:55:15 PM5/4/16
to libm...@googlegroups.com
Currently, random-test-client sends messages from ADDRESS_START to ADDRESS_END.
When it reaches ADDRESS_END, the number of bytes to write is zero, which causes the
server to reply with exception messages for some of the requests:

Waiting for a indication...
<03><E1><00><00><00><07><FF><0F><00><63><00><00><00>
Illegal number of values 0 in write_bits (max 1968)
Bytes flushed (0)
...
Waiting for a indication...
<03><E4><00><00><00><07><FF><10><00><63><00><00><00>
Illegal number of values 0 in write_registers (max 123)
Bytes flushed (0)
...
Waiting for a indication...
<03><E5><00><00><00><0B><FF><17><00><63><00><00><00><63><00><00><00>
Illegal nb of values (W0, R0) in write_and_read_registers (max W121, R125)
Bytes flushed (0)

The client in turn shows:

<03><E1><00><00><00><03><FF><8F><03>
ERROR Illegal data value
ERROR modbus_write_bits (-1)
Address = 99, nb = 0
...
<03><E4><00><00><00><03><FF><90><03>
ERROR Illegal data value
ERROR modbus_write_registers (-1)
Address = 99, nb = 0
...
<03><E5><00><00><00><03><FF><97><03>
ERROR Illegal data value
ERROR modbus_read_and_write_registers (-1)
Address = 99, nb = 0

This patch simply makes the client loop stop when it reaches ADDRESS_END - 1.

---
tests/random-test-client.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/random-test-client.c b/tests/random-test-client.c
index 69c9b0a..2ebbded 100644
--- a/tests/random-test-client.c
+++ b/tests/random-test-client.c
@@ -86,7 +86,7 @@ int main(void)

nb_loop = nb_fail = 0;
while (nb_loop++ < LOOP) {
- for (addr = ADDRESS_START; addr <= ADDRESS_END; addr++) {
+ for (addr = ADDRESS_START; addr < ADDRESS_END; addr++) {
int i;

/* Random numbers (short) */
--
2.8.2

Stéphane Raimbault

unread,
May 9, 2016, 3:59:11 AM5/9/16
to libm...@googlegroups.com
Good catch, thank you Martin.

--
2.8.2

--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes libmodbus.
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse libmodbus+...@googlegroups.com.
Pour plus d'options, visitez le site https://groups.google.com/d/optout .

Reply all
Reply to author
Forward
0 new messages