Read Serial RS232 as Master and Serve RS485 as Slave RUT956

I have a RUT956 reading RS232 over a serial connection and posting it via MQTT to our cloud server. I would like to also make the register data from the RS232 available to be polled/served to an external RS485 Master.

I found some directional guidance in the forum but feel I am missing a critical piece. Any guidance is much appreciated as I hope to avoid custom registers or scripts.

Hello,

Each serial interface can only be enabled in one service. Thus, it is not possible to have multiple services configured for the same RS232 or RS485 interface. Since RS232 is already in use, it cannot be used in other services. There’s not much that can be done without additional workarounds/scripts. The only suggestion that comes to mind is to enable custom Modbus registers on RUT956 and write to them (for example, via MQTT). Then, poll those registers via RS485.

Kind Regards,

I am attempting your suggestion of a custom script. First I tried with python since I am more familiar with it, but the RUT956 does not have space for the library to install.

Trying to use the ubus commands and some pieces I found in the forums I came up with the following script. It does not seem to have all the correct utilities available. Any guidance on the correct syntax and tools?

Trying to get the script to read rs232 and write the register values to custom registers in the tcp slave so that I can poll it using a second master via 485.

#!/bin/sh

Configure serial port

stty -F /dev/rs232 9600 cs8 -cstopb -parenb -echo

Function to read RS232 registers and write to Modbus registers

read_and_write_registers() {
# Read RS232 registers
reg1=$(dd if=/dev/rs232 bs=1 count=1 2>/dev/null | hexdump -e ‘1/1 “%02X”’)
reg4=$(dd if=/dev/rs232 bs=1 count=4 2>/dev/null | hexdump -e ‘4/1 “%02X”’)
reg6=$(dd if=/dev/rs232 bs=1 count=6 2>/dev/null | hexdump -e ‘6/1 “%02X”’)
reg8=$(dd if=/dev/rs232 bs=1 count=8 2>/dev/null | hexdump -e ‘8/1 “%02X”’)

# Write to Modbus registers using ubus
ubus call modbus write '{"address": 1025, "value": "'$reg1'"}'
ubus call modbus write '{"address": 1026, "value": "'$reg4'"}'
ubus call modbus write '{"address": 1027, "value": "'$reg6'"}'
ubus call modbus write '{"address": 1028, "value": "'$reg8'"}'

}

Main loop

while true; do
read_and_write_registers
sleep 60 # Delay for 60 second
done

Hello,

You can use USB flash drive for memory expansion on RUT956. This would allow you to install the necessary packages, such as Python3.

Since other services on RUT are already using the RS232 serial port, I cannot guarantee that your solution will work properly. However, you can try.

For Modbus, you will want to use ubus commands mentioned here.
I would also suggest taking a look at other posts on this forum using the search functionality. For instance, the following posts might be helpful:

Kind Regards,

This topic was automatically closed after 15 days. New replies are no longer allowed.