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

Accept error messages like '+CME ERROR:58' without a space after ':' #87

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
2 changes: 1 addition & 1 deletion gsmmodem/serial_comms.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class SerialComms(object):
# End-of-line read terminator
RX_EOL_SEQ = '\r\n'
# End-of-response terminator
RESPONSE_TERM = re.compile(r'^OK|ERROR|(\+CM[ES] ERROR: \d+)|(COMMAND NOT SUPPORT)$')
RESPONSE_TERM = re.compile(r'^OK|ERROR|(\+CM[ES] ERROR: ?\d+)|(COMMAND NOT SUPPORT)$')
# Default timeout for serial port reads (in seconds)
timeout = 1

Expand Down
2 changes: 2 additions & 0 deletions test/test_serial_comms.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ def test_write(self):
""" Tests basic writing operations """
tests = ((['OK\r\n'], ['OK']),
(['ERROR\r\n'], ['ERROR']),
(['+CMS ERROR: 58\r\n'], ['+CMS ERROR: 58']),
(['+CME ERROR:58\r\n'], ['+CME ERROR:58']),
(['first line\r\n', 'second line\r\n', 'OK\r\n'], ['first line', 'second line', 'OK']),
# Some Huawei modems issue this response instead of ERROR for unknown commands; ensure we detect it correctly
(['COMMAND NOT SUPPORT\r\n'], ['COMMAND NOT SUPPORT']))
Expand Down