After the update to 1.5.x I keep running into SerialExceptions

@foosel - Update: After printing more or less none stop since yesterday, running 1.5.2 and Python 3.7.3 after a clean SD card image reload I am no longer (touch wood) getting serial time out issues.

I have reloaded all the plugins, apart from GCodeEditior and all is well (plugin list below)

One thing of note, I would get print time out errors when using the BLough-R USB mod (physical device to block the 5V feed), now I am using a bit of electrical tape to block the 5v feedback pin.

But so far, it appears wiping the SD card, and reloading OctoPi, bypassing 1.5.0 and 1.5.1 and going right to 1.5.2, along with a Python 2 to 3 upgrade appears to have fixed my issues.

Lets see how long this lasts.

Plugins I use:
Bed Visualizer (1.0.0)
Creality Temperature (1.2.4)
Creality 2x temperature reporting fix (0.0.4)
HeaterTimeout (0.0.3)
Navbar Temperature Plugin (0.14)
Octolapse (0.4.1)
PrintTimeGenius Plugin (2.2.7)
UI Customizer (0.1.1.1)

Hi,

I notice communication timeout since few days, causinf printer to stop and i thought it was since the recent updates in 1.5.x.

But after reding this thread, i checked my usb plug that i modded to avoid 5v pin, and noticed that the tape masking the 5v was a little scratched. I just put a new tape to mask 5v and see if it works better.

My info:
browser.user_agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36
connectivity.connection_check: 84.200.xx.xx.xx
connectivity.connection_ok: false
connectivity.enabled: true
connectivity.online: false
connectivity.resolution_check: octoprint.org
connectivity.resolution_ok: false
env.hardware.cores: 4
env.hardware.freq: 1500
env.hardware.ram: 1979641856
env.os.bits: 32
env.os.id: linux
env.os.platform: linux2
env.plugins.pi_support.model: Raspberry Pi 4 Model B Rev 1.1
env.plugins.pi_support.octopi_version: 0.17.0
env.plugins.pi_support.throttle_state: 0x0
env.python.pip: 19.3.1
env.python.version: 2.7.16
env.python.virtualenv: true
octoprint.safe_mode: false
octoprint.version: 1.5.2
printer.firmware: Robin

  • Printer model - FLSun Q5 used exclusively with octopi since months flawless.
  • OctoPrint, Python & (if applicable) 1.5.2 /
  • Whether a connection to the printer was active at point of update or not - Yes I think
  • Whether the issue persists in safe mode not tested
  • Whether the issue persists after switching the USB port - not tested
  • Whether the issue persists after a reboot of the system OctoPrint is installed on - Yes
  • If on a Pi:
  • Pi model - 4B rev1.1
    octoprint.log (44.8 KB)

Wrong kind of issue, we are explicitly looking for increases of SerialException here. Communication timeouts as visible in your log are usually caused by the firmware stopping to respond to OctoPrint - firmware issues or crashing controllers.

@Steverino I don't want to rule this out, but I also think that if this was a general issue with 1.5 on Pis and Python, we would be seeing WAY more of this. I'm currently looking at over 33k confirmed instances on 1.5.x with over a million hours of printing between them. Yet we only so far have a handful of reports in this thread here, and so far all but one of these (whose issues turned out to be coincidence caused by a mintemp error thanks to lower temperature) seem to run Creality printers.

Looking at the posix implementation of pyserial it also seems to be utilizing OS functions for the serial implementation, with a heavy utilization of select and ioctl. The specific location where the error we are trying to understand here gets raised is here:

which I read as "this will happen if select.select reported available data to be read from the serial port's file descriptor, yet upon trying to read it it wasn't there". My understanding here is that the kernel driver for the serial device takes care of the serial protocol and timings itself, and gets utilized via its file interface from Python - pretty much being treated as a bidirectional data pipe with some ioctl sugar sprinkled on top. Based on this I'm not sure that the issue is even within anything implemented in Python. I'd be happy to get corrected here however.

