Reconnect after power cylce leads to error

What is the problem?

Can't reconnect after a power cycle. Normal power cycle or emergent power off seem to make no difference. I have a random bug with Marlins UBL where after some prints the Z offsets drifts a crazy amount. Really annoying... In such emergent case I power off the device through the power supply to not damage the bed any further. The USB is still connected then. This is on WIN10 as I test Octoprint till I have PI in the mail box. Powering on again and Octoprint can't reconnect. BTW why it doesn't try to reconnect automatically?

What did you already try to solve it?

Checked the USB cable. Taped the 5V connection from PC which is great for another reason but didn't resolve the issue. Changed a seriell port related registry entry as fix mentioned here on the forum.
(Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\sermouse)
There is the advice to install the Maple driver but its not possible as the driver is not signed and whatever I tried my machine doesn't want to install it. The connection is there so I don't know if the Maple driver is really essential.

Have you tried running in safe mode?

No

Did running in safe mode solve the problem?

No

Complete Logs

Changing monitoring state from "Offline" to "Opening serial connection"
Connecting to port COM3, baudrate 115200
Changing monitoring state from "Opening serial connection" to "Error: Connection error, see Terminal tab"
Changing monitoring state from "Error: Connection error, see Terminal tab" to "Offline (Error: Connection error, see Terminal tab)"
Unexpected error while connecting to serial port COM3, baudrate 115200 from hook default: SerialException: 'could not open port 'COM3': PermissionError(13, 'Zugriff verweigert', None, 5)' @ comm.py:_open_serial:3666

What is interesting there seems to be an PermissionError after this happens but I couldn't find any solution for it. Is there anything I could try?

Additional information about your setup

Latest Octoprint on WIN10 with a SKR mini E3 2.0 on an Ender 3

Argh, getting worse. In the end of the last print at 88% I came back to seee the connection is lost to Octoprint.

State Message: Offline (Error: SerialException: 'ClearCommError failed (PermissionError(13, 'Das Gerät erkennt den Befehl nicht.', None, 22))' @ comm.py:_readline:3831)

This was my terminal log. But doesn't show anything that leads to the connection loss but maybe I didn't recognize it.
print_terminal_log.gcode (49.2 KB)

I don't know yet where Octoprint got its log. Searching for it.

The Workstation was running and of course no energy saving feature activated. Anyone got an idea why its constantly losses its connection and why I can't reconnect?

Do you have any slicers installed on the PC?

Cura particularly likes to rob any serial connections as soon as you open it, it can be quite greedy :slightly_smiling_face:

Generally I would look to see if something else is opening/running in the background that might be using it, permission errors in Windows are annoying.

Yes. Cura is my main slicer. I have it connected to OctoPrint with a cura plugin so its sends the gcode to OctoPrint. I heard of cura being buggy about USB connections. Even had to change a script after I switched to the SKR mini E3 2.0 bc the ender was screaming an alarm buzzer sound throughout as soon it was connected.

I didn't find any info with a fix regarding my error code so I'm a bit lost here. It is weird as if I disconnect the printer through OctoP, I can reconnect without problems but as soon as I have to reset the printer or did a regular power cycle, I need to unplug the USB cable once and then it works. So if Cura should be the culprit, I would think on replugging the USB connection it would then block the connection again and I wouldn't be able to connect. But this is not the case.
With this happening pretty often I'm not quite sure about a raspberry and full OctoP operation anymore.

//Edit: Also can't reconnect after sending M997.