Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user to set (RTS/CTS) and (DSR/DTR) flows control #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change here...

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):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

""" 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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put rtscts and dsrdtr after timeout

timeout=self.timeout,*self.com_args,**self.com_kwargs)
# Start read thread
self.alive = True
Expand Down