Serial Interface Setup for RR Duino Nodes - manu-fwi/openlcb-gateway GitHub Wiki
RR_duino_net_serial.py
3 RRduino nodes (one UNO, one MEGA and one LEONARDO) connected on a RS485 bus (half-duplex at 38400 bauds), the link to the computer is done via another Leonardo setup as a USB to RS485 interface.
The small perf boards are the RS485 half duplex interfaces.
You can see Event monitor of the PanelPro on the upper right: I pushed/released twice the push-button, that generated twice a couple of events from the UNO (ID ....8C.52), these events are both linked to output sensors (one on the MEGA, one on the LEONARDO), setting the corresponding outputs (one HIGH one LOW, so the LEDs are always in different states).
On the left hand side you have the CDI config window, this one corresponds to the LEONARDO (bus address is 3).
This setup also works even without JMRI as the gateway propagates events/messages to all nodes.
You can also watch the small video showing the way the leds are switching ON/OFF depending on the pushbutton state:Video
Config files needed:
RR_duino_net_serial.cfg:
{
"serial_port":"/dev/ttyACM1",
"serial_speed":115200,
"openlcb_gateway_ip":"127.0.0.1",
"openlcb_gateway_port":50001,
"nodes_ID_filename":"RR_duino_nodes_DB.cfg"
}
Basically this one describes the serial port used to connect to the RS485 bus and the ip and port to connect to the gateway; this is used by the helper program that will manage the bus with RR-duino nodes (can be on another computer than the one running the gateway).
RR_duino_nodes_DB.cfg:
{
"2002002":1,
"2002003":2,
"2002004":3
}
This one just describes the nodes on the RS485 bus as pairs: "full ID":bus address. All the nodes config are stored in the nodes EEPROM and fetched via bus commands.
Once you have the configuration files setup, start the RR_duino_net_serial.py program.
python3 RR_duino_net_serial.py