Inappropriate IOCTL error when connecting to new Arduino Mega 2560 with new RAMPS 1.4a

What is the problem?
[Errno 25] Inappropriate ioctl for device' @ comm.py:_readline:2739 when trying to connect to a new Arduino/RAMPS.

What did you already try to solve it?
I don't even know what the error means, much less know what to do to try to fix it.

Additional information about your setup (OctoPrint version, OctoPi version, printer, firmware, what kind of hardware precisely, ...)
OctoPrint 1.3.11 running on OctoPi 0.15.1
Raspberry Pi 3B v1.2
KEYESTUDIO Mega 2560 R3
KEYESTUDIO 3D Printer Controller RAMPS 1.4a
Marlin 2.x, downloaded in July 2019.

Terminal output:

Changing monitoring state from "Offline" to "Detecting serial port"
Serial port list: ['/dev/ttyAMA0']
Connecting to: /dev/ttyAMA0
Changing monitoring state from "Detecting serial port" to "Opening serial port"
Connected to: Serial<id=0x65686db0, open=True>(port='/dev/ttyAMA0', baudrate=115200, bytesize=8, parity='N', stopbits=1, timeout=10.0, xonxoff=False, rtscts=False, dsrdtr=False), starting monitor
Changing monitoring state from "Opening serial port" to "Connecting"
Send: N0 M110 N0*125
Unexpected error while reading serial port, please consult octoprint.log for details: IOError: '[Errno 25] Inappropriate ioctl for device' @ comm.py:_readline:2739
Changing monitoring state from "Connecting" to "Offline (Error: IOError: '[Errno 25] Inappropriate ioctl for device' @ comm.py:_readline:2739)"
Connection closed, closing down monitor

octoprint.log:

2019-08-09 04:11:24,408 - octoprint.util.comm - INFO - Changing monitoring state from "Offline" to "Detecting serial port"
2019-08-09 04:11:24,445 - octoprint.util.comm - INFO - Changing monitoring state from "Detecting serial port" to "Opening serial port"
2019-08-09 04:11:24,449 - octoprint.util.comm - INFO - Changing monitoring state from "Opening serial port" to "Connecting"
2019-08-09 04:11:24,465 - octoprint.util.comm - INFO - M110 detected, setting current line number to 0
2019-08-09 04:11:24,465 - octoprint.util.comm - ERROR - Unexpected error while reading from serial port
Traceback (most recent call last):
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/util/comm.py", line 2739, in _readline
    ret = self._serial.readline()
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/util/comm.py", line 4828, in readline
    data += bytearray(self.read(self.in_waiting))
  File "/home/pi/oprint/local/lib/python2.7/site-packages/serial/serialposix.py", line 467, in in_waiting
    s = fcntl.ioctl(self.fd, TIOCINQ, TIOCM_zero_str)
IOError: [Errno 25] Inappropriate ioctl for device
2019-08-09 04:11:24,480 - octoprint.util.comm - INFO - Changing monitoring state from "Connecting" to "Offline (Error: IOError: '[Errno 25] Inappropriate ioctl for device' @ comm.py:_readline:2739)"

I had noticed with my original controller hardware that occasionally when homing my Y axis would move away from the endstop switch a few mm, instead of towards it. So I decided to replace the whole thing, Arduino, Ramps, and stepper drivers. I have everything plugged in the same way as the old Ramps, and flashed the same Marlin firmware with zero changes from the last time I used it. But after connecting it to the RasPi (same USB port as before, same cable), OctoPrint won't connect to the Ramps.

You might want to verify that your Marlin was configured for 115200. The error is likely a PySerial error, for what it's worth.