@@ -77,6 +77,28 @@ def connect_to_server(s, host, port):
77
77
78
78
class SocketCanDaemonBus (can .BusABC ):
79
79
def __init__ (self , channel , host , port , tcp_tune = False , can_filters = None , ** kwargs ):
80
+ """Connects to a CAN bus served by socketcand.
81
+
82
+ It will attempt to connect to the server for up to 10s, after which a
83
+ TimeoutError exception will be thrown.
84
+
85
+ If the handshake with the socketcand server fails, a CanError exception
86
+ is thrown.
87
+
88
+ :param channel:
89
+ The can interface name served by socketcand.
90
+ An example channel would be 'vcan0' or 'can0'.
91
+ :param host:
92
+ The host address of the socketcand server.
93
+ :param port:
94
+ The port of the socketcand server.
95
+ :param tcp_tune:
96
+ This tunes the TCP socket for low latency (TCP_NODELAY, and
97
+ TCP_QUICKACK).
98
+ This option is not available under windows.
99
+ :param can_filters:
100
+ See :meth:`can.BusABC.set_filters`.
101
+ """
80
102
self .__host = host
81
103
self .__port = port
82
104
@@ -197,9 +219,15 @@ def _expect_msg(self, msg):
197
219
raise can .CanError (f"{ msg } message expected!" )
198
220
199
221
def send (self , msg , timeout = None ):
222
+ """Transmit a message to the CAN bus.
223
+
224
+ :param msg: A message object.
225
+ :param timeout: Ignored
226
+ """
200
227
ascii_msg = convert_can_message_to_ascii_message (msg )
201
228
self ._tcp_send (ascii_msg )
202
229
203
230
def shutdown (self ):
231
+ """Stops all active periodic tasks and closes the socket."""
204
232
super ().shutdown ()
205
233
self .__socket .close ()
0 commit comments