File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22Interface for Chinese Robotell compatible interfaces (win32/linux).
33"""
44
5+ import io
56import time
67import logging
78
@@ -367,10 +368,14 @@ 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 (
375+ "fileno is not implemented using current CAN bus on this platform"
376+ )
377+ except Exception as exception :
378+ raise CanOperationError ("Cannot fetch fileno" ) from exception
374379
375380 def get_serial_number (self , timeout ):
376381 """Get serial number of the slcan interface.
Original file line number Diff line number Diff line change @@ -940,6 +940,10 @@ def test_set_hw_filter(self):
940940 ),
941941 )
942942
943+ def test_when_no_fileno (self ):
944+ with self .assertRaises (NotImplementedError ):
945+ self .bus .fileno ()
946+
943947
944948if __name__ == "__main__" :
945949 unittest .main ()
You can’t perform that action at this time.
0 commit comments