Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions serialx/platforms/serial_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ def _after_configure_port(self) -> None:
except OSError as exc:
if exc.errno in (errno.ENOTTY, errno.EOPNOTSUPP):
LOGGER.debug("Device does not support setting low latency")
elif exc.errno == errno.EPERM:
LOGGER.debug("User does not have permission to set low latency")
else:
raise

Expand Down
12 changes: 10 additions & 2 deletions tests/test_serial_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,23 @@ def test_set_non_posix_baudrate_zero_speed_raises() -> None:
assert captured == []


@pytest.mark.parametrize(
"err",
[
OSError(errno.EOPNOTSUPP, "Not supported"),
OSError(errno.ENOTTY, "Inappropriate ioctl for device"),
OSError(errno.EPERM, "Operation not permitted"),
],
)
@patch("serialx.platforms.serial_linux.TIOCGSERIAL", TIOCGSERIAL)
@patch("serialx.platforms.serial_linux.TIOCSSERIAL", TIOCSSERIAL)
def test_tiocgserial_ioctl_not_supported() -> None:
def test_tiocgserial_ioctl_not_supported(err: OSError) -> None:
"""Test that TIOCGSERIAL ioctl not supported is handled gracefully."""
ioctl_orig = fcntl.ioctl

def ioctl(fd: int, request: int, arg: Any = 0, mutate_flag: bool = True) -> Any:
if request in (TIOCGSERIAL, TIOCSSERIAL):
raise OSError(errno.EOPNOTSUPP, "Not supported")
raise err

return ioctl_orig(fd, request, arg, mutate_flag)

Expand Down
Loading