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
384 stars 302 forks source link

Can it work when the 3G connection is active? #18

Closed HansF closed 11 years ago

HansF commented 11 years ago

So all works well when there's no 3G connection. But when there is I have an issue running the incoming_call_demo.py script. When I dial the number it is ringing and with every ring an error message logs to the screen:

Exception in thread Thread-58:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 505, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/local/lib/python2.7/dist-packages/python_gsmmodem-0.8-py2.7.egg/gsmmodem/modem.py", line 643, in __threadedHandleModemNotification
    self._handleIncomingCall(lines)
  File "/usr/local/lib/python2.7/dist-packages/python_gsmmodem-0.8-py2.7.egg/gsmmodem/modem.py", line 672, in _handleIncomingCall
    callType = ringLine.split(' ', 1)[1]
IndexError: list index out of range

Manufacturer: huawei Model: K3715 Revision: 11.104.05.00.00

Furthermore, I'm using the sakis3G script to connect.

HansF commented 11 years ago

If I first make the connection, and then start the python script, all is fine.

faucamp commented 11 years ago

Thanks for the report! I'm glad you found a workaround, but this is indeed a valid bug (and one which I have been able to replicate), so I am reopening this until I have submitted a fix.

faucamp commented 11 years ago

The issue is that the sakis3g script modifies the "extended incoming call indication" setting of the modem (AT+CRC). Since python-gsmmodem sets this during connect(), it does not expect an external program to modify it - this is also why it works if you start python-gsmmodem after sakis3G.

The patch above allows python-gsmmodem to detect this change, so it should work fine either way for you now. Please re-open the ticket if the issue is not resolved for you.

HansF commented 11 years ago

Works like a charm here. Thanks!