@@ -50,7 +50,7 @@ class slcanBus(BusABC):
5050 LINE_TERMINATOR = b'\r '
5151
5252 def __init__ (self , channel , ttyBaudrate = 115200 , bitrate = None ,
53- sleep_after_open = _SLEEP_AFTER_SERIAL_OPEN ,
53+ btr = None , sleep_after_open = _SLEEP_AFTER_SERIAL_OPEN ,
5454 rtscts = False , ** kwargs ):
5555 """
5656 :param str channel:
@@ -60,6 +60,8 @@ def __init__(self, channel, ttyBaudrate=115200, bitrate=None,
6060 baudrate of underlying serial or usb device
6161 :param int bitrate:
6262 Bitrate in bit/s
63+ :param str btr:
64+ BTR register value to set custom can speed (overrides bitrate)
6365 :param float poll_interval:
6466 Poll interval in seconds when reading messages
6567 :param float sleep_after_open:
@@ -81,13 +83,20 @@ def __init__(self, channel, ttyBaudrate=115200, bitrate=None,
8183
8284 time .sleep (sleep_after_open )
8385
86+ if bitrate is not None and btr is not None :
87+ raise ValueError ("Bitrate and btr mutually exclusive." )
88+
8489 if bitrate is not None :
8590 self .close ()
8691 if bitrate in self ._BITRATES :
8792 self .write (self ._BITRATES [bitrate ])
8893 else :
8994 raise ValueError ("Invalid bitrate, choose one of " + (', ' .join (self ._BITRATES )) + '.' )
9095
96+ if btr is not None :
97+ self .close ()
98+ self .write ("s" + btr )
99+
91100 self .open ()
92101
93102 super (slcanBus , self ).__init__ (channel , ttyBaudrate = 115200 ,
0 commit comments