Serial Interface Setup for CMRI Nodes - manu-fwi/openlcb-gateway GitHub Wiki
cmri_net_serial.py
This helper program communicates with your CMRI node(s) via ttyUSB0; it will connect to the main server via port 50001 (or the port you setup for the gateway+1) but you don't have to worry about it. There are two configuration files that you will need to setup.
cmri_net_serial.cfg
Contains a json formatted dict, an example follows:
{
"serial_port":"/dev/ttyUSB0",
"serial_speed":9600,
"openlcb_gateway_ip":"127.0.0.1",
"openlcb_gateway_port":50001,
"nodes_ID_list":[2203631397546]
}
The first 4 entries are self-explanatory, the "nodes_ID_list" lists all nodes (full ID) managed by this client (base 10 representation of OpenLCB 6-byte address. Eg. 2203631397546 = 02:01:12:AA:AA:AA ).
cmri_net_bus_db.cfg
Moreover, you need this file which contains the nodes "DB": it describes all nodes (in JSON format also). It can be empty, any nodes started by cmri_net_serial will just be set up very basically (eg: all events will be 0.0.0.0.0.0.0.0) you need to use CDI config to set things correctly (and this will be automatically saved every 10s).
The file is cmri_net_bus_db.cfg using a JSON format, see below a very minimal example for a SUSIC node type "N" (24 bits) and 2 Inputs cards and one Outputs card:
[{"fullID": 2203631397546,
"cmri_node_add": 1,
"version": 1,
"name": "SUSIC-test-1",
"description": "SUSIC test for olcbgw",
"type": "N",
"cards_sets": ["IO", "I"]}
]
Mandatory fields per entry.
- fullID: OpenLCD ID (matching value in cmri_net_serial.cfg nodes_ID_list
- type: N=24 bit SUSIC/USIC cards, X=32 bit SUSIC cards, C=cpNode
- cards_sets: I=Input and O=Output. Ex. IOII means on Input card, then Output card, then Input and Input again installed in the slots on the node. The example in the JSON above shows a SUSIC/USIC with 24 bit cards giving you 24 Outputs and 48 Inputs. If the type was 'X', then it would be 32 Outputs and 64 Inputs.
Once you have created the files, launch cmri_net_serial.py to interface the CMRI RS485 network with the openlcb_gateway program(which should already be running).
python3 cmri_net_serial.py
When they are connected you can launch JMRI; you should see the nodes using CDI editor inside JMRI.
The CMRI node will be polled every 2 seconds and you should see the corresponding events being generated if an input has changed.
You can also send an event corresponding to an output to make it change accordingly.