Cannot connect to autodetected serial port

Hello

What is the problem?
I have a problem with connecting my printer to octoprint. When my printer is power ON, I can see in raspberry terminal with dmesg that the printer is using the serial port /dev/ttyACM0.

When I click on Connect button in Octoprint, the connection is not established. Here is a Serial log.

2020-03-17 18:04:03,906 - Changing monitoring state from "Offline" to "Detecting serial port"
2020-03-17 18:04:03,976 - Serial port list: [u'/dev/ttyACM0', u'/dev/ttyS0']
2020-03-17 18:04:03,977 - Trying /dev/ttyACM0
2020-03-17 18:04:09,362 - Could not connect to or enter programming mode on /dev/ttyACM0, might not be a printer or just not allow programming mode
2020-03-17 18:04:09,376 - Trying /dev/ttyS0
2020-03-17 18:04:14,710 - Could not connect to or enter programming mode on /dev/ttyS0, might not be a printer or just not allow programming mode
2020-03-17 18:04:14,727 - Changing monitoring state from "Detecting serial port" to "Error: Failed to autodetect serial port, please set it manually."
2020-03-17 18:04:14,736 - Failed to autodetect serial port, please set it manually.

When I click on Refresh connection options, and after that I choose the port and click on Connect, it works,

2020-03-17 18:04:45,055 - Connecting to: /dev/ttyACM0
2020-03-17 18:04:45,073 - Changing monitoring state from "Offline" to "Opening serial port"
2020-03-17 18:04:45,077 - Connected to: Serial<id=0x6a863c50, open=True>(port='/dev/ttyACM0', baudrate=115200, bytesize=8, parity='N', stopbits=1, timeout=10.0, xonxoff=False, rtscts=False, dsrdtr=False), starting monitor
2020-03-17 18:04:45,078 - Changing monitoring state from "Opening serial port" to "Connecting"

I tried many options, Run octoprint in safe mode, put the serial port into Additional serial ports in settings.
It worked well before, but after some update it is not working anymore.

Do you have any suggestion how to solve this problem?

Regards
dbarvik

Hello @dbarvik !

Already tried this?:

Not only the port (/dev/ttyACM0 seems somehow to work), but also the baudrate.
Also would be nice to know what printer you are using. And the serial.log would be quite handy too.

I had the same ever since I updated to Octoprint 1.40
My work around was to define SYMLINK to the printers serial number of the USB.
SSH into the pi.
Make sure your printer is connected:

ls /dev/ttyUSB

or

ls /dev/ttyACM

List specific information about connected devices:

