faucamp / python-gsmmodem

Python module to control a GSM modem attached to the system: send/receive SMS messages, handle calls, etc
GNU Lesser General Public License v3.0
386 stars 304 forks source link

sending SMS - delivery report error #9

Closed dauheeIRL closed 11 years ago

dauheeIRL commented 11 years ago

OK I'm beginning to look like a stalker :) I get an error after sending a SMS (Text mode) using: sms = modem.sendSms('0870000000', 'test4', waitForDeliveryReport=False)

And the error is below - message sends OK but it seems to get a delivery report a few seconds after:

Initializing modem... INFO: Connecting to modem on port COM9 at 115200bps DEBUG: write: ATZ DEBUG: response: ['OK'] DEBUG: write: ATE0 DEBUG: response: ['ATE0\r', 'OK'] DEBUG: write: AT+CSCA? DEBUG: response: ['+CSCA: "+353857000000",145', 'OK'] DEBUG: write: AT+CFUN? DEBUG: response: ['+CFUN: 1', 'OK'] DEBUG: write: AT+CMEE=1 DEBUG: response: ['OK'] DEBUG: write: AT+CPIN? DEBUG: response: ['+CPIN: READY', 'OK'] DEBUG: write: AT+CLAC DEBUG: response: ['ERROR'] DEBUG: write: AT+WIND? DEBUG: response: ['ERROR'] INFO: Loading Huawei call update table DEBUG: write: AT+COPS=3,0 DEBUG: response: ['OK'] DEBUG: write: AT+CMGF=1 DEBUG: response: ['OK'] DEBUG: write: AT+CSCA="+353857000000" DEBUG: response: ['OK'] DEBUG: write: AT+CSMP=49,167,0,0 DEBUG: response: ['OK'] DEBUG: write: AT+CPMS=? DEBUG: response: ['+CPMS: ("ME","MT","SM","SR"),("ME","MT","SM","SR"),("ME","MT","SM","SR")', 'OK'] DEBUG: write: AT+CPMS="ME","ME","ME" DEBUG: response: ['+CPMS: 7,100,7,100,7,100', 'OK'] DEBUG: write: AT+CNMI=2,1,0,2 DEBUG: response: ['OK'] DEBUG: write: AT+CLIP=1 DEBUG: response: ['OK'] DEBUG: write: AT+CRC=1 DEBUG: response: ['OK'] DEBUG: write: AT+CVHU=0 DEBUG: response: ['OK'] DEBUG: write: AT+CSQ DEBUG: response: ['+CSQ: 22,99', 'OK'] DEBUG: write: AT+CUSD? DEBUG: response: ['+CUSD: 0', 'OK'] ['+CUSD: 0', 'OK'] Waiting for SMS and/or calls... DEBUG: write: AT+CMGS="0870000000" DEBUG: response: ['> '] DEBUG: write: test4 DEBUG: response: ['+CMGS: 20', 'OK'] Message sent. DEBUG: notification: ['+CDSI: "SR",57'] DEBUG: SMS status report received DEBUG: write: AT+CPMS="SR" DEBUG: response: ['+CPMS: 8,100,8,100,8,100', 'OK'] DEBUG: write: AT+CMGR=57 DEBUG: response: ['+CMGR: ,6,20,"0870000000",129,"13/04/29,19:58:00+04","13/04/29,19:59:00+04",0', 'OK'] Exception in thread Thread-3: Traceback (most recent call last): File "c:\python27\lib\threading.py", line 551, in bootstrap_inner self.run() File "c:\python27\lib\threading.py", line 504, in run self.__target(_self.args, *_self.kwargs) File "c:\python27\lib\site-packages\gsmmodem\modem.py", line 513, in threadedHandleModemNotification self._handleSmsStatusReport(line) File "c:\python27\lib\site-packages\gsmmodem\modem.py", line 607, in _handleSmsStatusReport report = self._readStoredSmsMessage(msgIndex, msgMemory) File "c:\python27\lib\site-packages\gsmmodem\modem.py", line 660, in _readStoredSmsMessage raise CommandError('Failed to parse the SMS message +CMGR response: {0}'.format(msgData)) CommandError: Failed to parse the SMS message +CMGR response: ['+CMGR: ,6,20,"0870000000",129,"13/04/29,19:58:00+04","13/04/29,19:59:00+04",0', 'OK']

in PDU mode the following is returned: CommandError: Failed to parse the SMS message +CMGR response: ['+CMGR: ,,24', '059475000085061D0AA18027123654314092129300403140921293004000', 'OK']

faucamp commented 11 years ago

Bug confirmed; the SMS text-mode regular expression used for parsing status reports does not match the output of your modem.

I'll add this to the unit tests, issue a fix and update the code. Thanks for the detailed report!

faucamp commented 11 years ago

Fixed in 6a4a72899de60106105a960f277a1f9f091bef28