1212
1313from __future__ import absolute_import
1414
15- import io
1615import time
1716import logging
1817
@@ -42,9 +41,10 @@ class slcanBus(BusABC):
4241 83300 : 'S9'
4342 }
4443
45- _SLEEP_AFTER_SERIAL_OPEN = 2 # in seconds
44+ _SLEEP_AFTER_SERIAL_OPEN = 2 # in seconds
4645
47- def __init__ (self , channel , ttyBaudrate = 115200 , timeout = 1 , bitrate = None , ** kwargs ):
46+ def __init__ (self , channel , ttyBaudrate = 115200 , timeout = 1 , bitrate = None ,
47+ rtscts = False , ** kwargs ):
4848 """
4949 :param str channel:
5050 port of underlying serial or usb device (e.g. /dev/ttyUSB0, COM8, ...)
@@ -57,16 +57,18 @@ def __init__(self, channel, ttyBaudrate=115200, timeout=1, bitrate=None, **kwarg
5757 Poll interval in seconds when reading messages
5858 :param float timeout:
5959 timeout in seconds when reading message
60+ :param bool rtscts:
61+ turn hardware handshake (RTS/CTS) on and off
6062 """
6163
62- if not channel : # if None or empty
64+ if not channel : # if None or empty
6365 raise TypeError ("Must specify a serial port." )
6466
6567 if '@' in channel :
6668 (channel , ttyBaudrate ) = channel .split ('@' )
6769
6870 self .serialPortOrig = serial .serial_for_url (
69- channel , baudrate = ttyBaudrate , timeout = timeout )
71+ channel , baudrate = ttyBaudrate , timeout = timeout , rtscts = rtscts )
7072
7173 time .sleep (self ._SLEEP_AFTER_SERIAL_OPEN )
7274
@@ -80,7 +82,7 @@ def __init__(self, channel, ttyBaudrate=115200, timeout=1, bitrate=None, **kwarg
8082 self .open ()
8183
8284 super (slcanBus , self ).__init__ (channel , ttyBaudrate = 115200 , timeout = 1 ,
83- bitrate = None , ** kwargs )
85+ bitrate = None , rtscts = False , ** kwargs )
8486
8587 def write (self , string ):
8688 if not string .endswith ('\r ' ):
@@ -104,7 +106,7 @@ def _recv_internal(self, timeout):
104106 frame = []
105107
106108 readStr = self .serialPortOrig .read_until (b'\r ' )
107-
109+
108110 if not readStr :
109111 return None , False
110112 else :
0 commit comments