It possible to configure the Node-RED node "node-red-node-serialport" with `msg.port` to dynamically change the port?

Hello,

I have a question: Is it possible to configure the Node-RED node "node-red-node-serialport" with msg.port to dynamically change the port? For example, when I send msg.port=COM1, the serialrequest node changes to COM1, and when I send msg.port=COM5, it changes to COM5 and returns its response. I have read about this functionality in the serialrequest node, but I haven't found any documentation on it.

Can I modify the code of this node to meet my needs, or if that's not possible, are there any other nodes that offer this functionality?

It's in the docs here: node-red-nodes/io/serialport at master · node-red/node-red-nodes · GitHub

I tried using msg.port to control the serial-request node, but I found that the port does not change and remains on the one I configured manually.

As mentioned in the doc, you have to send a msg.payload with the matching format to change the values in the configuration node the serial-control node is pointing at. This config node is shared with the serial-in/serial-out/serial-request node.

I have an issue with the serial-control node, as mentioned on GitHub: Issue with node-red-node-serialport and serial control Node: “TypeError: newline.substr is not a function” when Using Fixed Length Split Configuration · Issue #1070 · node-red/node-red-nodes (github.com). I used the configuration "Split input into fixed lengths of 5000 chars", and this causes a problem with serial-control.

Is there another method to achieve this without using serial-control, or is there a change that can be made to the JavaScript code of the serial-request node to directly change the port with msg.port without using serial-control?

No

You can always submit a PR to fix the open issue.

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