Raspberry Pi 3 Control over direct serial ttyS0 errors out


#1

What is the problem?
I'm tying to set up control for two of my printers over the UART pins on the Raspberry Pi 3 and having some errors.

Connecting to: /dev/ttyS0
Changing monitoring state from 'Offline' to 'Error: Connection error, see Terminal tab'
Unexpected error while connecting to serial port: /dev/ttyS0 error: '(22, 'Invalid argument')' @ comm.py:_openSerial:1931 (hook default)
Connection closed, closing down monitor

What did you already try to solve it?
Inintially I was trying to connect via ttyAMA0 (which is no longer allocated to the UART pins 14/15)

I also needed to set proper permissions on the correct tty (ttyS0) which is no longer giving a permissions error, however now it's showing the above error.

I tried switching between baud rates (uploading different settings to the firmware and changing octoprint settings), 115200. 230400, 250000.

Additional information about your setup (OctoPrint version, OctoPi version, printer, firmware, octoprint.log, serial.log or output on terminal tab, ...)

Testing on two boards: Ramps 1.6 (SMD version of RAMPS 1.4), and MKS Gen L 1.0

Firmware: Marlin 1.1.8

Octopi 0.14.0
OctoPrint 1.3.6

error: (22, 'Invalid argument')
2018-03-20 21:24:03,575 - octoprint.plugins.filamentreload - INFO - Error: Disabling filament sensor.
2018-03-20 21:24:03,578 - octoprint.plugin - ERROR - Error while calling plugin filamentreload
Traceback (most recent call last):
  File "/home/pi/oprint/local/lib/python2.7/site-packages/OctoPrint-1.3.6-py2.7.egg/octoprint/plugin/__init__.py", line 225, in call_plugin
    result = getattr(plugin, method)(*args, **kwargs)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint_filamentreload/__init__.py", line 113, in on_event
    GPIO.remove_event_detect(self.pin)
RuntimeError: Please set pin numbering mode using GPIO.setmode(GPIO.BOARD) or GPIO.setmode(GPIO.BCM)
2018-03-20 21:24:06,662 - octoprint.util.comm - INFO - M110 detected, setting current line number to 0
2018-03-20 21:24:10,531 - octoprint.util.comm - INFO - M110 detected, setting current line number to 0
2018-03-20 21:24:15,454 - octoprint.util.comm - ERROR - Unexpected error while connecting to serial port: /dev/ttyS0 error: '(22, 'Invalid argument')' @ comm.py:_openSerial:1931 (hook default)
Traceback (most recent call last):
  File "/home/pi/oprint/local/lib/python2.7/site-packages/OctoPrint-1.3.6-py2.7.egg/octoprint/util/comm.py", line 1931, in _openSerial
    serial_obj = factory(self, self._port, self._baudrate, settings().getFloat(["serial", "timeout", "connection"]))
  File "/home/pi/oprint/local/lib/python2.7/site-packages/OctoPrint-1.3.6-py2.7.egg/octoprint/util/comm.py", line 1921, in default
    serial_obj = serial.Serial(str(port), baudrate, timeout=read_timeout, writeTimeout=10000, parity=serial.PARITY_ODD)
  File "build/bdist.linux-armv7l/egg/serial/serialutil.py", line 282, in __init__
    self.open()
  File "build/bdist.linux-armv7l/egg/serial/serialposix.py", line 296, in open
    self._reconfigurePort()
  File "build/bdist.linux-armv7l/egg/serial/serialposix.py", line 427, in _reconfigurePort
    termios.tcsetattr(self.fd, TERMIOS.TCSANOW, [iflag, oflag, cflag, lflag, ispeed, ospeed, cc])
error: (22, 'Invalid argument')
2018-03-20 21:24:15,763 - octoprint.plugins.filamentreload - INFO - Error: Disabling filament sensor.
2018-03-20 21:24:15,765 - octoprint.plugin - ERROR - Error while calling plugin filamentreload
Traceback (most recent call last):
  File "/home/pi/oprint/local/lib/python2.7/site-packages/OctoPrint-1.3.6-py2.7.egg/octoprint/plugin/__init__.py", line 225, in call_plugin
    result = getattr(plugin, method)(*args, **kwargs)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint_filamentreload/__init__.py", line 113, in on_event
    GPIO.remove_event_detect(self.pin)
RuntimeError: Please set pin numbering mode using GPIO.setmode(GPIO.BOARD) or GPIO.setmode(GPIO.BCM)

#2

I got some advice on reddit to disable the uart connection to onboard bluetooth for the Pi3 so that pins14/15 will again be assigned to ttyAMA0, which solved the invalid argument issue, but I'm still not able to connect to any of the atmega2560 based board I have over direct serial. Looks like I'll have to take this over to the Marlin team