File tree 2 files changed +12
-3
lines changed
2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 2
2
Interface for Chinese Robotell compatible interfaces (win32/linux).
3
3
"""
4
4
5
+ import io
5
6
import time
6
7
import logging
7
8
@@ -367,10 +368,14 @@ def shutdown(self):
367
368
self .serialPortOrig .close ()
368
369
369
370
def fileno (self ):
370
- if hasattr ( self . serialPortOrig , "fileno" ) :
371
+ try :
371
372
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
374
379
375
380
def get_serial_number (self , timeout ):
376
381
"""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):
940
940
),
941
941
)
942
942
943
+ def test_when_no_fileno (self ):
944
+ with self .assertRaises (NotImplementedError ):
945
+ self .bus .fileno ()
946
+
943
947
944
948
if __name__ == "__main__" :
945
949
unittest .main ()
You can’t perform that action at this time.
0 commit comments