File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ def __init__(
62
62
btr : Optional [str ] = None ,
63
63
sleep_after_open : float = _SLEEP_AFTER_SERIAL_OPEN ,
64
64
rtscts : bool = False ,
65
+ listen_only : bool = False ,
65
66
timeout : float = 0.001 ,
66
67
** kwargs : Any ,
67
68
) -> None :
@@ -81,12 +82,18 @@ def __init__(
81
82
Time to wait in seconds after opening serial connection
82
83
:param rtscts:
83
84
turn hardware handshake (RTS/CTS) on and off
85
+ :param listen_only:
86
+ If True, open interface/channel in listen mode with ``L`` command.
87
+ Otherwise, the (default) ``O`` command is still used. See ``open`` methode.
84
88
:param timeout:
85
89
Timeout for the serial or usb device in seconds (default 0.001)
90
+
86
91
:raise ValueError: if both ``bitrate`` and ``btr`` are set or the channel is invalid
87
92
:raise CanInterfaceNotImplementedError: if the serial module is missing
88
93
:raise CanInitializationError: if the underlying serial connection could not be established
89
94
"""
95
+ self .listen_only = listen_only
96
+
90
97
if serial is None :
91
98
raise CanInterfaceNotImplementedError ("The serial module is not installed" )
92
99
@@ -188,7 +195,10 @@ def flush(self) -> None:
188
195
self .serialPortOrig .reset_input_buffer ()
189
196
190
197
def open (self ) -> None :
191
- self ._write ("O" )
198
+ if self .listen_only :
199
+ self ._write ("L" )
200
+ else :
201
+ self ._write ("O" )
192
202
193
203
def close (self ) -> None :
194
204
self ._write ("C" )
You can’t perform that action at this time.
0 commit comments