Between debug sessions, plafrom.io does not know to close the monitor port so that it can upload, so I get this permission error. If I close the monitor port first it works fine.
raise SerialException("could not open port {!r}: {!r}".format(self.portstr, ctypes.WinError()))
serial.serialutil.SerialException: could not open port 'COM4': PermissionError(13, 'Access is denied.', None, 5)
*** [upload] Error 1
Is there a way to automate closing the monitor to avoid this error?