# Close and release serial Com ports from within flows

**URL:** https://discourse.nodered.org/t/close-and-release-serial-com-ports-from-within-flows/80329
**Category:** General
**Created:** [5 August 2023 05:50 UTC](https://discourse.nodered.org/t/close-and-release-serial-com-ports-from-within-flows/80329 "2023-08-05T05:50:42Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![MadTooler](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/madtooler/32/76728_2.png) [@MadTooler](https://discourse.nodered.org/u/MadTooler)
#### Post date: [5 August 2023 05:50 UTC](https://discourse.nodered.org/t/close-and-release-serial-com-ports-from-within-flows/80329/1 "2023-08-05T05:50:42Z")

</div>

As I have seen others searching in a couple of older posts, I need to release the Serial Com port from within running flows for use by other software. My specific need is to release my rpi pico boards from communication from Node-Red to allow for programming via VSCode all running on a raspberry pi 4b. Stopping and restarting Node-Red is not a very pleasant solution in my case.

Are there any plans to add the flow controlled options for releasing the ports, or does anyone have any working solutions for this type of use on raspberry pi linux based systems?

Thanks!

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [5 August 2023 06:50 UTC](https://discourse.nodered.org/t/close-and-release-serial-com-ports-from-within-flows/80329/2 "2023-08-05T06:50:19Z")

</div>

This is not going to be so simple. The same applies in VSCode - also need to close the project in order to release the port.

"A way" I can think of could be to use the node-red API to remove/post the flow.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [5 August 2023 08:22 UTC](https://discourse.nodered.org/t/close-and-release-serial-com-ports-from-within-flows/80329/3 "2023-08-05T08:22:27Z")

</div>

Another possibility would be to write a python (or whatever is your favourite language) application that manages the comms and communicates with node-red via (for example) MQTT. Then you could stop and start that using an exec node in node-red.

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [5 August 2023 08:43 UTC](https://discourse.nodered.org/t/close-and-release-serial-com-ports-from-within-flows/80329/4 "2023-08-05T08:43:16Z")

</div>

> [@MadTooler](#):
>
> My specific need is to release my rpi pico boards from communication from Node-Red to allow for programming via VSCode all running on a raspberry pi 4b

That is a very good use case justification for the serial node supporting disconnect/connect commands.

If I had time, I would submit a pull request. Is that something you are able to do? It would benefit many.

---

<div class="post-metadata">

### Author: ![MadTooler](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/madtooler/32/76728_2.png) [@MadTooler](https://discourse.nodered.org/u/MadTooler)
#### Post date: [5 August 2023 12:04 UTC](https://discourse.nodered.org/t/close-and-release-serial-com-ports-from-within-flows/80329/5 "2023-08-05T12:04:29Z")

</div>

I am not sure where/how to make the changes to the serial node myself. Even if I figured out a way, my code is usually more proof of concept grade than stable for the masses.

---

<div class="post-metadata">

### Author: ![MadTooler](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/madtooler/32/76728_2.png) [@MadTooler](https://discourse.nodered.org/u/MadTooler)
#### Post date: [5 August 2023 12:09 UTC](https://discourse.nodered.org/t/close-and-release-serial-com-ports-from-within-flows/80329/6 "2023-08-05T12:09:52Z")

</div>

I would rather not add a middle man to the serial communications. My node-red setup is actually working as the control interface for a CNC control which directly serial streams to a grblHAL setup on one pico and a custom motor driver with direct serial streaming as well. From my experience, MQTT would be far to slow for the fast gcode streaming needed for grbl to keep smooth motion.

---

<div class="post-metadata">

### Author: ![MadTooler](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/madtooler/32/76728_2.png) [@MadTooler](https://discourse.nodered.org/u/MadTooler)
#### Post date: [5 August 2023 12:15 UTC](https://discourse.nodered.org/t/close-and-release-serial-com-ports-from-within-flows/80329/7 "2023-08-05T12:15:52Z")

</div>

The VSCode setup I am running is programming in C++, not python. As long as I do not have the serial monitor running, it does not require closing the project to release the port back to other processes.

I am not sure how your suggestion of using the API would work. For now, I have been disabling the serial ports within my flow and deploying. Then uploading from VSCode, and finally redeploying with the ports enabled again. It is a bit of a hassle, and at different times, resetting my flows has losses in my process and machine control that could be sketchy under worst case scenarios.

Thanks all for the suggestions.

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [5 August 2023 12:24 UTC](https://discourse.nodered.org/t/close-and-release-serial-com-ports-from-within-flows/80329/8 "2023-08-05T12:24:28Z")

</div>

Rather than a Python script, you should consider using a virtual COM port that allows multiple access. Not used one for a while so can't remember the utility but they are available for both Linux and Windows.

---

<div class="post-metadata">

### Author: ![MadTooler](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/madtooler/32/76728_2.png) [@MadTooler](https://discourse.nodered.org/u/MadTooler)
#### Post date: [5 August 2023 12:30 UTC](https://discourse.nodered.org/t/close-and-release-serial-com-ports-from-within-flows/80329/9 "2023-08-05T12:30:55Z")

</div>

Thanks. I looked around a lot for a virtual com since another post suggested it too. I could not find anything that appeared to fit my application and would run on the rpi.

@Steve-Mcl I found a recent pull request that you were discussing with the requester. Not sure if it was something you all were considering folding in or not:

> <https://github.com/node-red/node-red-nodes/pull/1012>
>
> \<!--
> \## Types of changes
> 
> What types of changes does your code introduce?
> Pu…t an \`x\` in the boxes that apply
> \--\>
> 
> \- \[\] Bugfix (non-breaking change which fixes an issue)
> \- \[x\] New feature (non-breaking change which adds functionality)
> 
> \<!--
> If you want to raise a pull-request with a new feature, or a refactoring
> of existing code, it \*\*may well get rejected\*\* if it hasn't been discussed on
> the \[forum\](https://discourse.nodered.org) or
> \[slack team\](https://nodered.org/slack) first.
> 
> \--\>
> 
> \## Proposed changes
> 
> 
> 
> Auto reconnect time changed from hardcoded to configurable.
> 
> Add option to disconnect/reconnect serial port on demand.
> https://github.com/node-red/node-red-nodes/issues/330
> 
> I have updated locale for english, other langs will need to be updated.
> 
> \## Checklist
> 
> 
> \- \[x\] I have read the \[contribution guidelines\](https://github.com/node-red/node-red-nodes/blob/master/CONTRIBUTING.md)
> \- \[\] For non-bugfix PRs, I have discussed this change on the forum/slack team.
> \- \[\] I have run \`grunt\` to verify the unit tests pass
> \- \[\] I have added suitable unit tests to cover the new/changed functionality

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [5 August 2023 12:46 UTC](https://discourse.nodered.org/t/close-and-release-serial-com-ports-from-within-flows/80329/10 "2023-08-05T12:46:44Z")

</div>

I lost track of it.

I've nudged the guys involved.

Let's see.

---

<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: [4 October 2023 12:46 UTC](https://discourse.nodered.org/t/close-and-release-serial-com-ports-from-within-flows/80329/11 "2023-10-04T12:46:58Z")

</div>

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