I’m configuring the Modbus TCP agent in OpenRemote, but I can’t find an attribute for specifying the register address (Holding Register, Coil, etc.). Is there a way to define this in the configuration?
Also, what’s the best way to test if the agent is correctly reading/writing values?
Any help would be greatly appreciated. Thanks in advance!
I am assuming that you have checked out and are testing my Modbus agent branch.
The individual read/write settings can be configured using the agent link. You can press on “add parameter” in the agent link configuration item, and there, there will be 4 more configuration parameters in the agent link that you can specify. On one of those, you will be able to set the type of register you are reading from.
I would like to let you know that, as with any OpenRemote branch, the changes on it are not currently set in stone, and can change. This means that there is a possibility the structure of the agent, agent link, protocol, etc. could change, leading to issues with the connection, etc. If you would like to avoid that, then I suggest you wait for the PR to be merged.
I am new here and try to find out more about the exciting openremote project. One importante use case I see in our company is integrating devices with modbus TCP interface. So I tryed out your Modbus TCP Agent and had trouble defining the ModbusDataType. In your source code I found this parameter, but not in the manager UI - what could be the reason for that?
The documentation for the Modbus agent is currently ongoing, but I believe I can help:
The ModbusDataType is the enum used in the agent link for the Read Value Type and Write Value Type parameters.
Basically, those two agent link parameters, are used for parsing the resulting data from/to the Modbus server. They come from PLC4X’s documentation, and the value selected is then put in the query string sent to the Modbus server. PLC4X takes it from there and appropriately parses the response from the server (vice versa for sending the value to the Modbus server).
So if I select UINT in the Read Value Type, PLC4X will parse the response to UINT from the Modbus server before handing it back to OpenRemote.
Here’s the PLC4X documentation for the Modbus data types:
A modbus tester shows the server is communicating with the chosen parameters. If I use the same parameters in OpenRemote it won’t work.
As you can see in the image no valid data is returned. Is there probably an issue with the address? The server (PV-inverter from SMA) uses the shorter format (3XXXX)? Does the agent pass the given “Read Adress” directly to the server, or does it expect the longer version? I don’t now. Probably you have an idea…
Looking at your screenshot, I can tell that the address you should use there is probably 776, assuming that you’re not trying to read input register 30776, but rather trying to read input register 776. Our implementation simply uses the offset of the register, not the complete address (so not register 40002 meaning that we’re reading holding register 2).
Our implementation simply uses the read memory area configuration input from the agent link to do this transformation (i.e. start reading from the submitted memory area); so if you want to read register 776 from the input register memory area, you can just use INPUT as read memory area and 776 for read address.
Using your input from your screenshot, the request sent to the server would be formatted something like: input-register:30775:DINT, meaning that it’s going to go to the input registers, and request address 30775.
I believe you’re looking for something like input-register:776:DINT (make sure to check if you actually want DINT, meaning double integer).
EDIT: you may need to also try out address 775, in case it’s referring to an offset and not an address.
unfortunately it is not working yet, even considering your remarks. And yes it is double integer I need. That is also the reason why it needs to read two registers in one request (775 AND 776). But I guess this is automatically done by the code if I choose the Read Value Type = DINT, right? Then the request to the server should be according PLC4X documentation like {memory-Area}{start-address}:{data-type}[{array-size}] → input-register:30775:DINT[2].
Is there any way to print the polling request sent to the server, e.g. in some logfile?