steveohara / j2mod

Enhanced Modbus library implemented in the Java programming language
Apache License 2.0
265 stars 111 forks source link

Multiple reads of the same function code #70

Closed orensharon closed 6 years ago

orensharon commented 6 years ago

The registers on my device as following:

I can't read it in 1 read request because the protocol limit is 125 registers per request. When I'm trying to read like this:

registers = master.readMultipleRegisters(1, 0, 18);
registers = master.readMultipleRegisters(1,100, 1);

Something is not correct, I got delays between the reads.

steveohara commented 6 years ago

There isn't anything wrong with what you're doing except the obvious issue that you have specified a register count of zero in the second example.

What type of transaction are you using? (serial, TCP, RTU over TCP)

When you say "there are delays between read" I don't understand what you mean. Are you saying that each subsequent request after the first is delayed before sending?

If you are using a serial transaction, are you setting a transaction delay with setTransDelayMS

orensharon commented 6 years ago

Sorry, I fixed the issue to the correct length: registers = master.readMultipleRegisters(1,100, 1);

I'm using Serial RTU. setTransDelayMS seems to be a good start. How do I set it? Can i configure it out side from the library? Here is monitor output i use to see the problem: image

Thanks!

orensharon commented 6 years ago

Update: I changed (hard coded) TransDelayMS and now it working good!