Skip to content

Commit 3e87b1f

Browse files
committed
Accept error messages like '+CME ERROR:58' without a space after ':'
My A6 GSM modem returns such error codes. This caused the library to hang, waiting for a response indefinitely. After this change modem initialization succeeds and it's possible to send SMS messages etc. It could be also the cause of #24, the symptoms are very similar.
1 parent 834c68b commit 3e87b1f

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

gsmmodem/serial_comms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class SerialComms(object):
1818
# End-of-line read terminator
1919
RX_EOL_SEQ = '\r\n'
2020
# End-of-response terminator
21-
RESPONSE_TERM = re.compile(r'^OK|ERROR|(\+CM[ES] ERROR: \d+)|(COMMAND NOT SUPPORT)$')
21+
RESPONSE_TERM = re.compile(r'^OK|ERROR|(\+CM[ES] ERROR: ?\d+)|(COMMAND NOT SUPPORT)$')
2222
# Default timeout for serial port reads (in seconds)
2323
timeout = 1
2424

test/test_serial_comms.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ def test_write(self):
182182
""" Tests basic writing operations """
183183
tests = ((['OK\r\n'], ['OK']),
184184
(['ERROR\r\n'], ['ERROR']),
185+
(['+CMS ERROR: 58\r\n'], ['+CMS ERROR: 58']),
186+
(['+CME ERROR:58\r\n'], ['+CME ERROR:58']),
185187
(['first line\r\n', 'second line\r\n', 'OK\r\n'], ['first line', 'second line', 'OK']),
186188
# Some Huawei modems issue this response instead of ERROR for unknown commands; ensure we detect it correctly
187189
(['COMMAND NOT SUPPORT\r\n'], ['COMMAND NOT SUPPORT']))

0 commit comments

Comments
 (0)