I have downloaded version 0.1.1 from November 11, 2001.
My application consists of QNXRTP target, where I am running IBM's J9.
I compiled RandomRegs example with VisualAge Micro Edition ( Ver 1.4)
and run it into the target. I modified the part with with random number generation with
calling of shared library ( JNI ), reading a process values and placing them into the image of
Modbus register bank( number of registers = 4000 ). That works fine. I tested it with third party
software application which run under Windows PC. It connects through my QNXRTP Modbus device
and reads properly the data from the process.
So now the PROBLEM :::
I wrote my Java application ( under Windows) using ModbusTCPMaster class, once with
VisualAge Micro Edition( using IBM's J9) and second with Forte(using Sun java). There are following
problems common for both approaches :
1.1 readInputRegisters() can not read more than 62 registers, although I am supporting 4000
registers into master device.
1.2 Some of the registers (R1 and R6) are with wrong values / what does not occur with the third
party software I mentioned above /. The data from the process are unsigned integers with values
less than 42000.
2.1 readMultipleRegisters() reads the appointed registers, but all of them =0 opposed to
readInputRegisters().
It seems that ModbusTCPMaster class has some bugs or I am not using it properly.
Could you please help me?!?
Best Regards !
Kostadin Vardin
Logged In: NO
Mr Vardin,
I have used the library and had similiar problems. I have not
yet figured out the problem of the 62 registers yet. However,
the problem with the wrong register values seems to be in the
ModbusMaster class. The problem I was having was that the
class was not properly parsing numbers that came out
negative it the ethernet response packet. I fixed it by
changing the line:
results[i] = ((response.buff[3+2*i] << 8) + (response.buff
[4+2*i] << 0)) & 0xFFFF;
into
results[i] = ((response.buff[3+2*i] << 8) + ((response.buff
[4+2*i] << 24)>>>24)) & 0xFFFF;
This seems to fix the problem.