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

Serial Exceptions #66

Open ghost opened 8 years ago

ghost commented 8 years ago

Hi!, I have this code:

modem = GsmModem(port, 115200, smsReceivedCallbackFunc=handleSms)
modem.connect()
while True:
    try:
        print(str(modem.signalStrength))
    except Exception as e:
        print("Error: " + str(e))
        modem.close()

We have a usb multimodem with 8 ports, on a windows 7. The problem we have is that sometimes the ports die, and we get SerialExceptions and TimeoutExceptions.

I want to know if you have any idea what is causing this. Also I would like to know if this is a correct way to wait for incoming sms. As an alternative to this:
```python
modem.rxThread.join(2**31) # Specify a (huge) timeout so that it essentially blocks indefinitely, but still receives CTRL+C interrupt signal

Thank you
babca commented 8 years ago

while true print(modem.signalStrength) - why do you do this? check examples/sms_handler_demo.py for correct way to wait