# Modbus and Serial IN/OUT nodes (both) use one serial port

**URL:** <https://discourse.nodered.org/t/modbus-and-serial-in-out-nodes-both-use-one-serial-port/81136>\
**Category:** General\
**Created:** [8 September 2023 08:42 UTC](https://discourse.nodered.org/t/modbus-and-serial-in-out-nodes-both-use-one-serial-port/81136 "2023-09-08T08:42:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![John1](https://avatars.discourse-cdn.com/v4/letter/j/e9bcb4/32.png) [@John1](https://discourse.nodered.org/u/John1)\
**Post date:** [8 September 2023 08:42 UTC](https://discourse.nodered.org/t/modbus-and-serial-in-out-nodes-both-use-one-serial-port/81136/1 "2023-09-08T08:42:56Z")

</div>

Hello community.  
I have one device connected to serial port of device where Node-red runs (for instance - USB/RS485 converter connected to COM3). But, in Node-red flow, I have Modbus-Flex-Getter node and Serial IN/OUT nodes. Both use same port COM3. When some event has been occured (for instance I got the message from MQTT or HTTP) Modbus-Flex-Getter node should be "activated" and communication with COM3 in Serial IN/OUT nodes shoud be closed. When some other event has been occured - Modbus communication should be closed and communication via Serial IN/OUT node will be restored.

In other words. I have one global bool variable. State of that variable will decide what node (Modbus or Serial IN/OUT) uses COM3.

Any ideas how to solve this issue?

I know one possible solution on this issue - just replace Modbus-Flex-Getter node with usual function where Modbus frame is created manually. And use only Serial IN/OUT nodes. But, in such case, there are a lot of hardcoding...

---

<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:** [7 November 2023 08:43 UTC](https://discourse.nodered.org/t/modbus-and-serial-in-out-nodes-both-use-one-serial-port/81136/2 "2023-11-07T08:43:36Z")

</div>

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