Skip to content

Commit 6834cda

Browse files
committed
Fix fileno error on Windows (robotell bus)
1 parent 796b525 commit 6834cda

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

can/interfaces/robotell.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Interface for Chinese Robotell compatible interfaces (win32/linux).
33
"""
44

5+
import io
56
import time
67
import logging
78

@@ -367,10 +368,12 @@ def shutdown(self):
367368
self.serialPortOrig.close()
368369

369370
def fileno(self):
370-
if hasattr(self.serialPortOrig, "fileno"):
371+
try:
371372
return self.serialPortOrig.fileno()
372-
# Return an invalid file descriptor on Windows
373-
return -1
373+
except io.UnsupportedOperation:
374+
raise NotImplementedError("fileno is not implemented using current CAN bus on this platform")
375+
except Exception as exception:
376+
raise CanOperationError("Cannot fetch fileno") from exception
374377

375378
def get_serial_number(self, timeout):
376379
"""Get serial number of the slcan interface.

0 commit comments

Comments
 (0)