user38088: I would like to have all serial output from Arduino (nano) dumped to the terminal in Linux, without blocking the serial port for uploading new sketch version (for quick debugging loop), when using Arduino-Makefile:
[Errno 16] could not open port /dev/ttyUSB0: [Errno 16] Device or resource busy: '/dev/ttyUSB0'

Is there something made for that already? I did read about 10 related questions here and elsewhere (using screen, socat and others) but none of them deals with the question how to not block the port.
I might eventually code something in Python, which will disconnect when  signalled and reconnect again after a few seconds (I use custom Makefile for the upload) and I imagine Arduino's IDE serial monitor does something similar.
Other pointers on how to solve the issue are appreciated!

user38721: You can write your own python script that prints received serial output. By using try/except in a loop you can "pause" your serial monitor while uploading is in progress.
I did the same a while ago using pyserial on linux. I'd like to share it, but at the moment I have no access to my other machine. I can post it later if you want.

user7727: 
(using screen, socat and others) but none of them deals with the question how to not block the port.


Other pointers on how to solve the issue are appreciated!

I say:

Virtually all hardware problems can be solved with software. But, sometimes, the $50000 software problem can be solved with the $2 hardware solution.

This is one of those cases. Buy a CP2102 6-pin serial UART USB adapter for < $2 on Ebay, or for < $10 on Amazon, to provide a second serial interface to the same Arduino (both connected to the same hardware UART built in to the Arduino's ATmega328 mcu). Let the main USB serial interface handle code uploads to the Arduino. Let this 2nd, external UART handle READ-ONLY from the Arduino!
Plug it in:
Arduino     CP2102 USB 6-pin UART
-------     ---------------------
Tx          Rx
GND         GND

Done. Do NOT plug in the CP2102 Tx to anything.
Now, use picocom (one of my favorites), screen, or my crude datalogging Python serial terminal I wrote here (eRCaGuy_PyTerm), or a 2nd instance of the Arduino IDE with the Serial Monitor, or any other serial terminal for that matter, to read from the CP2102 while the Arduino's built-in USB adapter does code uploading.
Two serial interfaces to the same pins on the Arduino: one does Tx/Rx to/from the Arduino, while the other does only Rx to read from the Arduino.
I use a 2nd UART like this all the time as a trick to allow me to read the data from the Arduino into one Serial Monitor in one instance of the Arduino IDE so I can see the numbers, and I use the external CP2101 USB adapter to read the same exact data from the Arduino into the Serial Plotter of another instance of the Arduino IDE so I can see the live, plotted graphs!
It's amazing how well this works. Quick hack. Easy solution.

Note: to you use my eRCaGuy_PyTerm Python serial terminal, first set all your serial parameters inside the user_config.py file, then run python3 serial_terminal.py to run the program. It is a 2-way serial terminal, with datalogging. It works quite well. I really should improve its readme and post some examples someday.

38088: <p>I would like to have all serial output from Arduino (nano) dumped to the terminal in Linux, without blocking the serial port for uploading new sketch version (for quick debugging loop), when using <a href="https://github.com/sudar/Arduino-Makefile" rel="nofollow noreferrer">Arduino-Makefile</a>:</p>

<pre><code>[Errno 16] could not open port /dev/ttyUSB0: [Errno 16] Device or resource busy: '/dev/ttyUSB0'
</code></pre>

<p>Is there something made for that already? I did read about 10 related questions here and elsewhere (using <code>screen</code>, <code>socat</code> and others) but none of them deals with the question how to not block the port.</p>

<p>I might eventually code something in Python, which will disconnect when  signalled and reconnect again after a few seconds (I use custom Makefile for the upload) and I imagine Arduino's IDE serial monitor does something similar.</p>

<p>Other pointers on how to solve the issue are appreciated!</p>
 38721: <p>You can write your own python script that prints received serial output. By using try/except in a loop you can "pause" your serial monitor while uploading is in progress.</p>

<p>I did the same a while ago using <code>pyserial</code> on linux. I'd like to share it, but at the moment I have no access to my other machine. I can post it later if you want.</p>
 7727: <blockquote>
<p>(using screen, socat and others) but none of them deals with the question how to not block the port.</p>
</blockquote>
<blockquote>
<p>Other pointers on how to solve the issue are appreciated!</p>
</blockquote>
<p>I say:</p>
<blockquote>
<p>Virtually all hardware problems can be solved with software. But, sometimes, the $50000 software problem can be solved with the $2 hardware solution.</p>
</blockquote>
<p>This is one of those cases. <a href="https://www.ebay.com/sch/i.html?_from=R40&amp;_trksid=p2380057.m570.l1313&amp;_nkw=serial%20uart%206%20pin&amp;_sacat=0" rel="nofollow noreferrer">Buy a CP2102 6-pin serial UART USB adapter for &lt; $2 on Ebay</a>, or <a href="https://amzn.to/33JB1Jf" rel="nofollow noreferrer">for &lt; $10 on Amazon</a>, to provide a second serial interface to the same Arduino (both connected to the same hardware UART built in to the Arduino's ATmega328 mcu). Let the main USB serial interface handle code uploads to the Arduino. Let this 2nd, external UART handle READ-ONLY from the Arduino!</p>
<p>Plug it in:</p>
<pre><code>Arduino     CP2102 USB 6-pin UART
-------     ---------------------
Tx          Rx
GND         GND
</code></pre>
<p>Done. Do NOT plug in the CP2102 <code>Tx</code> to anything.</p>
<p>Now, use <a href="https://github.com/npat-efault/picocom" rel="nofollow noreferrer"><code>picocom</code></a> (one of my favorites), <code>screen</code>, or <a href="https://github.com/ElectricRCAircraftGuy/eRCaGuy_PyTerm" rel="nofollow noreferrer">my crude datalogging Python serial terminal I wrote here (eRCaGuy_PyTerm)</a>, or a 2nd instance of the Arduino IDE with the Serial Monitor, or any other serial terminal for that matter, to read from the CP2102 while the Arduino's built-in USB adapter does code uploading.</p>
<p>Two serial interfaces to the same pins on the Arduino: one does Tx/Rx to/from the Arduino, while the other does only Rx to read from the Arduino.</p>
<p>I use a 2nd UART like this all the time as a trick to allow me to read the data from the Arduino into one <strong>Serial Monitor</strong> in one instance of the Arduino IDE so I can <em>see the numbers,</em> and I use the external CP2101 USB adapter to <em>read the same exact data from the Arduino</em> into the <strong>Serial Plotter</strong> of another instance of the Arduino IDE so I can see the <em>live, plotted graphs!</em></p>
<p>It's amazing how well this works. Quick hack. Easy solution.</p>
<hr />
<p>Note: to you use my <a href="https://github.com/ElectricRCAircraftGuy/eRCaGuy_PyTerm" rel="nofollow noreferrer">eRCaGuy_PyTerm</a> Python serial terminal, first set all your serial parameters inside the <code>user_config.py</code> file, then run <code>python3 serial_terminal.py</code> to run the program. It is a 2-way serial terminal, <em>with datalogging</em>. It works quite well. I really should improve its readme and post some examples someday.</p>
