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

**URL:** <https://discourse.nodered.org/t/it-possible-to-configure-the-node-red-node-node-red-node-serialport-with-msg-port-to-dynamically-change-the-port/88816>\
**Category:** General\
**Tags:** node-red-node-serialport\
**Created:** [20 June 2024 15:00 UTC](https://discourse.nodered.org/t/it-possible-to-configure-the-node-red-node-node-red-node-serialport-with-msg-port-to-dynamically-change-the-port/88816 "2024-06-20T15:00:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![khalil\_khalil](https://avatars.discourse-cdn.com/v4/letter/k/ea666f/32.png) [@khalil\_khalil](https://discourse.nodered.org/u/khalil_khalil)\
**Post date:** [20 June 2024 15:00 UTC](https://discourse.nodered.org/t/it-possible-to-configure-the-node-red-node-node-red-node-serialport-with-msg-port-to-dynamically-change-the-port/88816/1 "2024-06-20T15:00:02Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)\
**Post date:** [20 June 2024 15:04 UTC](https://discourse.nodered.org/t/it-possible-to-configure-the-node-red-node-node-red-node-serialport-with-msg-port-to-dynamically-change-the-port/88816/2 "2024-06-20T15:04:38Z")

</div>

It's in the docs here: [node-red-nodes/io/serialport at master · node-red/node-red-nodes · GitHub](https://github.com/node-red/node-red-nodes/tree/master/io/serialport#control)

---

<div class="post-metadata">

**Author:** ![khalil\_khalil](https://avatars.discourse-cdn.com/v4/letter/k/ea666f/32.png) [@khalil\_khalil](https://discourse.nodered.org/u/khalil_khalil)\
**Post date:** [20 June 2024 15:27 UTC](https://discourse.nodered.org/t/it-possible-to-configure-the-node-red-node-node-red-node-serialport-with-msg-port-to-dynamically-change-the-port/88816/3 "2024-06-20T15:27:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)\
**Post date:** [20 June 2024 15:35 UTC](https://discourse.nodered.org/t/it-possible-to-configure-the-node-red-node-node-red-node-serialport-with-msg-port-to-dynamically-change-the-port/88816/4 "2024-06-20T15:35:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![khalil\_khalil](https://avatars.discourse-cdn.com/v4/letter/k/ea666f/32.png) [@khalil\_khalil](https://discourse.nodered.org/u/khalil_khalil)\
**Post date:** [21 June 2024 07:33 UTC](https://discourse.nodered.org/t/it-possible-to-configure-the-node-red-node-node-red-node-serialport-with-msg-port-to-dynamically-change-the-port/88816/5 "2024-06-21T07:33:44Z")

</div>

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)](https://github.com/node-red/node-red-nodes/issues/1070). 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`?

---

<div class="post-metadata">

**Author:** ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)\
**Post date:** [21 June 2024 07:39 UTC](https://discourse.nodered.org/t/it-possible-to-configure-the-node-red-node-node-red-node-serialport-with-msg-port-to-dynamically-change-the-port/88816/6 "2024-06-21T07:39:35Z")

</div>

No

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [19 September 2024 07:40 UTC](https://discourse.nodered.org/t/it-possible-to-configure-the-node-red-node-node-red-node-serialport-with-msg-port-to-dynamically-change-the-port/88816/7 "2024-09-19T07:40:15Z")

</div>

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