Open KLelong opened 2 months ago
0x,1x,3x,4x are just memory type identifiers notation and those identifiers do not correspond to Modbus function numbers:
%M
or %Q
(e.g. 000001
coil in modern notation can be accessed like %M0
or %Q0
), can have Read/Write access, corresponding access functions are READ_COILS
(which number is 1) and WRITE_MULTIPLE_COILS
(15, 0x0F);100001
boolean in modern notation can be accessed like %I0
), has ReadOnly access, corresponding access function is READ_DISCRETE_INPUTS
(2);300001
word in modern notation can be accessed like %IW0
), has ReadOnly access, corresponding access function is READ_INPUT_REGISTERS
(4 (!), yes, it doesn't match with memory type id);%MW
(e.g. 400001
word in modern notation can be accessed like %MW0
), , can have Read/Write access, corresponding access functions are READ_HOLDING_REGISTERS
(3 (!), yes, it doesn't match with memory type id again) and WRITE_MULTIPLE_REGISTERS
(16, 0x10);This is an old notation used since the 1980s by Modicon (now Schneider Electric) in PLC software (e.g. Modsoft and Concept). And the elements use an address number (starts with 1, e.g. 400001
, 400000 is incorrect) instead of an offset (starts with 0). But the offset (not the number) of the discrete/register is used to transfer data.
Hi, I'm running my first tests after compiling the project myself. I had unexpected results : I wanted to read holding registers, but I didn't receive the values I setup in the server. On the server-app in the device window, tab 3x, I setup the value I wanted and in the same tab of the client-app I did the counterpart. Running this, I got the expected results. So far so good. But then running my application I did not get those results. After a lot of sniffing with wireshark, I found the server-app and the client-app have the numbering of the functions wrong. I didn't pay attention to the logview but when I finally did I saw the same thing. Setting/getting things in the 3x fields resulted in function code '4' in stead of '3'. The reverse is similar : 4x gives code '3' in stead of code '4'. See the enclosed image.
I hope I made myself clear. Is this a bug ? Or something from my own compilation-process ?
B.T.W. I compiled this on Kubuntu 22.04LTS.
Now I know this I can work around it, but it's annoying.
I'm also not sure about the numbering of the registers. I have to have an offset of 1 to the address of the registers, but that could be the way of modbus.