What is the problem?
I have octoprint on a pi 4B (and previously a 3B+) connected to a custom built printer using an SKR 2 mainboard, via UART serial (not USB).
I noticed that when the pi is initially turned on and octoprint starts, it automatically connects to the printer OK. If I select 'Disconnect' and then attempt to reconnect, it would get stuck on "opening serial connection" and nothing would happen.
Attempting to diagnose the problem I booted octoprint into safe mode. It now fails to connect every time (even when starting octoprint) and I get this error:
Unexpected error while connecting to serial port /dev/ttyS0, baudrate 115200 from hook default: error: '(22, 'Invalid argument')' @ comm.py:_open_serial:3836
I found now that even restarting octoprint back into normal mode would now generate the same above error. I would have to completely power the pi down and reboot it (restart system) in order to get it to initially connect, and then hang on "opening serial connection" on the 2nd attempt again.
This pi is on a printer that I haven't finished building or started using yet. I initially noticed this problem (but didn't try and fix it) maybe a month or 2 ago using a pi 3B+ (that I already had laying around), that used a fresh SD card flash of octopi with octoprint 1.8.1.
When attempting to connect some accessories to my pi I accidently shorted and damaged a GPIO pin. I then recently swapped out the 3B+ with a brand new pi 4B, and reflashed the new SD card with the same octopi image. I restored an octoprint backup I had created from the 3B+ and reconfigured the rest manually (such as enabling serial using raspi-config). And updated octoprint to 1.8.5 via the notification when it boots up.
It appears the same problem has followed me, so possibly a problem that's created by 1.8.1 and not fixed in the updates?
I believe its the same as this unresolved problem: Octoprint not connecting via /dev/ttyS0 after upgrade to 1.8.1
What did you already try to solve it?
I have an oscilloscope and confirmed that the pi's TX line has data on it when it connects. However when I press disconnect and then reconnect, there is NOTHING transmitted when I hit reconnect.
I've confirmed powering down the mainboard after disconnecting (but leaving octoprint running), and then powering it back up before attempting to reconnect makes no difference.
I've logged in via SSH and installed minicom on the pi. Bridging the Pi's TX/RX pins, I can see all the letters I type echoed back at me using both /dev/tty0 and /dev/serial0. This is after octoprint wont connect (the problem has started). It seems minicom works with the serial pins fine but octoprint wont.
I added /dev/serial0 to the list in octoprint and attempted to connect with that instead, but it made no difference.
Have you tried running in safe mode?
Yes, the terminal then shows the above error. And it continues to show that error even after restarting octoprint back to normal mode. It only stops showing that error after rebooting the entire system.
Did running in safe mode solve the problem?
No, it made it worse (wouldn't even connect the first time).
Norman mode (hangs on "opening serial connection"):
octoprint-systeminfo-20221018093325_normal mode.zip (72.1 KB)
When in safe mode:
octoprint-systeminfo-20221018093911_safemode.zip (74.0 KB)
Additional information about your setup
OctoPrint version 1.8.5
OctoPi version 0.18.0
Printer: Custom built cartesian
Operating system: Windows
I guess my next option was to download a complete new image of octopi 0.18.0/octoprint 1.8.5 and start from scratch without restoring a backup.
However I'm not 100% sure it will fix it and would like to avoid that if possible.
Thanks in advance