Skip to content

Commit

Permalink
Merge pull request #1 from khssnv/master
Browse files Browse the repository at this point in the history
Allow user to set (RTS/CTS) and (DSR/DTR) flows control
  • Loading branch information
devegied committed May 3, 2019
2 parents c7a476b + bb3bc05 commit fe890ca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions gsmmodem/modem.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ class GsmModem(SerialComms):
CDSI_REGEX = re.compile('\+CDSI:\s*"([^"]+)",(\d+)$')
CDS_REGEX = re.compile('\+CDS:\s*([0-9]+)"$')

def __init__(self, port, baudrate=115200, incomingCallCallbackFunc=None, smsReceivedCallbackFunc=None, smsStatusReportCallback=None, requestDelivery=True, AT_CNMI="", *a, **kw):
super(GsmModem, self).__init__(port, baudrate, notifyCallbackFunc=self._handleModemNotification, *a, **kw)
def __init__(self, port, baudrate=115200, rtscts=True, dsrdtr=True, incomingCallCallbackFunc=None, smsReceivedCallbackFunc=None, smsStatusReportCallback=None, requestDelivery=True, AT_CNMI="", *a, **kw):
super(GsmModem, self).__init__(port, baudrate, rtscts, dsrdtr, notifyCallbackFunc=self._handleModemNotification, *a, **kw)
self.incomingCallCallback = incomingCallCallbackFunc or self._placeholderCallback
self.smsReceivedCallback = smsReceivedCallbackFunc or self._placeholderCallback
self.smsStatusReportCallback = smsStatusReportCallback or self._placeholderCallback
Expand Down
6 changes: 4 additions & 2 deletions gsmmodem/serial_comms.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class SerialComms(object):
# Default timeout for serial port reads (in seconds)
timeout = 1

def __init__(self, port, baudrate=115200, notifyCallbackFunc=None, fatalErrorCallbackFunc=None, *args, **kwargs):
def __init__(self, port, baudrate=115200, rtscts=True, dsrdtr=True, notifyCallbackFunc=None, fatalErrorCallbackFunc=None, *args, **kwargs):
""" Constructor
:param fatalErrorCallbackFunc: function to call if a fatal error occurs in the serial device reading thread
Expand All @@ -31,6 +31,8 @@ def __init__(self, port, baudrate=115200, notifyCallbackFunc=None, fatalErrorCal
self.alive = False
self.port = port
self.baudrate = baudrate
self.dsrdtr = dsrdtr
self.rtscts = rtscts

self._responseEvent = None # threading.Event()
self._expectResponseTermSeq = None # expected response terminator sequence
Expand All @@ -47,7 +49,7 @@ def __init__(self, port, baudrate=115200, notifyCallbackFunc=None, fatalErrorCal

def connect(self):
""" Connects to the device and starts the read thread """
self.serial = serial.Serial(dsrdtr=True, rtscts=True, port=self.port, baudrate=self.baudrate,
self.serial = serial.Serial(rtscts=self.rtscts, dsrdtr=self.dsrdtr, port=self.port, baudrate=self.baudrate,
timeout=self.timeout,*self.com_args,**self.com_kwargs)
# Start read thread
self.alive = True
Expand Down

0 comments on commit fe890ca

Please sign in to comment.