Trouble with connecting to the ttyUSB0 port on upload

Hello,
I’m having trouble connecting to the USB port (ttyUSB0) after compiling.

I’m not sure whether that is a specific problem related to pio or a more general problem.

After a few cycles of compiling/uploading a sketch suddenly its posting the message

A fatal error occurred: Could not open /dev/ttyUSB0, the port is busy or doesn't exist

The command ls -lha /dev/ttyUSB* shows crw-rw-rw- 1 root dialout 188, 0 Mar 22 12:14 /dev/ttyUSB0 .

I also run dmesg grep | ttyUBS* which shows [751240.961172] usb 3-2.1.1: ch341-uart converter now attached to ttyUSB0 as last line.

It seems I can’t fix the problem except I’m closing pio and open it again. Which then makes the USB port available. I don’ think that can be the only measure to deal with the problem.

Is there anything else I can do to avoid the problem?

I know a similar problem was discussed here :

but it seems to be of a different nature than my problem.

Any help is much appreciated.

TIA

For all who might run into the same problem.

My mistake was that the serial monitor was still active from the previous compiling/upload cycle and therefor the new compile/upload couldn’t work since the serial monitor (USB0) was still busy.

Probably no surprise to the experts; but I thought pio would be so smart that it would stop the monitor when executing the (new) compile command. But it didn’t.

Now I’m a little bit smarter (again).

TY