OSError: [Errno 25] Inappropriate ioctl for device

Changed from Pi zero W to pi4b external

What did you already try to solve it?
Checked my wiring for tx and rx, Also tried restoring from backup, enabled logging for connection

Logs (syslog, dmesg, ... no logs, no support)
Serial log : 2021-10-19 13:51:33,075 - serial.log is currently not enabled, you can enable it via Settings > Serial Connection > Log communication to serial.log

2021-10-19 13:52:42,883 - serial.log is currently not enabled, you can enable it via Settings > Serial Connection > Log communication to serial.log
2021-10-19 13:54:54,971 - Enabling serial logging
2021-10-19 13:54:57,830 - Changing monitoring state from "Offline" to "Opening serial connection"
2021-10-19 13:54:57,832 - Connecting to port /dev/ttyAMA0, baudrate 115200
2021-10-19 13:54:57,853 - Changing monitoring state from "Opening serial connection" to "Connecting"
2021-10-19 13:54:57,855 - Connected to: Serial<id=0xa3b03210, open=True>(port='/dev/ttyAMA0', baudrate=115200, bytesize=8, parity='N', stopbits=1, timeout=10.0, xonxoff=False, rtscts=False, dsrdtr=False), starting monitor
2021-10-19 13:54:57,858 - Send: N0 M110 N0*125
2021-10-19 13:54:57,898 - Unexpected error while reading serial port, please consult octoprint.log for details: OSError: '[Errno 25] Inappropriate ioctl for device' @ comm.py:_readline:3940
2021-10-19 13:54:57,900 - Changing monitoring state from "Connecting" to "Offline after error"
2021-10-19 13:54:57,901 - Connection closed, closing down monitor

Octoprint log:
2021-10-19 13:52:39,661 - octoprint.plugins.errortracking - INFO - Initialized error tracking
2021-10-19 13:52:42,906 - octoprint.util.comm - INFO - Changing monitoring state from "Offline" to "Opening serial connection"
2021-10-19 13:52:42,909 - octoprint.util.comm - INFO - Connecting to port /dev/ttyAMA0, baudrate 115200
2021-10-19 13:52:42,941 - octoprint.util.comm - INFO - Changing monitoring state from "Opening serial connection" to "Connecting"
2021-10-19 13:52:42,944 - 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 3940, in _readline
    ret = self._serial.readline()
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint/util/comm.py", line 6592, in readline
    self._buffered += self.read(self.in_waiting)
  File "/home/pi/oprint/lib/python3.7/site-packages/serial/serialposix.py", line 549, in in_waiting
    s = fcntl.ioctl(self.fd, TIOCINQ, TIOCM_zero_str)
OSError: [Errno 25] Inappropriate ioctl for device
2021-10-19 13:52:42,950 - octoprint.util.comm - INFO - M110 detected, setting current line number to 0
2021-10-19 13:52:42,979 - octoprint.util.comm - INFO - Changing monitoring state from "Connecting" to "Offline after error"
2021-10-19 13:52:42,985 - octoprint.plugins.action_command_notification - INFO - Notifications cleared
2021-10-19 13:54:57,830 - octoprint.util.comm - INFO - Changing monitoring state from "Offline" to "Opening serial connection"
2021-10-19 13:54:57,832 - octoprint.util.comm - INFO - Connecting to port /dev/ttyAMA0, baudrate 115200
2021-10-19 13:54:57,854 - octoprint.util.comm - INFO - Changing monitoring state from "Opening serial connection" to "Connecting"
2021-10-19 13:54:57,856 - 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 3940, in _readline
    ret = self._serial.readline()
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint/util/comm.py", line 6592, in readline
    self._buffered += self.read(self.in_waiting)
  File "/home/pi/oprint/lib/python3.7/site-packages/serial/serialposix.py", line 549, in in_waiting
    s = fcntl.ioctl(self.fd, TIOCINQ, TIOCM_zero_str)
OSError: [Errno 25] Inappropriate ioctl for device
2021-10-19 13:54:57,858 - octoprint.util.comm - INFO - M110 detected, setting current line number to 0
2021-10-19 13:54:57,900 - octoprint.util.comm - INFO - Changing monitoring state from "Connecting" to "Offline after error"
2021-10-19 13:54:57,906 - octoprint.plugins.action_command_notification - INFO - Notifications cleared

Additional information about your network (Hardware you are trying to connect to, hardware you are trying to connect from, router, access point, used operating systems, ...)
The weird thing is that I can see the camera streaming clearly, however i cant communicate witht he printer itself.....

Did you enable the UART in the config.txt?

I guess you want to use the pl011 UART (which disables bluetooth but is more reliable) and not the mini UART

put dtoverlay=disable-bt at the end of your config.txt

1 Like

I verified and added the coding. now i get the following
Changing monitoring state from "Offline" to "Opening serial connection"
Connecting to port /dev/ttyAMA0, baudrate 115200
Changing monitoring state from "Opening serial connection" to "Error"
Changing monitoring state from "Error" to "Offline after error"
Unexpected error while connecting to serial port /dev/ttyAMA0, baudrate 115200 from hook default: SerialException: '[Errno 13] could not open port /dev/ttyAMA0: [Errno 13] Permission denied: '/dev/ttyAMA0'' @ comm.py:_open_serial:3779

Ok the solution was two part. first added the line suggested by @PrintedWeezl dtoverlay=disable-bt at the end of the config.txt file.
then used putty to connect to the pi, did sudo raspi-config and followed the instructions given by @OutsourcedGuru " just go into sudo raspi-config , go to Interfaces -> Serial and answer "no", "yes" to the next two prompts." then clicked finish rebooted and it works :slight_smile: