I'm having a weird issue communicating with a serial device using the serial request node from node-red-node-serialport 2.03 palette. I'm running Node Red on my Raspberry Pi 4b.
I have a simple test flow set up as seen below. The inject node injects the string flashLed to msg.payload upon click. This is the command recognized by my serial device and it should blink the onboard LED. The serial request node indicates that it is connected and is configured as seen in the second picture. When I inject the payload, the node just times out.
My frustration is coming from the fact that I can type the string flashLed into minicom configured to the same serial port and everything responds fine. The lights blink and I get back an OK message so I feel like the issue is in my Node-Red setup. I made sure to close minicom after this testing as I know only one device can use a serial port at a time.
I am relatively new to Node Red (used it once for a school project) and have never worked with serial communications so I in over my head and hoping someone can help me. Please feel free to ask questions as I'm certain there are important details that I have neglected to add.
Thanks so much for the quick reply! I removed the serial out from my flow and added < CR > (with no spaces) to the payload (as my device's integration manual indicated) and am still having no luck. The integration manual also states that sending an unknown command should result in a string "u->'unknown command'< CR>< LF>" being returned so I tried to send "test< CR>" and still just got a timeout. Seems to indicate to me that the message isn't making it to the device.
I'll keep trying things and update here if I get it to work. Please feel free to make other suggestions as well. Thanks!
I was just playing around with this and got it to work based on this post. I created a function as seen below and it worked. When I simply put the /r into the inject node, it didn't work but the function node worked like a charm. Hopefully this will be helpful to others in the future.
Yes - you cannot simply add '\r' in the inject node as that will literally add the two characters '\' and 'r'. Other methods you can use are 1) in the serial node you can add \r to every message output or 2) you can use JSON mode ({}) in the inject mode (instead of String) and surround the payload with quotes - eg "...your payload here...\r"