sudo lsusb -v | grep 'idVendor|idProduct|iProduct|iSerial'`

Read through the output you should be able to determine you device by understanding what is connected to your pi.
Mine showed 2x USB hubs, a root hub controller and an FTDI FT232 serial IC.

The printer is the FTDI chip in my case.

idVendor 0x0403 Future Technology Devices International, Ltd
idProduct 0x6001 FT232 Serial (UART) IC
iProduct 2 FT232R USB UART
iSerial 3 B804S3NC

I then edited the usb-serial.rules file:

sudo nano /etc/udev/rules.d/99-usb-serial.rules

Adding something like this harvesting the information into the fields from the previous generated list:

#PRINTER NAME
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="B804S3NC", SYMLINK+="ttyUSB-PORTNAME"

PRINTER NAME and PORTNAME can be whatever you want.

Then in my octoprint interface the connection tab, then the serial dropdown box I select the name I gave the port and save that as default.

If I click on refresh button and select the port manualy, it connects. My printer is ENDER-3,

Here is the serial log

2020-03-17 18:17:50,843 - Changing monitoring state from "Offline" to "Detecting serial port"
2020-03-17 18:17:50,874 - Serial port list: [u'/dev/ttyACM0', u'/dev/ttyS0']
2020-03-17 18:17:50,875 - Trying /dev/ttyACM0
2020-03-17 18:17:56,186 - Could not connect to or enter programming mode on /dev/ttyACM0, might not be a printer or just not allow programming mode
2020-03-17 18:17:56,207 - Trying /dev/ttyS0
2020-03-17 18:18:01,540 - Could not connect to or enter programming mode on /dev/ttyS0, might not be a printer or just not allow programming mode
2020-03-17 18:18:01,560 - Changing monitoring state from "Detecting serial port" to "Error: Failed to autodetect serial port, please set it manually."
2020-03-17 18:18:01,594 - Failed to autodetect serial port, please set it manually.
2020-03-17 18:18:18,810 - Changing monitoring state from "Offline" to "Detecting serial port"
2020-03-17 18:18:18,871 - Serial port list: [u'/dev/ttyACM0', u'/dev/ttyS0']
2020-03-17 18:18:18,872 - Trying /dev/ttyACM0
2020-03-17 18:18:24,209 - Could not connect to or enter programming mode on /dev/ttyACM0, might not be a printer or just not allow programming mode
2020-03-17 18:18:24,228 - Trying /dev/ttyS0
2020-03-17 18:18:29,560 - Could not connect to or enter programming mode on /dev/ttyS0, might not be a printer or just not allow programming mode
2020-03-17 18:18:29,581 - Changing monitoring state from "Detecting serial port" to "Error: Failed to autodetect serial port, please set it manually."
2020-03-17 18:18:29,592 - Failed to autodetect serial port, please set it manually.
2020-03-17 18:18:33,372 - Changing monitoring state from "Offline" to "Detecting serial port"
2020-03-17 18:18:33,490 - Serial port list: [u'/dev/ttyACM0', u'/dev/ttyS0']
2020-03-17 18:18:33,491 - Trying /dev/ttyACM0
2020-03-17 18:18:38,810 - Could not connect to or enter programming mode on /dev/ttyACM0, might not be a printer or just not allow programming mode
2020-03-17 18:18:38,829 - Trying /dev/ttyS0
2020-03-17 18:18:44,170 - Could not connect to or enter programming mode on /dev/ttyS0, might not be a printer or just not allow programming mode
2020-03-17 18:18:44,191 - Changing monitoring state from "Detecting serial port" to "Error: Failed to autodetect serial port, please set it manually."
2020-03-17 18:18:44,201 - Failed to autodetect serial port, please set it manually.
2020-03-17 18:18:54,191 - Changing monitoring state from "Offline" to "Detecting serial port"
2020-03-17 18:18:54,305 - Serial port list: [u'/dev/ttyACM0', u'/dev/ttyS0']
2020-03-17 18:18:54,308 - Trying /dev/ttyACM0
2020-03-17 18:18:59,661 - Could not connect to or enter programming mode on /dev/ttyACM0, might not be a printer or just not allow programming mode
2020-03-17 18:18:59,667 - Trying /dev/ttyS0
2020-03-17 18:19:05,011 - Could not connect to or enter programming mode on /dev/ttyS0, might not be a printer or just not allow programming mode
2020-03-17 18:19:05,029 - Changing monitoring state from "Detecting serial port" to "Error: Failed to autodetect serial port, please set it manually."
2020-03-17 18:19:05,044 - Failed to autodetect serial port, please set it manually.
2020-03-17 18:19:10,731 - Connecting to: /dev/ttyACM0
2020-03-17 18:19:10,752 - Changing monitoring state from "Offline" to "Opening serial port"
2020-03-17 18:19:10,759 - Connected to: Serial<id=0x704a9490, open=True>(port='/dev/ttyACM0', baudrate=115200, bytesize=8, parity='N', stopbits=1, timeout=10.0, xonxoff=False, rtscts=False, dsrdtr=False), starting monitor
2020-03-17 18:19:10,760 - Changing monitoring state from "Opening serial port" to "Connecting"
2020-03-17 18:19:10,772 - Send: N0 M110 N0*125
2020-03-17 18:19:10,782 - Send: N0 M110 N0*125
2020-03-17 18:19:10,785 - Recv: echo:Unknown command: "e"
2020-03-17 18:19:10,797 - Recv: ok
2020-03-17 18:19:10,807 - Changing monitoring state from "Connecting" to "Operational"
2020-03-17 18:19:10,823 - Send: N0 M110 N0*125
2020-03-17 18:19:10,830 - Recv: ok
2020-03-17 18:19:10,836 - Send: N1 M115*39
2020-03-17 18:19:10,837 - Recv: ok
2020-03-17 18:19:10,841 - Recv: FIRMWARE_NAME:Marlin bugfix-2.0.x (GitHub) SOURCE_CODE_URL:https://github.com/MarlinFirmware/Marlin PROTOCOL_VERSION:1.0 MACHINE_TYPE:Ender-3 EXTRUDER_COUNT:1 UUID:cede2a2f-41a2-4748-9b12-c55c62f367ff
2020-03-17 18:19:10,848 - Recv: Cap:SERIAL_XON_XOFF:0
2020-03-17 18:19:10,850 - Send: M21
2020-03-17 18:19:10,852 - Recv: Cap:BINARY_FILE_TRANSFER:0
2020-03-17 18:19:10,861 - Recv: Cap:EEPROM:1
2020-03-17 18:19:10,865 - Recv: Cap:VOLUMETRIC:1
2020-03-17 18:19:10,874 - Recv: Cap:AUTOREPORT_TEMP:1
2020-03-17 18:19:10,883 - Recv: Cap:PROGRESS:0
2020-03-17 18:19:10,885 - Recv: Cap:PRINT_JOB:1
2020-03-17 18:19:10,888 - Recv: Cap:AUTOLEVEL:1
2020-03-17 18:19:10,890 - Recv: Cap:Z_PROBE:1
2020-03-17 18:19:10,894 - Recv: Cap:LEVELING_DATA:1
2020-03-17 18:19:10,896 - Recv: Cap:BUILD_PERCENT:0
2020-03-17 18:19:10,898 - Recv: Cap:SOFTWARE_POWER:0
2020-03-17 18:19:10,900 - Recv: Cap:TOGGLE_LIGHTS:0
2020-03-17 18:19:10,903 - Recv: Cap:CASE_LIGHT_BRIGHTNESS:0
2020-03-17 18:19:10,905 - Recv: Cap:EMERGENCY_PARSER:0
2020-03-17 18:19:10,908 - Recv: Cap:PROMPT_SUPPORT:0
2020-03-17 18:19:10,911 - Recv: Cap:AUTOREPORT_SD_STATUS:0
2020-03-17 18:19:10,915 - Recv: Cap:THERMAL_PROTECTION:1
2020-03-17 18:19:10,918 - Recv: Cap:MOTION_MODES:0
2020-03-17 18:19:10,920 - Recv: Cap:CHAMBER_TEMPERATURE:0
2020-03-17 18:19:10,923 - Recv: ok
2020-03-17 18:19:10,925 - Recv: echo:SD card ok
2020-03-17 18:19:10,929 - Recv: ok
2020-03-17 18:19:10,933 - Send: M117 IP 192.168.1.112
2020-03-17 18:19:10,936 - Recv: ok
2020-03-17 18:19:10,940 - Send: M155 S2
2020-03-17 18:19:10,943 - Recv: ok
2020-03-17 18:19:10,947 - Send: M20
2020-03-17 18:19:10,949 - Recv: Begin file list
2020-03-17 18:19:10,952 - Recv: End file list
2020-03-17 18:19:10,956 - Recv: ok
2020-03-17 18:19:12,913 - Send: M115
2020-03-17 18:19:12,920 - Recv: FIRMWARE_NAME:Marlin bugfix-2.0.x (GitHub) SOURCE_CODE_URL:https://github.com/MarlinFirmware/Marlin PROTOCOL_VERSION:1.0 MACHINE_TYPE:Ender-3 EXTRUDER_COUNT:1 UUID:cede2a2f-41a2-4748-9b12-c55c62f367ff
2020-03-17 18:19:12,925 - Recv: Cap:SERIAL_XON_XOFF:0
2020-03-17 18:19:12,934 - Recv: Cap:BINARY_FILE_TRANSFER:0
2020-03-17 18:19:12,940 - Recv: Cap:RCENT:0
2020-03-17 18:19:12,957 - Recv: Cap:SOFTWARE_POWER:0
2020-03-17 18:19:12,966 - Recv: Cap:TOGGLE_LIGHTS:0
2020-03-17 18:19:12,984 - Recv: Cap:CASE_LIGHT_BRIGHTNESS:0
2020-03-17 18:19:12,987 - Recv: Cap:EMERGENCY_PARSER:0
2020-03-17 18:19:12,990 - Recv: Cap:PROMPT_SUPPORT:0
2020-03-17 18:19:12,995 - Recv: Cap:AUTOREPORT_SD_STATUS:0
2020-03-17 18:19:12,999 - Recv: Cap:THERMAL_PROTECTION:1
2020-03-17 18:19:13,003 - Recv: Cap:MOTION_MODES:0
2020-03-17 18:19:13,007 - Recv: Cap:CHAMBER_TEMPERATURE:0
2020-03-17 18:19:13,010 - Recv: ok
2020-03-17 18:19:13,013 - Recv:  T:20.62 /0.00 B:20.62 /0.00 @:0 B@:0
2020-03-17 18:19:13,014 - Send: M504
2020-03-17 18:19:13,022 - Recv: echo:EEPROM OK
2020-03-17 18:19:13,025 - Recv: ok

2020-03-17 18:26:26,788 - Connection closed, closing down monitor
2020-03-17 18:26:26,816 - Changing monitoring state from "Operational" to "Offline"
2020-03-18 07:35:57,379 - Changing monitoring state from "Offline" to "Detecting serial port"
2020-03-18 07:35:57,412 - Serial port list: [u'/dev/ttyACM0', u'/dev/ttyS0']
2020-03-18 07:35:57,413 - Trying /dev/ttyACM0
2020-03-18 07:36:02,724 - Could not connect to or enter programming mode on /dev/ttyACM0, might not be a printer or just not allow programming mode
2020-03-18 07:36:02,744 - Trying /dev/ttyS0
2020-03-18 07:36:08,080 - Could not connect to or enter programming mode on /dev/ttyS0, might not be a printer or just not allow programming mode
2020-03-18 07:36:08,095 - Changing monitoring state from "Detecting serial port" to "Error: Failed to autodetect serial port, please set it manually."
2020-03-18 07:36:08,110 - Failed to autodetect serial port, please set it manually.

Thank you for answer,

If I set the port manualy and disconnect the printer, the port changes to AUTO, a on power on my printer, I always need to click on refresh, and select the port.

Take a look at the port lister plugin.

I installed the PortLister plugin, but I need to choose the right port. Now I don't need to click on refresh button only.

But the situation is so weird for me, octoprint autodetect can see the port where the printer is connected, but it cannot connect to it, when I choose manualy the same port as autodetected, printer connects...

Thank you all for answers.

That's because autodetect tries to acertain that it is actually a printer its talking to, and the way it currently does that doesn't work for a significant number of printers out there, your's being one of them. If OctoPrint gets a port from you to connect to it trusts that you know that that is in fact a printer and can just happily connect. The same happens btw if OctoPrint only sees one single port, which due to an addition to the port pattern it no longer does on some machines out there (and I still haven't figured out the reason for that, I cannot reproduce it locally).

I have the same exact issue on my Ender 3 Pro w/ EZBoard Lite. Started when I updated to 1.4

@mungbean 's first two commands do not work "no such file or directory". The third, even with the extra ` at the end removed doesn't list anything even though my printer is connected.

I have to power on with PSU Control, refresh serial connections, select /dev/ttyACM0, and then click 'Connect'. I save those settings and it switches back to Auto when I disconnect. Save connection settings has never saved the serial port for me since I started using OctoPrint.