MODBUS trough RS232-USB Serial Port

Hello! I am trying to connect to a machine that uses MODBUS, in the attached image I set the protocols based on what I already did using Python, note: the slave ID is 001. I receive no errors when connecting but nothing happens when I try to send signals:

I’d appreciate any guidance or advice :slight_smile:

@camilosr huh, interesting application! My triage process would be as follows:

  1. Confirm the connection happens successfully - open the console (Developer >> Toggle Developer Tools (Content) >> Console) and look for messages with the key generic-serial in them. This will say whether connection is successful or not.

  2. Confirm your code is correct - I assume so, since you’re just taking this from python, but worth noting

  3. Note that anything put in that “Message” field is going to be sent as a string, so any possibilities for escaped characters, etc will be dependent on the receiving device - Tulip is not going to do any parsing or mapping, and just send exactly what you put there

  4. Are you sure that your Modbus device is RS-232? Most of the time, I’ve seen Modbus done over TCP - which, perhaps you can use the Telnet driver in Tulip but I doubt it has the extra functionality Modbus requires

  5. The ‘canon’ way to use Modbus with Tulip is via Node-RED. We have a guide coming out on this soon, but check this out as a good start.

Also note that you need to make Triggers to do something when the device does indeed respond with a value - save the output, or whatever, as applicable.

In Summary: Two main things to check:

  1. Assume the connection is wrong and the code is right: Be sure you see a successful connection message in the Console when running the first Trigger.

  2. Assume the connection is right and the code is wrong: Even if the code is copy-pasted, it’s likely that Modbus does not support serial connection. I recommend using the Modbus nodes in Node-RED.

If you get through these and have questions, I recommend you drop us a line at ! Hope this helps

1 Like

Hello Kyle, thank you so much for your help, here is my progress so far:

    • The Connection is successful. this is the message from the console: console-stream.ts:105 [2024-01-13 16:58:06:0499] INFO: renderer: [DEVICE-MANAGER] [serial] Connection succeeded for R232-USB at COM3. {appVersion: ‘2.5.0’, platform: ‘win32’, hostname: ‘SHARED3350’, serialNumber: ‘00329-00000-00003-AA271’}appVersion: "2.5.0"hostname: "SHARED3350"platform: "win32"serialNumber: “00329-00000-00003-AA271”[[Prototype]]: Object
  1. the code is correct and tested several times :slight_smile:

  2. maybe here is where the issue resides. in the console I’m receiving a error, apparently a missing dependency, here is the error message:

