I am trying to Solve a problem with the Serial Request Node. I am using a Raspberry PI, with a USB Serial converter to send data to an ICOM radio. I am not sure what other information would be helpful with understanding the setup but am happy to provide.
When using bash command line, I can manually form up packets to send to the radio and see the proper response. Also, when the same USB to serial converter is connected to Windows, I can also manually form the packet in Realterm, and see the response.
However, when I use the Serial Request object in NR on the Pi, the node will always return the sent packet as the output message. To investigate, I removed the Serial Request Node and replaced it with individual Serial In and Serial out nodes.
After doing this, I noticed the Serial In node would always send two messages. The first message would be a duplicate of the data sent via Serial Out , and the second would be the actual data that was sent received from the radio.
At first, I thought it was radio echoing it back also.
I moved the dongle over to Windows and launched a terminal program, Realterm, which allowed me to manually form up the packet and send it. I monitored the radio's reply there was no Echo.
I then thought that it might be something weird with the Raspberry Pi drivers, so I created a binary file with the packet contents and sent it to the port via cat, I monitored the return data also, no echo.
It almost feels like the Dongle may be buffering the packet, and due to the system timing of when the Request node switches from transmit to receive, it is actually ends up reading the packet that is buffered in the dongle and thinking it is the reply.
For the time being, I have implemented a less than desirable hack where I use Serial In and Serial out nodes, and then filter out the echo the transmitted packet, and then operate on the second message received. This keeps things going for now, but I would much rather use the Serial Request node instead.
This is not a hack, it is a perfectly normal way of communicating over serial ports.
Node-red allows you to manipulate and filter messages, so that it should not be a real problem to filter out the echo message at all.
Well, yes it works, the problem is I loose the nice 1 to 1 "Request/Response" behavior offered by the Serial Request node. It is possible to do it with Serial In/Out, but requires additional timeout and blocking logic which will need to be implemented to achieve the same function.
All do-able, but it is a lot of programming just to work around and mask the root cause of the problem.