Hi Guys,
I want to write a script that uses a Modbus TCP client to periodically read data from Modbus devices and publish it to an MQTT broker, while also receiving messages from an MQTT topic (to which it is subscribed) and write to Modbus registers based on those messages. But I couldn’t find the packages documentations and alike.
I have read about the UBUS lib, but I could not find a script that uses Modbus TCP to read and write data.
What packages or libraries should I use? Does someone have an example of something similar? How can I find the documentation of the packages installed in the RUTOS?
Thank you,
Miguel Chagas
Thank you for reaching out. Your request is currently under analysis, and we are reviewing the appropriate libraries, available documentation, and practical implementation steps.
Once the review is done, I will follow up here with a concise summary and any available examples.
In the meantime, thank you for your patience and understanding.
Additionally, since you have a related topic already created, feel free to leave a comment or reminder there as well to help consolidate the discussion.
After reviewing relevant information found on the forum and other sources and analyzing it, in summary:
To read data from a Modbus TCP server, you can utilize the ubus call interface available in RutOS. All available ubus parameters and endpoints can be listed using the following command:
ubus -v list
Here is an example ubus call to read holding registers (Function Code 3) from a Modbus TCP server: