@@ -31,7 +31,11 @@ class BusABC(metaclass=ABCMeta):
3131 """The CAN Bus Abstract Base Class that serves as the basis
3232 for all concrete interfaces.
3333
34- This class may be used as an iterator over the received messages.
34+ This class may be used as an iterator over the received messages
35+ and as a context manager for auto-closing the bus when done using it.
36+
37+ Please refer to :ref:`errors` for possible exceptions that may be
38+ thrown by certain operations on this bus.
3539 """
3640
3741 #: a string describing the underlying bus and/or channel
@@ -60,6 +64,10 @@ def __init__(
6064
6165 :param dict kwargs:
6266 Any backend dependent configurations are passed in this dictionary
67+
68+ :raises ValueError: If parameters are out of range
69+ :raises can.CanInterfaceNotImplementedError: If the driver cannot be accessed
70+ :raises can.CanInitializationError: If the bus cannot be initialized
6371 """
6472 self ._periodic_tasks : List [_SelfRemovingCyclicTask ] = []
6573 self .set_filters (can_filters )
@@ -73,10 +81,9 @@ def recv(self, timeout: Optional[float] = None) -> Optional[Message]:
7381 :param timeout:
7482 seconds to wait for a message or None to wait indefinitely
7583
76- :return:
77- None on timeout or a :class:`Message` object.
78- :raises can.CanError:
79- if an error occurred while reading
84+ :return: ``None`` on timeout or a :class:`Message` object.
85+
86+ :raises can.CanOperationError: If an error occurred while reading
8087 """
8188 start = time ()
8289 time_left = timeout
@@ -141,8 +148,7 @@ def _recv_internal(
141148 2. a bool that is True if message filtering has already
142149 been done and else False
143150
144- :raises can.CanError:
145- if an error occurred while reading
151+ :raises can.CanOperationError: If an error occurred while reading
146152 :raises NotImplementedError:
147153 if the bus provides it's own :meth:`~can.BusABC.recv`
148154 implementation (legacy implementation)
@@ -165,8 +171,7 @@ def send(self, msg: Message, timeout: Optional[float] = None) -> None:
165171 Might not be supported by all interfaces.
166172 None blocks indefinitely.
167173
168- :raises can.CanError:
169- if the message could not be sent
174+ :raises can.CanOperationError: If an error occurred while sending
170175 """
171176 raise NotImplementedError ("Trying to write to a readonly bus?" )
172177
@@ -323,7 +328,7 @@ def filters(self) -> Optional[can.typechecking.CanFilters]:
323328 return self ._filters
324329
325330 @filters .setter
326- def filters (self , filters : Optional [can .typechecking .CanFilters ]):
331+ def filters (self , filters : Optional [can .typechecking .CanFilters ]) -> None :
327332 self .set_filters (filters )
328333
329334 def set_filters (
@@ -336,7 +341,7 @@ def set_filters(
336341 messages are matched.
337342
338343 Calling without passing any filters will reset the applied
339- filters to `None`.
344+ filters to `` None` `.
340345
341346 :param filters:
342347 A iterable of dictionaries each containing a "can_id",
@@ -421,7 +426,7 @@ def state(self) -> BusState:
421426 return BusState .ACTIVE
422427
423428 @state .setter
424- def state (self , new_state : BusState ):
429+ def state (self , new_state : BusState ) -> None :
425430 """
426431 Set the new state of the hardware
427432 """
0 commit comments