Serial Port Management Features?

#1

Just throwing a few ideas out there about Serial Ports. Do you think it will ever be possible to Open, Close, or Configure a Serial Port from inside a Running Flow?

I am thinking I should be able to Modify that "Configuration Node" of a Serial Port to Change Baud, Stop, Parity.
I guess I will try to implement the work around.

End Goal- is to eventually figure out how to have a serial port automatically change its settings(using a few reconfigured Serial Port Templates), until "human readable" chars are found. I work with a lot of Scales, Thickness Gauges, Instruments which all have Serial Ports. End users will be moving equipment, unhooking, re-hooking cables, potentially.

I might just have to do this in Python until higher level management features are added in Node-Red(Open Port, Close Port, Configure Port).

1 Like
#2

Sounds a bit too specialised for general usage. What happens when you plug into a device that expects to be talked to first ? does it send random characters to provoke a response ? How can it guess what to send ? - by the time it has guessed what to say you could have looked up the baud rate in the manual :slight_smile:

I guess most things do use 8 bits, 1 stop and no parity... but are you going to iterate over all those combos as well ?

#3

This is also going to be highly platform specific. Certainly Windows and Linux have very different ways of managing serial ports.

#4

a little off-topic, but I recently found that a fresh usb-tty in RPi using NR serial port is NOT binary transparent without adjusting settings in stty outside of NR. had me going for more than a few hours suspecting my firmware at the other end of the link - until I notices that 0x11 & 0x12 incoming seemed primarily affected.

#5

Hi Guys,
Thanks for the feedback. Ignore my End Goal for a second. Do you foresee any reasons of not being able to Open or Close a Serial Port from a Running Flow? If a Serial Port is Closed you should be able to update the Configuration Node of Serial Port.

I am not sure how Node Red currently Auto Opens Serial Ports. Or the fundamentals behind Configuration Nodes, maybe they can only be changed and require a redeploy?

In the future could it be possible to Open, Close and Configure a Closed Port from inside the Flow?

1 Like
#6

This is really a question about how serial ports work. As I say, this is different depending on the platform. After the platform differences, it is then down to the way that Node.JS uses the ports. You may have seen after a Node.JS update that the serial port module has to be rebuilt. That's because it is a platform dependent binary that has to be recompiled.

In general, serial port devices can only be opened by a single process, even opening them as read-only locks them. So unless Node.JS has a way to release the ports (I suspect it does but I'm not an expert), Node-RED won't be able to either.

1 Like
#7

In theory it could be possible for the config node to close and restart the port. However as config nodes have no dynamic input there is no easy way to set those internal settings. You can use environment variables to set those that are text easily enough - but they only get read when the node is re-deployed.

Also top level nodes (the in and out). The In from the serial port node has no input wire so there is no concept of being able to change its configuration dynamically, so realistically I think this would be a new sort of serial node.

2 Likes
#8

Is anyone up for working together to write this node?

I have no experience writing nodes but love node-red for its IOT applications and would love to find a way to help create something useful to the community.