7
7
import usb
8
8
import logging
9
9
10
+ from ..exceptions import CanInitializationError , CanOperationError
11
+
10
12
11
13
logger = logging .getLogger (__name__ )
12
14
@@ -22,7 +24,7 @@ def __init__(self, channel, bus, address, bitrate, can_filters=None, **kwargs):
22
24
"""
23
25
gs_usb = GsUsb .find (bus = bus , address = address )
24
26
if not gs_usb :
25
- raise can . CanError ( "Can not find device {}" . format ( channel ) )
27
+ raise CanInitializationError ( f"Cannot find device { channel } " )
26
28
self .gs_usb = gs_usb
27
29
self .channel_info = channel
28
30
@@ -38,7 +40,7 @@ def send(self, msg: can.Message, timeout: Optional[float] = None):
38
40
:param timeout: timeout is not supported.
39
41
The function won't return until message is sent or exception is raised.
40
42
41
- :raises can.CanError :
43
+ :raises CanOperationError :
42
44
if the message could not be sent
43
45
"""
44
46
can_id = msg .arbitration_id
@@ -64,7 +66,7 @@ def send(self, msg: can.Message, timeout: Optional[float] = None):
64
66
try :
65
67
self .gs_usb .send (frame )
66
68
except usb .core .USBError :
67
- raise can . CanError ("The message can not be sent" )
69
+ raise CanOperationError ("The message could not be sent" )
68
70
69
71
def _recv_internal (
70
72
self , timeout : Optional [float ]
@@ -76,6 +78,8 @@ def _recv_internal(
76
78
:meth:`~can.BusABC.set_filters` do not match and the call has
77
79
not yet timed out.
78
80
81
+ Never raises an error/exception.
82
+
79
83
:param float timeout: seconds to wait for a message,
80
84
see :meth:`~can.BusABC.send`
81
85
0 and None will be converted to minimum value 1ms.
@@ -85,9 +89,6 @@ def _recv_internal(
85
89
2. a bool that is True if message filtering has already
86
90
been done and else False. In this interface it is always False
87
91
since filtering is not available
88
-
89
- :raises can.CanError:
90
- if an error occurred while reading
91
92
"""
92
93
frame = GsUsbFrame ()
93
94
@@ -111,8 +112,4 @@ def _recv_internal(
111
112
return msg , False
112
113
113
114
def shutdown (self ):
114
- """
115
- Called to carry out any interface specific cleanup required
116
- in shutting down a bus.
117
- """
118
115
self .gs_usb .stop ()
0 commit comments