Still having an issue with the USB after the update, but it running great in safe mode. I'm thinking its a plugin problem now. The only two plugins I have are AstroPrint (1.6.3) and TP-Link Smartplug (0.9.26). Will do some more testing later today with one plugin at a time. time.octoprint.log (206.8 KB)

I'd hate to think it's my TPLink plugin, as I use it regularly and have not had SerialException errors at all. If it does turn out to be the culprit, I'd need logs and an issue opened on the plugin's github repo.

Edit: It could be that the plugin is doing what it's told to do and powering off your printer on a temperature runaway setting or something similar?

Gina,

Itā€™s not, although is probably is. I did a bit of research on how the BCM2837 does USB. I couldnā€™t find the actual hardware manual (I put a request into Broadcom, but have not heard back), but I found the hardware peripheral info on the BCM2835 (used in the PI2), so it is probably similar to the one used in the PI3B. The operation of the serial ports (including the USB is similar to the 16550 UART without the DMA.

Anyway, without going into a lot of hardware talk, my suspicions seem to be correct, although I have no idea how Raspbian does itā€™s I/O. What happens is the serial data is assembled and written into a register. The processor has a limited amount of time to extract that data before the next byte is written into the register. There is a limited time after the serial interrupt when the data has to be retrieved from the UART before new data is written into the register. Timeouts and serial exception mean that when the interrupt occurs, data is not timely read from the register, and so the processor canā€™t get any the serial data. One can calculate this time, but obviously, Raspbian is not getting the data fast enough before the next byte of data comes in.

The problem mainly occurs when the serial handler is poorly written, and priority is not given to the serial interrupt. Remember, I have no idea how Raspbian does their serial I/O (USB), nor how it is programmed, so I canā€™t pinpoint where the problem lies. Unfortunately, Gina, I donā€™t think you can do anything about it, except find a real-time linux that will run on the PI.

What makes the Pi different? On big computers, USB is typically handled by DMA (direct memory access), where the data from the UART is written directly into a memory buffer, and therefore, timing is only critical to keep the buffers switched so the data keeps flowing. X86 architecture is like this, and the 16550 UART works like this. The little machines (like the PI or the Arduino) donā€™t have enough real estate on board to implement this, and so you have timing issues on high data throughput.

My suspicion on Raspbian is that they ported Debian without rewriting (or minimally rewriting) the I/O handling. These tiny chips require a total rewrite of the I/O handlers when used in a high-throughput or real time capacity. A real-time OS (or a real-time Linux) should have done this already.

When it comes to the snake (Python), how the implementation of the language interpreter and garbage collector interface with Linux may be part of the problem. If they are part of a Linux thread spawn (at the OS level), then all that software can affect the I/O timing because of the software load. You might not even know this from CPU utilization because CPU utilization might not even be calculating this. I typically go by CPU temperature to determine the load on the CPU, not the utilization number. On my PI 2B+, based on the temperature, the CPU utilization Is fairly high because I can see throttling taking place, and the 3D prints show it.

My only comment is to try to explain what is going on, not specifically how to fix it. The real fix is not to use Raspbian as a real-time OS, and to code certain portions of Octopi in C or C++, but I understand this probably isnā€™t practical.

Take a look at the source code of Marlin, and you will get a fair idea of writing embedded code. The PI is great for some things, but not great for others. Octoprint might have been better on an Arduino, not a PI. The Arduino is a simpler architecture and is easier to code without an OS.

The PI isnā€™t a big general purpose computer that does multiple things. Itā€™s a tiny machine, that probably does one or two small things well. I had a similar argument in another part of this forum where I was asking questions about shutting off the main power supply of the printer, which also powers Octoprint. I got arguments as to why the PI should be left on all the time because it can do other things. I countered this argument, but I couldnā€™t convince some folks. Anyway, I figured out how to do what I wanted to do on my own, and now Octoprint nicely shuts down the printer power supply when it shuts down.

Steve

@Steverino as I said though, of this was a case of "the pi is at its limit with 1.5.x and python is just ill suited here" we'd see way more cases of this, across all possible printers. We don't. In fact we only see a handful. That does not indicate a general fundamental problem rooted in OS and/or architecture - that is identical to literally thousands of setups that print problem free. We are trying to identify a pattern here that differs from the setups known to work. Considering the available information, I find "Raspbian combined with Python" to be the cause here somewhat unlikely.

Depends on what is going on inside the processor.

Just giving my opinion.

@foosel

Just an update for you, printing using 1.5.1 after a few days, I've had no serial connection issues.

I've removed the 'OctoPrint-TuyaSmartplug' and 'GcodeEditor' plugins and I've not had any issues.

Now i know versions of GCodeEditor prior to the latest are included in the plugin blacklist. So that may not be playing nice with OctoPrint.

Also, the TuyaSmartplug plugin was logging errors into the octoprint.log for a while also the install.

Unfortunatly I no longer have those logs.

Intermediary summary:

  • :white_check_mark: @Doug_s_Printing:
    • unknown printer w/ Marlin 1.1.9 (ADVi3++ 4.0.6-dev)
    • OctoPrint 1.5.2, Python 2.7.16, OctoPi 0.17.0
    • communication timeout with 1.4.2
    • 1.5.2 works w/o issue in safe mode, suspects Astroprint or TP-Link Smartplug
  • :x: @Rancorbin:
    • Ender 5 plus
    • no further info
  • :no_entry: @Spooky_Wookie:
    • Ender 3 & CR10s Pro
    • false positive, "too many timeouts"
  • :no_entry: @drfish:
    • Prusa Mini
    • false positive, room too cold & mintemp
  • :white_check_mark: @Red_Gorilla:
    • unknown printer
    • switching USB port solved issue
  • :white_check_mark: @apainter2:
    • Ender 3 v2 w/ Marlin E3V2-2.0.x-14-Smith3D.M (Oct 13 2020)
    • OctoPrint 1.5.1, Python 3.7.3, OctoPi 0.17.0
    • downgrade to 1.4.2 w/o reboot still caused issue, after hard reboot printed without any failures in safe mode
    • reflashed card, switch to Python 3.7.3, upgrade to 1.5.2, minimal plugins (creality temperature, creality 2x reporting fix, printtimegenius, ui customizer) -> no issue
    • no issue since removing TuyaSmartplug and GcodeEditor from plugin collection
  • :x: @AevnsGrandpa:
    • Ender 3 w/ MKS Gen L & Marlin TH3D U1.R2.B5
      • no problem on Artillery Sidewinder X1 w/ MKS Gen L & vanilla Marlin
    • OctoPrint 1.5.1, Python 3.7.3, OctoPi 0.17.0
  • :no_entry: @fificap:
    • FLSun Q5
    • false positive, "too many timeouts"

Legend: :x: exception problem reported and unsolved, :white_check_mark: exception problem reported and solved, :no_entry: false positive

1 Like

OctoPrint 1.5.2
Ender 5 Pro
Debian Buster
Creality board 4.2.2
Creality firmware 1.3.1 w/BLTouch with Adapter
Python 3.7.3

Troubleshooting:
Disabled plugins

Changed USB cable power feed is taped off.
Applied OS updates
Changed USB port
Enabled logging

Current PLUGINS:
Bed Visualizer
Detailed Progress
Exclude Region
Navbar Temperature Plugin
PrintTimeGenius Plugin
Printer Dialogs
Printer Notifications
Sidebar Webcam
Simple Emergency Stop
Themeify
Thingiverse Plugin
Virtual Printer
Octolapse

I enabled logging and after the USB port swap and I haven't been able to duplicate since.
I had experienced the Serial Connection error three times deep into a two seperate model prints five to six hours into three 8 hour prints.
To the best of my knowledge my printer was connected and powered on with the upgrade of Octoprint. I haven't duplicated the condition as of yet since changing usb ports
After applying the updates in Debian and changing the usb port it seems to have possilbly resolved my issue. If I can duplicate the error I will publish the serial.log files.

octoprint (2).log (387.6 KB)

Just as a reference changing my usb port seems to have resolved my issues. I have not been able to duplicate the error..

@foosel

After several days of printing the error has for some reason returned, and is more or less constant.

A long 26 hour print, failed 3 hours in. Nothing on my end has changed, I have attached the octoprint.log file for you. Time index of the failure is around 2020-12-24 18:48:57.

I'm at a loss, so much so I placed an order for a Prusa i3 MK3S+, trying not to simply scrap this printer, would like to get it fixed somehow.

octoprint (8).log (2.1 MB)

Details:
Plugins installed

  • UI Customizer[uicustomizer] v0.1.1.8
  • PrusaSlicer Thumbnails[prusaslicerthumbnails] v0.1.3
  • Preheat Button[preheat] v0.5.1
  • Cura Thumbnails[UltimakerFormatPackage] v0.2.1
  • Resource Monitor[resource_monitor] v0.2.7
  • PrintTimeGenius Plugin[PrintTimeGenius] v2.2.7
  • Navbar Temperature Plugin[navbartemp] v0.14
  • HeaterTimeout[HeaterTimeout] v0.0.3
  • Filament Manager[filamentmanager] v1.6.3
  • Creality Temperature[CrealityTemperature] v1.2.4
  • Octolapse[octolapse] v0.4.1
  • DisplayLayerProgress Plugin[DisplayLayerProgress] v1.24.0
  • Creality-2x-temperature-reporting-fix[ender3v2tempfix] v0.0.4
  • Bed Visualizer[bedlevelvisualizer] v1.0.0
  • Action Commands[actioncommands] v0.3

Software versions

  • OctoPrint 1.5.2
  • Python 3.7.3
  • OctoPi 0.17.0

To me it looks like it's at this line...

2020-12-24 13:58:32,642 - octoprint.util.comm - ERROR - Unexpected error while reading from serial port
Traceback (most recent call last):
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint/util/comm.py", line 3831, in _readline
    ret = self._serial.readline()
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint/util/comm.py", line 6455, in readline
    c = self.read(1)
  File "/home/pi/oprint/lib/python3.7/site-packages/serial/serialposix.py", line 596, in read
    'device reports readiness to read but returned no data '
serial.serialutil.SerialException: device reports readiness to read but returned no data (device disconnected or multiple access on port?)
2020-12-24 13:58:32,692 - octoprint.util.comm - ERROR - Please see https://faq.octoprint.org/serialerror for possible reasons of this.

Your printer has stopped communicating, with a link to https://faq.octoprint.org/serialerror in the log. I notice you have 2 different creality temp fix plugins installed, might not need more than one? Have you tried minimizing the amount of enabled plugins to just those necessary for your printer to be able to connect. Since it looks like you have Smith 3D firmware I doubt you even need the creality fix plugins at all.

I used sudo apt full-upgrade to update everything on the pi and it fixed my issue.

TL;DR - I can trigger it reliably in my case just by issuing M303 to run PID autotuning. I think there's something fishy going on with the mainboard and firmware on my CR6-SE that's causing this in my case. Using 'minicom' to run the M303 command does complete, but throws its own warning that it lost the serial port connection 30 seconds into the M303 - the same point that Octoprint drops out (minicom just carries on, however - built for the good old days of unreliable serial comms I'm guessing it reconnects automatically).

octoiprint-log-and-terminal-capture.zip (8.0 KB)
I've just hit this. The printer, with Octoprint on the RPi, has been running fine for a good number of weeks since I rebuilt the Pi with the 0.18 Octoprint to try Python 3. It's a Creality CR6 SE, so I have the 5v line on the USB cable isolated.

A print job had finished fine and the printer had been idle for a while (just reporting temperature), and I went to run the PID autotuning from the Terminal. A short time into that, the SerialException was thrown.

In its current state (I haven't power cycled the printer or restarted the Pi or Octoprint yet), it's repeatable - I waited for the PID autotune seqence to finish (the printer carries on doing it after Octoprint disconnects), then reconnected from Octoprint and issued the M303 again. The SerialException report recurred after a similar time into the command.

I switched debug on in Octoprint (I think - added DEBUG for 'octoprint' in the bottom of the logging tab), and did the M303 thing again a couple of times. Octoprint log and terminal capture attached.

I've now restarted Octoprint (not the whole Pi) - same behaviour; I get the SerialException part way into M303.

Now restarted the Pi - same behaviour.

Switched printer off and on - same behaviour.

Installed minicom onto the pi, use it to connect to the printer to run M303 - that worked, however I notice minicom flashed up "Cannot open /dev/ttyACM0" occasionally. In fact the first time it flashed up, is about the same point that Octoprint disconnected (about 30s after the M303 command is issued). I'm guessing that minicom is seeing the same glitch on the serial port that Octoprint is seeing, but is treating it as a temporary issue and carrying on, whereas Octoprint makes it a hard fault. The "Cannot open" message seems to pop up every 30 seconds.

I ran an apt-get update/upgrade on the pi, but that didn't change anything.

I'm using a BTT mainboard (replacement for the Creality CR6 board) with the BTT firmware, which itself is a small delta to the Creality 1.0.3.6 firmware (which we believe branched sometime shortly after Marlin 2.0 - y'all know the drill here).

I'll look to try a more upstream Marlin version and report back here.

Update - I moved the Raspberry Pi to another printer, and lo and behold no problem there with M303. Moved it back and triggered it again with M303.

To state the obvious, this suggests strongly at the moment that my issue is not Octoprint.

The printer I moved it to is a much-modified Ender 3 with a BTT main board and a reasonably current Marlin (BTT do their firmware work on GitHub, and largely keep current with upstream Marlin - 2.0.5.3 I've modified it myself for various reasons and haven't updated for a while).

The CR6-SE is a bit unusual in that BTT have taken the Creality firmware (at least, the version they published the source code for) and tweaked that for their board, so unusually for BTT the firmware isn't current with upstream Marlin.

Difficult to tell from the history on this thread whether there's a common printer component to the reports, as not everyone has reported their precise printer configuration. So what I'm seeing may not be common - however I would say all the current Creality machines share a lot of firmware code, bugs and all, so if there's a firmware component to this issue it would likely affect a lot of current Creality machines.

So I have a couple of things to try. First is to put the Creality mainboard back to see if it's something with the BTT board. Then the firmware, get it closer to Marlin upstream - should be able to use upstream Marlin pretty much unmodified if I disconnect the touchscreen.

Replaced the Creality motherboard (with a firmware fix for the double-temperature-report mess), and no problem issuing M303 - no serial port drop-outs so far.

I had a similar issue here. I fixed the tornado warnings by deleting net gear software I didn't use on my computer but they have an alternate solution here. It didn't solve my issue but it got rid of the tornado warnings. There where a few firmware changes that did on my thread. I am on a skr mini e3 so it might work with your board.

Found what the difference was - with the BTT board, I had chosen to build using their STM32F103RC_bigtree_512K_USB PlatformIO configuration for Marlin which defines USE_USB_COMPOSITE. The Creality configuration didn't do that - and rebuilding with the BTT configuration STM32F103RC_bigtree_512K eliminated the problem.

I don't know what USE_USB_COMPOSITE macro does, but if I had to guess it's sharing the USB interface between serial and something else (debug probe perhaps?) and that sharing is causing glitches whereby it declares it has data available, when actually it doesn't.

So in summary; I had SerialException occur when USE_USB_COMPOSITE was defined for the Marlin build.

2 Likes