Closed lnlp closed 3 years ago
So the plugin shouldn't effect what's available in the list, but it could be defaulting to use the "auto" option when it sends the connect command to octoprint. I'll take a look when I can.
So I just checked the code and I am using the option that is specifying he port, based on the default OctoPrint setting here so if you select AUTO and the option to save setting and manually connect it will use that, otherwise it will automatically use the one that was manually saved before. Maybe the time isn't long enough for the port to be available to connect with? Maybe increase the delay to 20 seconds and restart OctoPrint.
The problem still exists and there appears to be no usable workaround. This currently renders the plugin unusable for me. It not only fails to auto connect but also messes up my configured Serial port.
Below I describe additonal tests that I have performed:
I changed the Marlin2.0.5 firmware configuration so that it no longer shows a custom bootsceen to limit startup time. From manual printer power-on to "Printer ready" message on the printer display currently takes 8 seconds.
As a safety measure I have increased Tasmota plugin auto connect wait time to 20 seconds. I currently observe the following behavior:
I first switch on the printer and then boot octopi with OctoPrint so the serial printer device is available when OctoPrint starts.
Next in Settings / Serial Connection I explicitly set Serial port to one of my configured additional serial ports (as described earlier). I leave 'Auto-connect to printer on server start' disabled and then click Save to save the serial connection settings.
The selected serial port then shows up in the Connection widget on the main OctoPrint screen:
I can then connect manually with the 'Connect' button:
And can manually disconnect again with the 'Disconnect button'.
I can repeat the process as often as wanted and the selected Serial port always stays the same.
When disconnected I can manually switch off the Sonoff S26 switch that powers the printer (with on-switch on/off button), then switch it on again and after 8 seconds when printer display says "Printer ready" I can manually connect to the printer in OctoPrint with the 'Connect' button. This works without problems and the selected Serial port never changes.
When disconnected I can also switch off the printer via the Sonoff switch by selecting the Tosmota plugin power icon on the OctoPrint status bar which then switches off the Sonoff switch:
If I next MANUALLY switch ON the Sonoff switch again (with on-switch on/off button) wait 8 seconds until printer display shows "Printer ready", I can then manually connect to the printer again with the 'Connect' button in the OctoPrint Connection widget without problems and the selected Serial port never changes.
I then manually disconnect the printer via 'Disconnect' button again (just to be safe that it was properly disconnected) and then switch off power again via Tasmota plugin power icon the printer properly switches off and selected Serial port stays unchanged, but as soon as I try to power on the printer (Sonoff switch) via the Tasmota plugin power icon on the status bar:
The selected Serial port in the OctoPrint Connection widget INSTANTLY switches to "AUTO" and the previously available addtional serial ports are unavailable in the dropdown:
But, however, the FIRST TIME this is done the Tasmota plugin auto-connect will succeed anyway (and the proper Serial port is selected again in the Connection widget):
BUT doing this subsequently for a second time FAILS:
The instant switching of Serial port setting to "AUTO" and subsequent failure of the Tasmota Plugin auto connect only happen when the printer (Sonoff switch) is switched on via the Tasmota plugin power icon in the status bar. So the issue really appears to be caused by the Tasmota plugin.
More information:
After the failure only "AUTO" is available as Serial port option in the Connection widget. If I then check Settings / Connection Settings also in the settings menu "AUTO" is the only Serial port option available (and AUTO does not work, which actually I don't understand anyway).
In the Connection widget I have to select the (two half-round arrows) refresh button to make the additional ports available in the Serial port dropdown in the Connection widget again. But this still does not make them available again in the Settings / Connection Settings / Serial port dropdown however.
To make the additional ports show up in the Settings / Connection Settings / Serial port dropdown again I first must manually connect to one of the additional ports from within the Connection widget, otherwise they will not show up in Settings / Connection Settings / Serial port (another way to get these values appear again is restart OctoPrint, which makes little sense here). That I first have to manually connect to the printer with the 'Connect' button in the Connection widget before they are shown in OctoPrint Settings / Connection Settings again is appears to be a bug in OctoPrint as it seems not to do a refresh for available devices when the Settings are opend (it probably only checks if OctoPrint is started and the cached list of available ports is probably only updated when explicitly connected via the Connection widget - which is not good).
This Tasmota issue could possibly be related to the Tasmota plugin issues described here. But the Tasmota plugin issues described here occur only when powering up the printer with the Tasmota plugin. They do not occur when manually powering and connecting the printer.
Another observation: State messages in the State widget are not updated by the Tasmota plugin. So if I switch off the printer (Sonoff switch) via the plugin icon on the status bar, the "Error failed to autodetect serial port..." messages is still displayed, while I would expect that status to be cleared and updated with something like "Printer has been switched off.
Question unrelated to above issues: Are the available icons provided by the Tasmota plugin or are these resources included with/provided by OctoPrint? The Tasmota plugin allows to select a different status bar icon instead of the default lightning bolt. The selection of available icons is limited and appears not to use Google's material design icons (which Home Assistant uses). The Tasmota plugin does not provide a 3D printer icon, while material design icons does (printer-3d) and it would be nice if it was possible to use it for the Tasmota plugin.
Thre icons are from fontawesome 5. Relative to your issue though, are there any errors in your octoprint.log? Also, how are you defining your serial port as thre one you list does not look like a standard one. As I mentioned, the plugin doesn't do anything to alter the port list. Do you have any other plugins installed that might be causing a conflict, like port lister?
Also, how are you defining your serial port as thre one you list does not look like a standard one.
I am defining nothing. I just plugin my Ender-3 Pro printer (which was upgraded with the popular BigTreeTech SKR Mini E3 32-bit ARM main board) into the USB port of a standard Raspberry Pi 3B+ running on the latest standard OctoPi image. This happens to make itself visible as ttyACMx device on Linux and not ttyUSBx. I don't recall to have seen any ttyACMx's before but these appear to be used more often e.g. for certain Arduino boards (which the printer board actually kind of is, but STM32 instead of AVR MCU).
https://rfc1149.net/blog/2013/03/05/what-is-the-difference-between-devttyusbx-and-devttyacmx/
When developping on a USB-enabled embedded microcontroller that needs to exchange data with a computer over USB, it is tempting to use a standardized way of communication which is well supported by virtually every operating system. This is why most people choose to implement CDC/PSTN with ACM.
The /dev/serial/by-id/... name is very common to use. It explicitly refers to that device by it's USB device identifier, independent of which USB port the device is plugged. The Linux (USB) device enumeration process does not always assign the same sequence number (same ttyXXX name) after each reboot when multiple USB devices are connected.
"port lister" does not ring a bell. Does not sound like a plugin that I would have installed myself. The plugins that I have installed appear quite common and not exotic to me.
I will have a look at the log and other installed plugins.
Two things I don't understand:
As I mentioned, the plugin doesn't do anything to alter the port list.
Maybe not directly but it for sure triggers some action that causes above described problems.
It appears to (instantly) trigger a scan for available devices while the printer is still starting up and very probably (at that moment) is not yet available on the OctoPi host. Which is exactly the reason why Tasmota plugin allows to set a delay to wait for the printer to become ready and I have no clue why pressing the Tasmota plugin icon to switch on power causes the Serial port to instantly be set to AUTO (regardless of the delay configured for auto connect).
Are you also using a touch screen attached to your SKR?
Relative to your issue though, are there any errors in your octoprint.log?
Could you please check your octoprint.log fo errors?
The port lister plugin may actually help with the problem on the UI side of OctoPrint, but I still would like to try to figure out why this is happening. I'm curious if you were to use the ttyACMx
port with the save option instead of the by-id
port as a test if it would make a difference? That is how my board shows up. Can you explain how that by-id
port is added, because I do not get that on my set-up.
I am using the standard LCD that came with the Ender-3 Pro (no SKR).
I will look into OctoPrint log some later today.
I have now also enabled the standard MQTT plugin to receive event messages from OctoPrint.
When clicking the Tasmota plugin status bar icon I received the following MQTT messages:
When switching off printer via Tasmota status bar icon:
octoPrint/event/SettingsUpdated {"effective_hash": "12692ebf351cd2c49718ea0d65caef32", "config_hash": "a37a77b437f9e2ebd3ff140b105fe00c", "_event": "SettingsUpdated", "_timestamp": 1590419920}
When switching on printer via Tasmota status bar icon:
octoPrint/event/SettingsUpdated {"effective_hash": "40067dde47659dd239d2d561a9495e1e", "config_hash": "b02c4b53bb2c81f039e085f36a4e7462", "_event": "SettingsUpdated", "_timestamp": 1590419954}
These MQTT messages show that a press on the icon generates some action where settings are updated. Messages that settings have been updated is not what I would expect for these actions. Receiving status update messages instead would be more logical. Why are any settings updated by these actions (and which)?
While this may be perfectly valid, depending on how the Tasmota plugin is implemented, this could also indication that Serial port settings are changed (either explicitly or indirectly). In which case the updated settings would refer to changes to Serial port settings.
Yeah, the save event is triggered in my plugin, but only for internal settings of the "current status" (on/off) within the plugin section. So that does make sense. It works be easy enough to verify that by checking the config.yaml before and after the change.
I'm curious if you were to use the ttyACMx port with the save option instead of the by-id port as a test if it would make a difference?
It makes no (noticable) difference which of these is configured (and saved) as value for Serial port.
the save event is triggered in my plugin, but only for internal settings of the "current status" (on/off) within the plugin section.
OctoPrint and it's plugins are rather new to me. Would it be possible that your use of the save action (that causes the SettingsUpdated event) can introduce any side-effects that impact the Serial port setting?
It works be easy enough to verify that by checking the config.yaml before and after the change.
Where is this file located and what is its scope, OctoPrint or only the Tasmota plugin?
I have ran the following test sequence:
Repeating 7. and 8. only makes the auto connection fail again.
The attached file contains an extract from the OctoPrint log with results from above actions. Annotations have been added for each action to clarify which log entries belong to which action. (All log entries from start to end of the test sequence are included)
OctoPrint and it's plugins are rather new to me. Would it be possible that your use of the save action (that causes the SettingsUpdated event) can introduce any side-effects that impact the Serial port setting?
Not to my knowledge, no-one else has ever reported this before.
Where is this file located and what is its scope, OctoPrint or only the Tasmota plugin?
I'd look specifically in the serial port section and the tasmota plugin section. The file can be found in /home/pi/.octoprint/config.yaml
.
I'll review the logs and see if I can reproduce.
@kantlivelong, I know you've been working with the serial stuff lately in OctoPrint. Have you seen what @lnlp is describing here and in the octoprint_partial.log linked above? I've never seen/heard of this.
Could you confirm if this is still an issue for you with the latest version @lnlp?
Could you confirm if this is still an issue for you with the latest version
Cannot confirm on short term, haven't touched my 3d printer setup in months.
Possibly this was an issue related to Octoprint itself that may have been fixed in a later release. I do not remember exactly.
Printer: Ender-3 Pro with SKR Mini E3 1.2 main board. Firmware: Marlin 2.0.5. OctoPrint 1.4.0 running on OctoPi 0.17.0 OctoPi system: Rasberry Pi 3 Model B+ On/off switch: Sonoff S26 with Tasmota 8.1.0
OctoPrint settings: Additional serial ports: /dev/ttyACM0 /dev/serial/by-id/usb-LeafLabs_Maple-if00
Problem description:
I have auto connect enabled with 14s wait time (longer than 10s because of custom bootscreen). When switching printer on via power icon in OctoPrint status bar the value that was selected in the Serial port dropdown field (either of above additional serial port values) is reset to 'AUTO' and the above values are not available anymore. Then after the wait time OctoPrint tries to connect to the printer, but fails with following error message: "Error: Failed to autodetect serial port, please set it manually."
When I then click the Connection refresh button then the above additional serial ports are available again in the Serial port dropdown. If I then select either of above listed additional serial ports and manually select the 'Connect' button then the printer connects successfully. When I then power off the printer via the power icon in OctoPrint status bar the power off succeeds and the Serial port dropdown field value stays unchanged (one of above additional serial port values stays selected), but if I then power on the printer via the icon again, the above described problem repeats (Serial port is automatically set to AUTO) and the auto connect fails again with above error message.
The problem appears to be caused by the Tasmota plugin, because switching the printer on via the icon resets the selected serial port to Auto.
Auto connect is enabled:
After powering on printer via power button in OctoPrint status bar, the value in Serial port is reset to Auto and when the auto connect starts it fails, apparently because the previously configured Serial port is wiped and replaced with 'AUTO'.
When I enable 'Off on error' the printer is automatically switched off every time that it is switched on via the icon in the status bar, because of the auto connect failure.
I have tried several combinations of settings/options but none made any difference for this problem. Enabling 'save settings' for the connection and/or configuring serial port via OctoPrint settings did not make any difference.
The problem appears to be caused by the plugin. If not a bug in the plugin, what else may be causing this?