console-stream.ts:105 [2024-01-13 16:15:35:0375] WARN: renderer: [DEVICE-MANAGER] [serial] Error unescaping unicode code point sequence. Ignoring… {appVersion: ‘2.5.0’, platform: ‘win32’, hostname: ‘SHARED3350’, serialNumber: ‘00329-00000-00003-AA271’, err: ReferenceError: unescapeUnicodeCodePointEscapes is not defined
at apply (file:///C:/Users/LineL…, …}appVersion: "2.5.0"err: ReferenceError: unescapeUnicodeCodePointEscapes is not defined
at apply (file:///C:/…/tulip-player-desktop/app-2.5.0/resources/app.asar/renderer/webpack:/src/renderer/devices/device-drivers/generic/serial.js:312:5)
at apply (file:///C:/…/tulip-player-desktop/app-2.5.0/resources/app.asar/renderer/webpack:/src/renderer/devices/device-manager.js:128:41)
at (file:///C:/…/tulip-player-desktop/app-2.5.0/resources/app.asar/renderer/webpack:/src/renderer/clientRPC/clientRPC.ts:82:40)
at new Promise ()
at Object.runRPC (file:///C:/…/tulip-player-desktop/app-2.5.0/resources/app.asar/renderer/webpack:/src/renderer/clientRPC/clientRPC.ts:76:10)
at fn (file:///C:/…/tulip-player-desktop/app-2.5.0/resources/app.asar/renderer/webpack:/src/renderer/views/webview/ipc-handlers.ts:207:22)
at EventEmitter. (file:///C:/…/tulip-player-desktop/app-2.5.0/resources/app.asar/renderer/webpack:/src/renderer/views/webview/webview-ipc.ts:63:7)
at EventEmitter.emit (node:events:517:28)
at WebViewElement. (file:///C:/…/tulip-player-desktop/app-2.5.0/resources/app.asar/renderer/webpack:/src/renderer/views/webview/webview-ipc.ts:49:19)
at WebViewImpl.dispatchEvent (node:electron/js2c/renderer_init:2:26414)hostname: "SHARED3350"identifier: "R232-USB"message: "\x01 \x05 \x00 \x01 \xff \x00 \xdd \xfa"platform: "win32"serialNumber: “00329-00000-00003-AA271”[[Prototype]]: Object

  1. I confirm is Modbus/RTU via RS-232, I cannot run it via TCP.

I’d appreciate any further help.

Hey @camilosr ,

Thanks for the helpful reply! Spoke with some of our engineers, and we were able to identify a bug with how we implemented unescapeUnicodePointEscapes in the Player Serial driver.

In short, the Serial driver will always send messages as ASCII. So, your message would have to use the escape sequence \u{hex_value} to convert the hex values to ASCII. However, this can only be done once this bug is fixed!

The Player team is on it, and it should be fixed pretty soon as this is a small change. Thanks for your help, as this made the triage process speedy - we hope to have this out soon! Stay tuned, and make sure your Player is set to stay on the most up-to-date Production release.

1 Like

Hey! @k.ober Thank you for the quick response! Looking forward to that fixed :slight_smile:

I’ll stay tuned.

@camilosr Thank you for the flag.

We have fixed the unicode escape issue in 2.5.1 version of Tulip Player. It will be released on 17th Feb.

In the mean time, you can download the 2.5.1 version right now by switching to the “Release Candidate” release channel (from the top menu bar → Developer → Change Release channel → Release Candidate) and then checking for updates by File → Check for updates


Hey @hari that was Fast! Thanks a lot.
I tested it and now the Unicode escape issue is not a problem.
I’m trying to use these options as messages in static value TEXT:

  • \u01 \u05 \u00 \u01 \uFF \u00 \uDD \uFA
  • \u01\u05\u00\u01\uFF\u00\uDD\uFA
  • \u{01}\u{05}\u{00}\u{01}\u{FF}\u{00}\u{DD}\u{FA}
  • \u{01} \u{05} \u{00} \u{01} \u{FF} \u{00} \u{DD} \u{FA}

this is the original hex bits string:

  • 01 05 00 01 FF 00 DD FA
    01 - Slave address:
    05 - Function code:
    00 01 - Coil address:
    FF 00 - Write data:
    DD FA - CRC

no success, probably my approach is not the best. any advice?

@camilosr May be try a serial port emulator like com0com as outlined in this stack overflow answer windows - Faking an RS232 Serial Port - Stack Overflow and attach Putty on one end and see the actual data that is being written.

Connect your python script to it as well and look for differences in data written between your script and Tulip Player.

Hello @k.ober. I tried communicating over Modbus RTU via node red with an edge device, I followed the guide, but for some reason, when I arrive at serial port selection step, I can’t select dev/ttyUSB0.

I saw the note saying that there is no support for hot-plugging USB devices in Node-RED so I plugged it before booting for node red. But still nothing, could it be an issue with cable driver ? I also tried the serial port node for another application but the result is still the same can’t select USB0, if I try to write it directly it says error: Port not Open.

Any idea on what I’m doing wrong, or what could be the issue ?

@Nicolas1 Are you trying to connect the RS-232 port to the device or the USB side to the device? The ttyUSB0 would only enumerate when the USB side is plugged in. The RS-232 port is ttyS1.

1 Like

I’m trying to send data from USB port to the slave with a USB to RS-232 cable