I spend a lot of time to replace gammu with python-gsmmodem for my Huawei E3531.
The python exemple is just an exemple, it's incomplete. It does not read sms in the memory (if you receive a sms before starting the script). And it does not concat multiple parts sms (it will print unordered parts).
Also, as your live read sms script is running, you cannot send sms with another script because the dongle is busy.
Here is my own script to read all kind of SMS and send in same time.
Don't use python-gsmmodem that is deprecated but python-gsmmodem-new
Install Pyro4:
pip install Pyro4
Install threaded:
pip install threaded
Listen for new SMS
$> python2.7 python-gsmmodem-advanced-read.py
Initializing modem...
Waiting for new SMS message...
Object <__main__.RemoteSMSHandler object at 0x764e9910>:
uri = PYRO:[email protected]:9091
Pyro daemon running.
Keep this process running in background, for exemple with screen
Send SMS:
$> python2.7 python-gsmmodem-advanced-send.py --to=<receipient_number> --message=<your_message>
Hi Steve,
Thanks for this script! I'm stuck trying to use gammu on a E3531 but I get all sort of random error messages.. So I ended up here :)
I'm trying to run your script in a raspberry pi 4 but I'm getting the following error:
pi@raspberrypi:~ $ python2.7 python-gsmmodem-advanced-read.py
Initializing modem...
INFO: Connecting to modem on port /dev/ttyUSB0 at 115200bps
DEBUG: write: ATZ
DEBUG: response: ['OK']
DEBUG: write: ATE0
DEBUG: response: ['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
Traceback (most recent call last):
File "python-gsmmodem-advanced-read.py", line 81, in
main()
File "python-gsmmodem-advanced-read.py", line 67, in main
modem.connect(PIN)
File "/usr/local/lib/python2.7/dist-packages/gsmmodem/modem.py", line 201, in connect
commands = self.supportedCommands
File "/usr/local/lib/python2.7/dist-packages/gsmmodem/modem.py", line 490, in supportedCommands
response = self.write('AT+CLAC')
File "/usr/local/lib/python2.7/dist-packages/gsmmodem/modem.py", line 398, in write
responseLines = SerialComms.write(self, data + writeTerm, waitForResponse=waitForResponse, timeout=timeout, expectedResponseTermSeq=expectedResponseTermSeq)
File "/usr/local/lib/python2.7/dist-packages/gsmmodem/serial_comms.py", line 135, in write
raise TimeoutException()
gsmmodem.exceptions.TimeoutException
On lsusb I get:
Bus 001 Device 022: ID 12d1:1001 Huawei Technologies Co., Ltd. E161/E169/E620/E800 HSDPA Modem
And gammu identify:
Device : /dev/ttyUSB0
Manufacturer : Huawei
Model : E3531 (E3531)
Anything else basic I might be missing ? Thanks!