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