Skip to content

Commit

Permalink
Merge pull request #474 from canton7/feature/custom-serial-write-err
Browse files Browse the repository at this point in the history
Handle poll-related errors, too
  • Loading branch information
canton7 authored Dec 14, 2023
2 parents 0f96261 + ed31d4f commit 752f31c
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,13 @@ def write(self, data: Any) -> int:
raise SerialTimeoutException("Write timeout")

result = _PollResult.TIMEOUT # In case poll returns an empty list
for fd, _event in poll.poll(None if timeout.is_infinite else (timeout.time_left() * 1000)):
for fd, event in poll.poll(None if timeout.is_infinite else (timeout.time_left() * 1000)):
if fd == self.pipe_abort_write_r:
os.read(self.pipe_abort_read_r, 1000)
result = _PollResult.ABORT
break
if event & (select.POLLERR | select.POLLHUP | select.POLLNVAL):
raise SerialException("device reports error (poll)")
result = _PollResult.READY

if result == _PollResult.TIMEOUT:
Expand Down

0 comments on commit 752f31c

Please sign in to comment.