Modbus Flex Connector Example

Does anyone have a working example of Modbus Flex Connector with the ability to dynamically connect to both TCP and SERIAL devices (using the most recent version of NR and node-red-contrib-modbus)? I have looked at MODSCAN - and although I have been able to get it working it still requires manually going into the Node-Red GUI and selecting the Link-out for either TCP or Serial connection before they will work, and I have found it's now not working with the latest updates to node-red-contrib-modbus (v5.8). I am looking for something that will allow changing the settings from Dashboard to switch between a WiFi/TCP and Serial RS-485 connection. I am using a Function as follows to input the settings to Modbus Flex Connector;

msg.payload = { 
    'connectorType': 'TCP',
    'tcpHost': '',
    'tcpPort': '10502',
    'unitId': '253'
return msg;


msg.payload = { 
    'serialPort': '/dev/ttyUSB0',
    'serialType': 'RTU',
    'serialBaudrate': '115200',
    'unitId': '254'
return msg;

I currently have it working for the TCP connection, but when I try to switch to Serial it gives me a " Dynamic Reconnect Starts on actual state activated" message and then reconnects to TCP.

  contribModbus:flex:connector dynamicReconnect: {"connectorType":"SERIAL","serialPort":"/dev/ttyUSB0","serialType":"RTU","serialBaudrate":"115200","unitId":"254"} +0ms
  contribModbus:core:client Dynamic Reconnect Parameters {"connectorType":"SERIAL","serialPort":"/dev/ttyUSB0","serialType":"RTU","serialBaudrate":"115200","unitId":"254","emptyQueue":false} +1m
  contribModbus:core:client New Connection Serial Settings /dev/ttyUSB0 115200 RTU +6ms
  contribModbus:core:client Dynamic Reconnect Starts on actual state activated +1ms
2 Apr 22:56:46 - [warn] [modbus-client:ModbusConnect] Client -> init in 2000 ms TCP@ default Unit-Id: 254

Any info on this would be much appreciated.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.