Serial port left open when sketch program closed

Serial port opened by sketch is left open . When I try to run sketch again it fails with port busy
try - catch exception doesn’t work on re running program to close open port then reopen.
Is there a way , other than restarting PC to clear this?
Restarting or removing power from serial I/O card is only way that works!

Hello,

Close the sketch with a keypressed() function that will stop() serial port and exit()

Let me know if this works.

:)

1 Like

Hello,

I also came across this topic:

I have NOT tested it but it may have potential for adding a clean exit (saving data, closing serial port etc.) to sketches.

:)