Git Product home page Git Product logo

python-gammu's Introduction

python-gammu

Python bindings for the Gammu library.

https://api.codacy.com/project/badge/Grade/c7e87df480fb4609aa48482873f5c46b Liberapay Bountysource PyPI

Homepage

<https://wammu.eu/python-gammu/>

License

Copyright (C) 2003 - 2018 Michal Cihar

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Installing

You can install in a usual way for Python modules using setuptools, so use setup.py which is placed in the top level directory:

./setup.py build
sudo ./setup.py install

You can also install it using pip installer:

pip install python-gammu

Requirements

To compile python-gammu, you need Gammu development files (usually shipped as libgammu-dev or gammu-devel in Linux distributions).

The location of the libraries is discovered using pkg-config, GAMMU_PATH environment variable and falls back to generic locations. In case it does not work, either install pkg-config or set GAMMU_PATH.

On Linux something like this should work:

GAMMU_PATH=/opt/gammu python setup.py build

On Windows:

SET GAMMU_PATH="C:\Gammu"
python setup.py build

Documentation

Please see included python documentation:

>>> import gammu
>>> help(gammu)

Alternatively you can use Sphinx to generate browsable version, which is also available on-line at <https://wammu.eu/docs/manual/>.

Feedback and bug reports

Any feedback is welcome, see <https://wammu.eu/support/> for information how to contact developers.

python-gammu's People

Contributors

bourock avatar dannybeckett avatar demank avatar dependabot[bot] avatar ekacnet avatar falbot avatar fenio avatar fitojb avatar gsavix avatar haaninjo avatar jnavila avatar mashtullah avatar nijel avatar nmarci1 avatar ocalvo avatar panos78 avatar phcoder avatar pre-commit-ci[bot] avatar readmanr avatar rimy avatar rmathias avatar ruleant avatar samejo avatar severense avatar sihar avatar sorenjorvang avatar stefanbosak avatar trimbilrepo avatar weblate avatar yarons avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

python-gammu's Issues

python3 support needed

# sudo apt-get install gammu
Reading package lists... Done
Building dependency tree       
Reading state information... Done
gammu is already the newest version (1.38.1-1+deb.cihar.com~yakkety.1).
0 to upgrade, 0 to newly install, 0 to remove and 26 not to upgrade.
root@crowthorne:/home/dave/Downloads/python-gammu-2.8# sudo pip-3.2 install python-gammu
sudo: pip-3.2: command not found
root@crowthorne:/home/dave/Downloads/python-gammu-2.8# sudo pip-3.2 install python-gammu
sudo: pip-3.2: command not found
root@crowthorne:/home/dave/Downloads/python-gammu-2.8# sudo pip3.2 install python-gammu
sudo: pip3.2: command not found
root@crowthorne:/home/dave/Downloads/python-gammu-2.8# sudo pip3 install python-gammu
Collecting python-gammu
  Using cached python-gammu-2.8.tar.gz
    Complete output from command python setup.py egg_info:
    Package gammu was not found in the pkg-config search path.
    Perhaps you should add the directory containing `gammu.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'gammu' found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-v8lls__o/python-gammu/setup.py", line 110, in <module>
        check_minimum_gammu_version()
      File "/tmp/pip-build-v8lls__o/python-gammu/setup.py", line 45, in check_minimum_gammu_version
        "gammu"
      File "/usr/lib/python3.5/distutils/spawn.py", line 36, in spawn
        _spawn_posix(cmd, search_path, dry_run=dry_run)
      File "/usr/lib/python3.5/distutils/spawn.py", line 159, in _spawn_posix
        % (cmd, exit_status))
    distutils.errors.DistutilsExecError: command 'pkg-config' failed with exit status 1
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-v8lls__o/python-gammu/
# 

unicode characters don't show up in sms

whenever i send unicode characters in an sms they either don't show up or get replaced by similar nonunicode ones

this is what i use to send the sms

def send_sms(recipients, sms_text):
    sm = gammu.StateMachine()
    sm.ReadConfig()
    sm.Init()

    for number, language in recipients:
        smsinfo = {
            'Class': -1,
            'Unicode': True,
            'Entries': [
                {
                    'ID': 'ConcatenatedTextLong',
                    'Buffer': sms_text
                }
            ]}
        encoded = gammu.EncodeSMS(smsinfo)
        try:
            for message in encoded:
                message['SMSC'] = {'Location': 1}
                message['Number'] = number
                sm.SendSMS(message)
            logger.info('sent to ' + number)
        except Exception as e:
            logger.error(e)

python-gammu ussd response delay

Hi Guys,
I've been trying out python-gammu the last couple off days, and noticed a delay in the ussd response when using the service_numbers example.

The response is -+ 17 seconds, while for the same ussd command I receive a response within 4 seconds, if i sent the AT command
AT+CUSD=1,,15 using socat.

I noticed that the state_machine.Init() takes 5-7 seconds

Any idea how i can speed up the init process within python-gammu

My setup:
CentOS 7
python 3.6
python-gammu 3.1
modem: wavecomm wmod2 (at9600)

Cannot send to Canada

We are facing a strange problem. It seems like that we could send SMS to different countries and to different numbers but not to Canada. :) It does not work from python-gammu but it works with the cli. The cli SMS is received, the python-gammu sms not.

I haven't looked into the source until now. Any idea? Is the number to short ;)

python gammu:

cat test.py 
#!/usr/bin/python3

import gammu

print(gammu.Version())
s = gammu.StateMachine()
s.ReadConfig(Section=0, Filename="/opt/smsgateway/conf/gammu.conf")
s.Init()

content = 'text'
content = content.encode('ascii')

smsinfo = {
    'Class': 1,
    'Unicode': False,
    'Entries': [
        {
            'ID': 'Text',
            'Buffer': content
        }
    ]}

encoded = gammu.EncodeSMS(smsinfo)

for message in encoded:
    message['SMSC'] = {'Location': 1}
    message['Number'] = '+128938XXXXX'

    try:
        msgref = s.SendSMS(message)
        status = True
        print(status)
    except:
        msgref = 'Error'
        status = False
        print(status)
        raise

cli:

echo "test" | ./gammu -c /opt/smsgateway/conf/gammu.conf sendsms TEXT +128938XXXXX

SMSD test does not pass

When running the test suite for python-gammu 2.5 under any of Python 2.7.11, 3.4.3, 3.5.1 on x86_64 Linux, I receive the following error:

test_smsd (test.test_smsd.SMSDDummyTest) ... Log filename is "stderr"
Fri 2016/01/22 01:14:31 python-gammu[541]: Warning: No PIN code in /var/tmp/portage/dev-python/python-gammu-2.5/temp/tmp40w59hdn/.gammurc file
Fri 2016/01/22 01:14:31 python-gammu[541]: Connected to Database sqlite3: smsd.db on localhost
Fri 2016/01/22 01:14:31 python-gammu[541]: Written message with ID 1
Fri 2016/01/22 01:14:31 python-gammu[541]: Written message with ID 2
Fri 2016/01/22 01:14:31 python-gammu[541]: Created POSIX RW shared memory at 0x7fcb84044000
Fri 2016/01/22 01:14:31 python-gammu[541]: Starting phone communication...
Fri 2016/01/22 01:14:31 python-gammu[541]: Inserting phone info
Fri 2016/01/22 01:14:32 python-gammu[541]: Read 2 messages
Fri 2016/01/22 01:15:02 python-gammu[541]: Terminating communication...
FAIL

======================================================================
FAIL: test_smsd (test.test_smsd.SMSDDummyTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/var/tmp/portage/dev-python/python-gammu-2.5/work/python-gammu-2.5/test/test_smsd.py", line 118, in test_smsd
    status['Sent']
AssertionError: 0 != 2 : Messages were not sent as expected (0)!

----------------------------------------------------------------------
Ran 46 tests in 46.197s

FAILED (failures=1)

SMS callback does not fire

I can't get the callback to fire on incoming SMS. I can see the received SMS when I call GetNextSMS but the callback never fires. The callback does not fire for incoming calls either, but it does work for replies to USSD requests.

I attached the modified incoming.py example which reproduces the problem on my system and the debug log. From the output, the SMS is received but the callback is never called:

Press Ctrl+C to interrupt
Signal is at 48%
Signal is at 48%
Signal is at 48%
Signal is at 48%
Signal is at 48%
Signal is at 48%
Signal is at 48%
Signal is at 48%
Signal is at 48%
Signal is at 48%
Signal is at 48%
Signal is at 48%
Received new SMS
Signal is at 48%
Signal is at 48%
Signal is at 48%
Signal is at 48%
Signal is at 48%
Signal is at 48%
Received new SMS
Signal is at 48%
Signal is at 48%
Signal is at 48%

Any idea where the problem might be?

Thanks.

incoming.py.txt
gammu.dbg.txt


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

how install it ?

diff gammu-1.34.0/python/ python-gammu-2.1/ -rq
shows:
Only in gammu-1.34.0/python/: CMakeLists.txt
Only in gammu-1.34.0/python/: CMakeTests.txt

So I think, it can't be installed as in gammu-1.34 ...

service-numbers.py seems not to work

Hi,
I wanted to use the python example service-numbers.py but as far as I can say it seems to have a bug.
If I use gammu (gammu getussd *100#) I get the left credits (in โ‚ฌ) of my Prepaid Card just like I want to.
However if I use service-numbers.py, which should accomplish the same, I always get status: Terminated and no further info. I am using a Huawei E!60 USB-Device with a Raspberrypi 2 OS: Jessie

Below you find the logfiles:

  • for gammu getussd *100#
[Gammu            - 1.33.0 built 08:46:05 Aug 14 2013 using GCC 4.6]
[Connection       - "at19200"]
[Connection index - 0]
[Model type       - ""]
[Device           - "/dev/ttyUSB1"]
[Running on       - Linux, kernel 4.1.7-v7+ (#817 SMP PREEMPT Sat Sep 19 15:32:00 BST 2015)]
Serial device: DTR is up, RTS is up, CAR is down, CTS is down
Setting speed to 19200
[Module           - "auto"]
Escaping SMS mode
SENDING frametype 0x00/length 0x02/2
1B |0D                                                          ..              
Sending simple AT command to wake up some devices
SENDING frametype 0x00/length 0x03/3
41A|54T|0D                                                      AT.             
1 "AT"
2 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x09/9
41A|54T|0D |0D |0A |4FO|4BK|0D |0A                              AT...OK..       
Enabling echo
SENDING frametype 0x00/length 0x05/5
41A|54T|45E|311|0D                                              ATE1.           
1 "ATE1"
2 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x0B/11
41A|54T|45E|311|0D |0D |0A |4FO|4BK|0D |0A                      ATE1...OK..     
Trying Motorola mode switch
SENDING frametype 0x00/length 0x0A/10
41A|54T|2B+|4DM|4FO|44D|45E|3D=|322|0D                          AT+MODE=2.      
1 "AT+MODE=2"
2 "ERROR"
Checking line: ERROR
AT reply state: 3
RECEIVED frametype 0x00/length 0x13/19
41A|54T|2B+|4DM|4FO|44D|45E|3D=|322|0D |0D |0A |45E|52R|52R|4FO AT+MODE=2...ERRO
52R|0D |0A                                                      R..             
Seems not to be supported
Enabling CME errors
SENDING frametype 0x00/length 0x0A/10
41A|54T|2B+|43C|4DM|45E|45E|3D=|311|0D                          AT+CMEE=1.      
1 "AT+CMEE=1"
2 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x10/16
41A|54T|2B+|43C|4DM|45E|45E|3D=|311|0D |0D |0A |4FO|4BK|0D |0A  AT+CMEE=1...OK..
SENDING frametype 0x00/length 0x09/9
41A|54T|2B+|43C|53S|43C|53S|3F?|0D                              AT+CSCS?.       
1 "AT+CSCS?"
2 "+CSCS: "GSM""
3 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x1F/31
41A|54T|2B+|43C|53S|43C|53S|3F?|0D |0D |0A |2B+|43C|53S|43C|53S AT+CSCS?...+CSCS
3A:|20 |22"|47G|53S|4DM|22"|0D |0A |0D |0A |4FO|4BK|0D |0A      : "GSM"....OK.. 
SENDING frametype 0x00/length 0x08/8
41A|54T|2B+|43C|47G|4DM|49I|0D                                  AT+CGMI.        
1 "AT+CGMI"
2 "huawei"
3 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x18/24
41A|54T|2B+|43C|47G|4DM|49I|0D |0D |0A |68h|75u|61a|77w|65e|69i AT+CGMI...huawei
0D |0A |0D |0A |4FO|4BK|0D |0A                                  ....OK..        
Manufacturer info received
[Manufacturer: Huawei]
SENDING frametype 0x00/length 0x0A/10
41A|54T|2B+|43C|53S|43C|53S|3D=|3F?|0D                          AT+CSCS=?.      
1 "AT+CSCS=?"
2 "+CSCS: ("IRA","GSM","UCS2")"
3 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x2F/47
41A|54T|2B+|43C|53S|43C|53S|3D=|3F?|0D |0D |0A |2B+|43C|53S|43C AT+CSCS=?...+CSC
53S|3A:|20 |28(|22"|49I|52R|41A|22"|2C,|22"|47G|53S|4DM|22"|2C, S: ("IRA","GSM",
22"|55U|43C|53S|322|22"|29)|0D |0A |0D |0A |4FO|4BK|0D |0A      "UCS2")....OK.. 
Chosen GSM as normal charset
Chosen UCS2 as unicode charset
Getting model
SENDING frametype 0x00/length 0x08/8
41A|54T|2B+|43C|47G|4DM|4DM|0D                                  AT+CGMM.        
1 "AT+CGMM"
2 "E160"
3 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x16/22
41A|54T|2B+|43C|47G|4DM|4DM|0D |0D |0A |45E|311|366|300|0D |0A  AT+CGMM...E160..
0D |0A |4FO|4BK|0D |0A                                          ..OK..          
[Model name: `E160']
[Model data: `E160']
[Model data: `E160']
1 "^BOOT:30275962,0,0,0,75"
Checking line: ^BOOT:30275962,0,0,0,75
AT reply state: 4
RECEIVED frametype 0x00/length 0x19/25
5E^|42B|4FO|4FO|54T|3A:|333|300|322|377|355|399|366|322|2C,|300 ^BOOT:30275962,0
2C,|300|2C,|300|2C,|377|355|0D |0A                              ,0,0,75..       
[Connected model  - "E160"]
Checking for OBEX support
SENDING frametype 0x00/length 0x0B/11
41A|54T|2B+|43C|50P|52R|4FO|54T|3D=|3F?|0D                      AT+CPROT=?.     
1 "AT+CPROT=?"
2 "ERROR"
Checking line: ERROR
AT reply state: 3
RECEIVED frametype 0x00/length 0x14/20
41A|54T|2B+|43C|50P|52R|4FO|54T|3D=|3F?|0D |0D |0A |45E|52R|52R AT+CPROT=?...ERR
4FO|52R|0D |0A                                                  OR..            
Checking for SYNCML/OBEX support
SENDING frametype 0x00/length 0x0C/12
41A|54T|2B+|53S|59Y|4EN|43C|4DM|4CL|3D=|3F?|0D                  AT+SYNCML=?.    
1 "AT+SYNCML=?"
2 "ERROR"
Checking line: ERROR
AT reply state: 3
RECEIVED frametype 0x00/length 0x15/21
41A|54T|2B+|53S|59Y|4EN|43C|4DM|4CL|3D=|3F?|0D |0D |0A |45E|52R AT+SYNCML=?...ER
52R|4FO|52R|0D |0A                                              ROR..           
Checking for SYNCML/OBEX support
SENDING frametype 0x00/length 0x0D/13
41A|54T|24$|54T|53S|53S|50P|43C|53S|57W|3D=|3F?|0D              AT$TSSPCSW=?.   
1 "AT$TSSPCSW=?"
2 "ERROR"
Checking line: ERROR
AT reply state: 3
RECEIVED frametype 0x00/length 0x16/22
41A|54T|24$|54T|53S|53S|50P|43C|53S|57W|3D=|3F?|0D |0D |0A |45E AT$TSSPCSW=?...E
52R|52R|4FO|52R|0D |0A                                          RROR..          
[Module           - "A2D|iPAQ|at|M20|S25|MC35|TC35|C35i|S65|S300|5110|5130|5190|5210|6110|6130|6150|6190|6210|6250|6310|6310i|6510|7110|8210|8250|8290|8310|8390|8850|8855|8890|8910|9110|9210"]
Escaping SMS mode
SENDING frametype 0x00/length 0x02/2
1B |0D                                                          ..              
Sending simple AT command to wake up some devices
SENDING frametype 0x00/length 0x03/3
41A|54T|0D                                                      AT.             
1 "AT"
2 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x09/9
41A|54T|0D |0D |0A |4FO|4BK|0D |0A                              AT...OK..       
Enabling echo
SENDING frametype 0x00/length 0x05/5
41A|54T|45E|311|0D                                              ATE1.           
1 "ATE1"
2 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x0B/11
41A|54T|45E|311|0D |0D |0A |4FO|4BK|0D |0A                      ATE1...OK..     
Trying Motorola mode switch
SENDING frametype 0x00/length 0x0A/10
41A|54T|2B+|4DM|4FO|44D|45E|3D=|322|0D                          AT+MODE=2.      
1 "AT+MODE=2"
2 "ERROR"
Checking line: ERROR
AT reply state: 3
RECEIVED frametype 0x00/length 0x13/19
41A|54T|2B+|4DM|4FO|44D|45E|3D=|322|0D |0D |0A |45E|52R|52R|4FO AT+MODE=2...ERRO
52R|0D |0A                                                      R..             
Seems not to be supported
Enabling CME errors
SENDING frametype 0x00/length 0x0A/10
41A|54T|2B+|43C|4DM|45E|45E|3D=|311|0D                          AT+CMEE=1.      
1 "AT+CMEE=1"
2 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x10/16
41A|54T|2B+|43C|4DM|45E|45E|3D=|311|0D |0D |0A |4FO|4BK|0D |0A  AT+CMEE=1...OK..
SENDING frametype 0x00/length 0x09/9
41A|54T|2B+|43C|53S|43C|53S|3F?|0D                              AT+CSCS?.       
1 "AT+CSCS?"
2 "+CSCS: "GSM""
3 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x1F/31
41A|54T|2B+|43C|53S|43C|53S|3F?|0D |0D |0A |2B+|43C|53S|43C|53S AT+CSCS?...+CSCS
3A:|20 |22"|47G|53S|4DM|22"|0D |0A |0D |0A |4FO|4BK|0D |0A      : "GSM"....OK.. 
SENDING frametype 0x00/length 0x08/8
41A|54T|2B+|43C|47G|4DM|49I|0D                                  AT+CGMI.        
1 "AT+CGMI"
2 "huawei"
3 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x18/24
41A|54T|2B+|43C|47G|4DM|49I|0D |0D |0A |68h|75u|61a|77w|65e|69i AT+CGMI...huawei
0D |0A |0D |0A |4FO|4BK|0D |0A                                  ....OK..        
Manufacturer info received
[Manufacturer: Huawei]
SENDING frametype 0x00/length 0x0A/10
41A|54T|2B+|43C|53S|43C|53S|3D=|3F?|0D                          AT+CSCS=?.      
1 "AT+CSCS=?"
2 "+CSCS: ("IRA","GSM","UCS2")"
3 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x2F/47
41A|54T|2B+|43C|53S|43C|53S|3D=|3F?|0D |0D |0A |2B+|43C|53S|43C AT+CSCS=?...+CSC
53S|3A:|20 |28(|22"|49I|52R|41A|22"|2C,|22"|47G|53S|4DM|22"|2C, S: ("IRA","GSM",
22"|55U|43C|53S|322|22"|29)|0D |0A |0D |0A |4FO|4BK|0D |0A      "UCS2")....OK.. 
Chosen GSM as normal charset
Chosen UCS2 as unicode charset
Checking for OBEX support
SENDING frametype 0x00/length 0x0B/11
41A|54T|2B+|43C|50P|52R|4FO|54T|3D=|3F?|0D                      AT+CPROT=?.     
1 "AT+CPROT=?"
2 "ERROR"
Checking line: ERROR
AT reply state: 3
RECEIVED frametype 0x00/length 0x14/20
41A|54T|2B+|43C|50P|52R|4FO|54T|3D=|3F?|0D |0D |0A |45E|52R|52R AT+CPROT=?...ERR
4FO|52R|0D |0A                                                  OR..            
Checking for SYNCML/OBEX support
SENDING frametype 0x00/length 0x0C/12
41A|54T|2B+|53S|59Y|4EN|43C|4DM|4CL|3D=|3F?|0D                  AT+SYNCML=?.    
1 "AT+SYNCML=?"
2 "ERROR"
Checking line: ERROR
AT reply state: 3
RECEIVED frametype 0x00/length 0x15/21
41A|54T|2B+|53S|59Y|4EN|43C|4DM|4CL|3D=|3F?|0D |0D |0A |45E|52R AT+SYNCML=?...ER
52R|4FO|52R|0D |0A                                              ROR..           
Checking for SYNCML/OBEX support
SENDING frametype 0x00/length 0x0D/13
41A|54T|24$|54T|53S|53S|50P|43C|53S|57W|3D=|3F?|0D              AT$TSSPCSW=?.   
1 "AT$TSSPCSW=?"
2 "ERROR"
Checking line: ERROR
AT reply state: 3
RECEIVED frametype 0x00/length 0x16/22
41A|54T|24$|54T|53S|53S|50P|43C|53S|57W|3D=|3F?|0D |0D |0A |45E AT$TSSPCSW=?...E
52R|52R|4FO|52R|0D |0A                                          RROR..          
Setting date & time
SENDING frametype 0x00/length 0x21/33
41A|54T|2B+|43C|43C|4CL|4BK|3D=|22"|322|300|311|355|2F/|311|300 AT+CCLK="2015/10
2F/|300|311|2C,|311|322|3A:|355|311|3A:|355|399|2B+|300|300|22" /01,12:51:59+00"
0D                                                              .               
1 "AT+CCLK="2015/10/01,12:51:59+00""
2 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x27/39
41A|54T|2B+|43C|43C|4CL|4BK|3D=|22"|322|300|311|355|2F/|311|300 AT+CCLK="2015/10
2F/|300|311|2C,|311|322|3A:|355|311|3A:|355|399|2B+|300|300|22" /01,12:51:59+00"
0D |0D |0A |4FO|4BK|0D |0A                                      ...OK..         
Getting firmware versions
SENDING frametype 0x00/length 0x08/8
41A|54T|2B+|43C|47G|4DM|52R|0D                                  AT+CGMR.        
1 "AT+CGMR"
2 "11.604.18.01.00"
3 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x21/33
41A|54T|2B+|43C|47G|4DM|52R|0D |0D |0A |311|311|2E.|366|300|344 AT+CGMR...11.604
2E.|311|388|2E.|300|311|2E.|300|300|0D |0A |0D |0A |4FO|4BK|0D  .18.01.00....OK.
0A                                                              .               
Received firmware version: "11.604.18.01.00"
Number version is "11.604180"
[Firmware version - "11.604.18.01.00"]
[Connected]
Entering GSM_SetIncomingUSSD
Enabling incoming USSD
SENDING frametype 0x00/length 0x0A/10
41A|54T|2B+|43C|55U|53S|44D|3D=|311|0D                          AT+CUSD=1.      
1 "AT+CUSD=1"
2 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x10/16
41A|54T|2B+|43C|55U|53S|44D|3D=|311|0D |0D |0A |4FO|4BK|0D |0A  AT+CUSD=1...OK..
Leaving GSM_SetIncomingUSSD
Entering GSM_DialService
SENDING frametype 0x00/length 0x1A/26
41A|54T|2B+|43C|55U|53S|44D|3D=|311|2C,|22"|41A|41A|311|388|300 AT+CUSD=1,"AA180
43C|333|366|300|322|22"|2C,|311|355|0D                          C3602",15.      
1 "AT+CUSD=1,"AA180C3602",15"
2 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x20/32
41A|54T|2B+|43C|55U|53S|44D|3D=|311|2C,|22"|41A|41A|311|388|300 AT+CUSD=1,"AA180
43C|333|366|300|322|22"|2C,|311|355|0D |0D |0A |4FO|4BK|0D |0A  C3602",15...OK..
Incoming USSD received
Leaving GSM_DialService
1 "+CUSD: 0,"A0E09A5E2FB3D9E539E858A7A3C3E2B25B07CAB9723150B12A7501",15"
Checking line: +CUSD: 0,"A0E09A5E2FB3D9E539E858A7A3C3E2B25B07CAB9723150B12A7501",15
AT reply state: 4
RECEIVED frametype 0x00/length 0x46/70
2B+|43C|55U|53S|44D|3A:|20 |300|2C,|22"|41A|300|45E|300|399|41A +CUSD: 0,"A0E09A
355|45E|322|46F|42B|333|44D|399|45E|355|333|399|45E|388|355|388 5E2FB3D9E539E858
41A|377|41A|333|43C|333|45E|322|42B|322|355|42B|300|377|43C|41A A7A3C3E2B25B07CA
42B|399|377|322|333|311|355|300|42B|311|322|41A|377|355|300|311 B9723150B12A7501
22"|2C,|311|355|0D |0A                                          ",15..          
Incoming USSD received
Parsing +CUSD: 0,"A0E09A5E2FB3D9E539E858A7A3C3E2B25B07CAB9723150B12A7501",15
 with +CUSD: @i @0
Parsed int 0
Status: 0
Parsing +CUSD: 0,"A0E09A5E2FB3D9E539E858A7A3C3E2B25B07CAB9723150B12A7501",15
 with +CUSD: @i, @r, @i @0
Parsed int 0
Grabbed string from reply: "A0E09A5E2FB3D9E539E858A7A3C3E2B25B07CAB9723150B12A7501" (parsed 56 bytes)
Parsed raw string "A0E09A5E2FB3D9E539E858A7A3C3E2B25B07CAB9723150B12A7501"
Parsed int 15
1 "^RSSI:22"
Checking line: ^RSSI:22
AT reply state: 4
RECEIVED frametype 0x00/length 0x0A/10
5E^|52R|53S|53S|49I|3A:|322|322|0D |0A                          ^RSSI:22..      
1 "^RSSI:22"
Checking line: ^RSSI:22
AT reply state: 4
RECEIVED frametype 0x00/length 0x0A/10
5E^|52R|53S|53S|49I|3A:|322|322|0D |0A                          ^RSSI:22..      
  • for service-numbers.py
[Gammu            - 1.33.0 built 08:46:05 Aug 14 2013 using GCC 4.6]
[Connection       - "at19200"]
[Connection index - 0]
[Model type       - ""]
[Device           - "/dev/ttyUSB1"]
[Running on       - Linux, kernel 4.1.7-v7+ (#817 SMP PREEMPT Sat Sep 19 15:32:00 BST 2015)]
Serial device: DTR is up, RTS is up, CAR is down, CTS is down
Setting speed to 19200
[Module           - "auto"]
Escaping SMS mode
SENDING frametype 0x00/length 0x02/2
1B |0D                                                          ..              
Sending simple AT command to wake up some devices
SENDING frametype 0x00/length 0x03/3
41A|54T|0D                                                      AT.             
1 "AT"
2 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x09/9
41A|54T|0D |0D |0A |4FO|4BK|0D |0A                              AT...OK..       
Enabling echo
SENDING frametype 0x00/length 0x05/5
41A|54T|45E|311|0D                                              ATE1.           
1 "ATE1"
2 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x0B/11
41A|54T|45E|311|0D |0D |0A |4FO|4BK|0D |0A                      ATE1...OK..     
Trying Motorola mode switch
SENDING frametype 0x00/length 0x0A/10
41A|54T|2B+|4DM|4FO|44D|45E|3D=|322|0D                          AT+MODE=2.      
1 "AT+MODE=2"
2 "ERROR"
Checking line: ERROR
AT reply state: 3
RECEIVED frametype 0x00/length 0x13/19
41A|54T|2B+|4DM|4FO|44D|45E|3D=|322|0D |0D |0A |45E|52R|52R|4FO AT+MODE=2...ERRO
52R|0D |0A                                                      R..             
Seems not to be supported
Enabling CME errors
SENDING frametype 0x00/length 0x0A/10
41A|54T|2B+|43C|4DM|45E|45E|3D=|311|0D                          AT+CMEE=1.      
1 "AT+CMEE=1"
2 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x10/16
41A|54T|2B+|43C|4DM|45E|45E|3D=|311|0D |0D |0A |4FO|4BK|0D |0A  AT+CMEE=1...OK..
SENDING frametype 0x00/length 0x09/9
41A|54T|2B+|43C|53S|43C|53S|3F?|0D                              AT+CSCS?.       
1 "AT+CSCS?"
2 "+CSCS: "GSM""
3 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x1F/31
41A|54T|2B+|43C|53S|43C|53S|3F?|0D |0D |0A |2B+|43C|53S|43C|53S AT+CSCS?...+CSCS
3A:|20 |22"|47G|53S|4DM|22"|0D |0A |0D |0A |4FO|4BK|0D |0A      : "GSM"....OK.. 
SENDING frametype 0x00/length 0x08/8
41A|54T|2B+|43C|47G|4DM|49I|0D                                  AT+CGMI.        
1 "AT+CGMI"
2 "huawei"
3 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x18/24
41A|54T|2B+|43C|47G|4DM|49I|0D |0D |0A |68h|75u|61a|77w|65e|69i AT+CGMI...huawei
0D |0A |0D |0A |4FO|4BK|0D |0A                                  ....OK..        
Manufacturer info received
[Manufacturer: Huawei]
SENDING frametype 0x00/length 0x0A/10
41A|54T|2B+|43C|53S|43C|53S|3D=|3F?|0D                          AT+CSCS=?.      
1 "AT+CSCS=?"
2 "+CSCS: ("IRA","GSM","UCS2")"
3 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x2F/47
41A|54T|2B+|43C|53S|43C|53S|3D=|3F?|0D |0D |0A |2B+|43C|53S|43C AT+CSCS=?...+CSC
53S|3A:|20 |28(|22"|49I|52R|41A|22"|2C,|22"|47G|53S|4DM|22"|2C, S: ("IRA","GSM",
22"|55U|43C|53S|322|22"|29)|0D |0A |0D |0A |4FO|4BK|0D |0A      "UCS2")....OK.. 
Chosen GSM as normal charset
Chosen UCS2 as unicode charset
Getting model
SENDING frametype 0x00/length 0x08/8
41A|54T|2B+|43C|47G|4DM|4DM|0D                                  AT+CGMM.        
1 "AT+CGMM"
2 "E160"
3 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x16/22
41A|54T|2B+|43C|47G|4DM|4DM|0D |0D |0A |45E|311|366|300|0D |0A  AT+CGMM...E160..
0D |0A |4FO|4BK|0D |0A                                          ..OK..          
[Model name: `E160']
[Model data: `E160']
[Model data: `E160']
[Connected model  - "E160"]
Checking for OBEX support
SENDING frametype 0x00/length 0x0B/11
41A|54T|2B+|43C|50P|52R|4FO|54T|3D=|3F?|0D                      AT+CPROT=?.     
1 "AT+CPROT=?"
2 "ERROR"
Checking line: ERROR
AT reply state: 3
RECEIVED frametype 0x00/length 0x14/20
41A|54T|2B+|43C|50P|52R|4FO|54T|3D=|3F?|0D |0D |0A |45E|52R|52R AT+CPROT=?...ERR
4FO|52R|0D |0A                                                  OR..            
Checking for SYNCML/OBEX support
SENDING frametype 0x00/length 0x0C/12
41A|54T|2B+|53S|59Y|4EN|43C|4DM|4CL|3D=|3F?|0D                  AT+SYNCML=?.    
1 "AT+SYNCML=?"
2 "ERROR"
Checking line: ERROR
AT reply state: 3
RECEIVED frametype 0x00/length 0x15/21
41A|54T|2B+|53S|59Y|4EN|43C|4DM|4CL|3D=|3F?|0D |0D |0A |45E|52R AT+SYNCML=?...ER
52R|4FO|52R|0D |0A                                              ROR..           
Checking for SYNCML/OBEX support
SENDING frametype 0x00/length 0x0D/13
41A|54T|24$|54T|53S|53S|50P|43C|53S|57W|3D=|3F?|0D              AT$TSSPCSW=?.   
1 "AT$TSSPCSW=?"
2 "ERROR"
Checking line: ERROR
AT reply state: 3
RECEIVED frametype 0x00/length 0x16/22
41A|54T|24$|54T|53S|53S|50P|43C|53S|57W|3D=|3F?|0D |0D |0A |45E AT$TSSPCSW=?...E
52R|52R|4FO|52R|0D |0A                                          RROR..          
[Module           - "A2D|iPAQ|at|M20|S25|MC35|TC35|C35i|S65|S300|5110|5130|5190|5210|6110|6130|6150|6190|6210|6250|6310|6310i|6510|7110|8210|8250|8290|8310|8390|8850|8855|8890|8910|9110|9210"]
Escaping SMS mode
SENDING frametype 0x00/length 0x02/2
1B |0D                                                          ..              
Sending simple AT command to wake up some devices
SENDING frametype 0x00/length 0x03/3
41A|54T|0D                                                      AT.             
1 "AT"
2 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x09/9
41A|54T|0D |0D |0A |4FO|4BK|0D |0A                              AT...OK..       
Enabling echo
SENDING frametype 0x00/length 0x05/5
41A|54T|45E|311|0D                                              ATE1.           
1 "ATE1"
2 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x0B/11
41A|54T|45E|311|0D |0D |0A |4FO|4BK|0D |0A                      ATE1...OK..     
Trying Motorola mode switch
SENDING frametype 0x00/length 0x0A/10
41A|54T|2B+|4DM|4FO|44D|45E|3D=|322|0D                          AT+MODE=2.      
1 "AT+MODE=2"
2 "ERROR"
Checking line: ERROR
AT reply state: 3
RECEIVED frametype 0x00/length 0x13/19
41A|54T|2B+|4DM|4FO|44D|45E|3D=|322|0D |0D |0A |45E|52R|52R|4FO AT+MODE=2...ERRO
52R|0D |0A                                                      R..             
Seems not to be supported
Enabling CME errors
SENDING frametype 0x00/length 0x0A/10
41A|54T|2B+|43C|4DM|45E|45E|3D=|311|0D                          AT+CMEE=1.      
1 "AT+CMEE=1"
2 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x10/16
41A|54T|2B+|43C|4DM|45E|45E|3D=|311|0D |0D |0A |4FO|4BK|0D |0A  AT+CMEE=1...OK..
SENDING frametype 0x00/length 0x09/9
41A|54T|2B+|43C|53S|43C|53S|3F?|0D                              AT+CSCS?.       
1 "AT+CSCS?"
2 "+CSCS: "GSM""
3 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x1F/31
41A|54T|2B+|43C|53S|43C|53S|3F?|0D |0D |0A |2B+|43C|53S|43C|53S AT+CSCS?...+CSCS
3A:|20 |22"|47G|53S|4DM|22"|0D |0A |0D |0A |4FO|4BK|0D |0A      : "GSM"....OK.. 
SENDING frametype 0x00/length 0x08/8
41A|54T|2B+|43C|47G|4DM|49I|0D                                  AT+CGMI.        
1 "AT+CGMI"
2 "huawei"
3 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x18/24
41A|54T|2B+|43C|47G|4DM|49I|0D |0D |0A |68h|75u|61a|77w|65e|69i AT+CGMI...huawei
0D |0A |0D |0A |4FO|4BK|0D |0A                                  ....OK..        
Manufacturer info received
[Manufacturer: Huawei]
SENDING frametype 0x00/length 0x0A/10
41A|54T|2B+|43C|53S|43C|53S|3D=|3F?|0D                          AT+CSCS=?.      
1 "AT+CSCS=?"
2 "+CSCS: ("IRA","GSM","UCS2")"
3 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x2F/47
41A|54T|2B+|43C|53S|43C|53S|3D=|3F?|0D |0D |0A |2B+|43C|53S|43C AT+CSCS=?...+CSC
53S|3A:|20 |28(|22"|49I|52R|41A|22"|2C,|22"|47G|53S|4DM|22"|2C, S: ("IRA","GSM",
22"|55U|43C|53S|322|22"|29)|0D |0A |0D |0A |4FO|4BK|0D |0A      "UCS2")....OK.. 
Chosen GSM as normal charset
Chosen UCS2 as unicode charset
Checking for OBEX support
SENDING frametype 0x00/length 0x0B/11
41A|54T|2B+|43C|50P|52R|4FO|54T|3D=|3F?|0D                      AT+CPROT=?.     
1 "AT+CPROT=?"
2 "ERROR"
Checking line: ERROR
AT reply state: 3
RECEIVED frametype 0x00/length 0x14/20
41A|54T|2B+|43C|50P|52R|4FO|54T|3D=|3F?|0D |0D |0A |45E|52R|52R AT+CPROT=?...ERR
4FO|52R|0D |0A                                                  OR..            
Checking for SYNCML/OBEX support
SENDING frametype 0x00/length 0x0C/12
41A|54T|2B+|53S|59Y|4EN|43C|4DM|4CL|3D=|3F?|0D                  AT+SYNCML=?.    
1 "AT+SYNCML=?"
2 "ERROR"
Checking line: ERROR
AT reply state: 3
RECEIVED frametype 0x00/length 0x15/21
41A|54T|2B+|53S|59Y|4EN|43C|4DM|4CL|3D=|3F?|0D |0D |0A |45E|52R AT+SYNCML=?...ER
52R|4FO|52R|0D |0A                                              ROR..           
Checking for SYNCML/OBEX support
SENDING frametype 0x00/length 0x0D/13
41A|54T|24$|54T|53S|53S|50P|43C|53S|57W|3D=|3F?|0D              AT$TSSPCSW=?.   
1 "AT$TSSPCSW=?"
2 "ERROR"
Checking line: ERROR
AT reply state: 3
RECEIVED frametype 0x00/length 0x16/22
41A|54T|24$|54T|53S|53S|50P|43C|53S|57W|3D=|3F?|0D |0D |0A |45E AT$TSSPCSW=?...E
52R|52R|4FO|52R|0D |0A                                          RROR..          
Setting date & time
SENDING frametype 0x00/length 0x21/33
41A|54T|2B+|43C|43C|4CL|4BK|3D=|22"|322|300|311|355|2F/|311|300 AT+CCLK="2015/10
2F/|300|311|2C,|311|322|3A:|355|311|3A:|344|311|2B+|300|300|22" /01,12:51:41+00"
0D                                                              .               
1 "AT+CCLK="2015/10/01,12:51:41+00""
2 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x27/39
41A|54T|2B+|43C|43C|4CL|4BK|3D=|22"|322|300|311|355|2F/|311|300 AT+CCLK="2015/10
2F/|300|311|2C,|311|322|3A:|355|311|3A:|344|311|2B+|300|300|22" /01,12:51:41+00"
0D |0D |0A |4FO|4BK|0D |0A                                      ...OK..         
Getting firmware versions
SENDING frametype 0x00/length 0x08/8
41A|54T|2B+|43C|47G|4DM|52R|0D                                  AT+CGMR.        
1 "AT+CGMR"
2 "11.604.18.01.00"
3 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x21/33
41A|54T|2B+|43C|47G|4DM|52R|0D |0D |0A |311|311|2E.|366|300|344 AT+CGMR...11.604
2E.|311|388|2E.|300|311|2E.|300|300|0D |0A |0D |0A |4FO|4BK|0D  .18.01.00....OK.
0A                                                              .               
Received firmware version: "11.604.18.01.00"
Number version is "11.604180"
[Firmware version - "11.604.18.01.00"]
[Connected]
Entering GSM_SetIncomingUSSD
Enabling incoming USSD
SENDING frametype 0x00/length 0x0A/10
41A|54T|2B+|43C|55U|53S|44D|3D=|311|0D                          AT+CUSD=1.      
1 "AT+CUSD=1"
2 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x10/16
41A|54T|2B+|43C|55U|53S|44D|3D=|311|0D |0D |0A |4FO|4BK|0D |0A  AT+CUSD=1...OK..
Leaving GSM_SetIncomingUSSD
Entering GSM_DialService
SENDING frametype 0x00/length 0x1A/26
41A|54T|2B+|43C|55U|53S|44D|3D=|311|2C,|22"|41A|41A|311|388|300 AT+CUSD=1,"AA180
43C|333|366|300|322|22"|2C,|311|355|0D                          C3602",15.      
1 "AT+CUSD=1,"AA180C3602",15"
2 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x20/32
41A|54T|2B+|43C|55U|53S|44D|3D=|311|2C,|22"|41A|41A|311|388|300 AT+CUSD=1,"AA180
43C|333|366|300|322|22"|2C,|311|355|0D |0D |0A |4FO|4BK|0D |0A  C3602",15...OK..
Incoming USSD received
Leaving GSM_DialService
Entering GSM_SetIncomingSMS
Getting available SMS memories
SENDING frametype 0x00/length 0x0A/10
41A|54T|2B+|43C|50P|4DM|53S|3D=|3F?|0D                          AT+CPMS=?.      
1 "AT+CPMS=?"
2 "+CPMS: ("ME","MT","SM","SR"),("ME","MT","SM","SR"),("ME","MT","SM","SR")"
3 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x5C/92
41A|54T|2B+|43C|50P|4DM|53S|3D=|3F?|0D |0D |0A |2B+|43C|50P|4DM AT+CPMS=?...+CPM
53S|3A:|20 |28(|22"|4DM|45E|22"|2C,|22"|4DM|54T|22"|2C,|22"|53S S: ("ME","MT","S
4DM|22"|2C,|22"|53S|52R|22"|29)|2C,|28(|22"|4DM|45E|22"|2C,|22" M","SR"),("ME","
4DM|54T|22"|2C,|22"|53S|4DM|22"|2C,|22"|53S|52R|22"|29)|2C,|28( MT","SM","SR"),(
22"|4DM|45E|22"|2C,|22"|4DM|54T|22"|2C,|22"|53S|4DM|22"|2C,|22" "ME","MT","SM","
53S|52R|22"|29)|0D |0A |0D |0A |4FO|4BK|0D |0A                  SR")....OK..    
Available SMS memories received: read: ME : ok, SM : ok, save: ME : ok, SM = ok, Motorola = no
Setting SMS memory type to ME
SENDING frametype 0x00/length 0x0D/13
41A|54T|2B+|43C|50P|4DM|53S|3D=|22"|4DM|45E|22"|0D              AT+CPMS="ME".   
1 "AT+CPMS="ME""
2 "+CPMS: 0,23,0,20,0,20"
3 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x2C/44
41A|54T|2B+|43C|50P|4DM|53S|3D=|22"|4DM|45E|22"|0D |0D |0A |2B+ AT+CPMS="ME"...+
43C|50P|4DM|53S|3A:|20 |300|2C,|322|333|2C,|300|2C,|322|300|2C, CPMS: 0,23,0,20,
300|2C,|322|300|0D |0A |0D |0A |4FO|4BK|0D |0A                  0,20....OK..    
SENDING frametype 0x00/length 0x0A/10
41A|54T|2B+|43C|4EN|4DM|49I|3D=|3F?|0D                          AT+CNMI=?.      
1 "AT+CNMI=?"
2 "+CNMI: (0,1,2),(0,1,2,3),(0,2),(0,1,2),(0,1)"
3 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x40/64
41A|54T|2B+|43C|4EN|4DM|49I|3D=|3F?|0D |0D |0A |2B+|43C|4EN|4DM AT+CNMI=?...+CNM
49I|3A:|20 |28(|300|2C,|311|2C,|322|29)|2C,|28(|300|2C,|311|2C, I: (0,1,2),(0,1,
322|2C,|333|29)|2C,|28(|300|2C,|322|29)|2C,|28(|300|2C,|311|2C, 2,3),(0,2),(0,1,
322|29)|2C,|28(|300|2C,|311|29)|0D |0A |0D |0A |4FO|4BK|0D |0A  2),(0,1)....OK..
Parsing range: (0,1,2),(0,1,2,3),(0,2),(0,1,2),(0,1)
Returning range: 0, 1, 2, -1
Parsing range: (0,1,2,3),(0,2),(0,1,2),(0,1)
Returning range: 0, 1, 2, 3, -1
Parsing range: (0,2),(0,1,2),(0,1)
Returning range: 0, 2, -1
Parsing range: (0,1,2),(0,1)
Returning range: 0, 1, 2, -1
Leaving GSM_SetIncomingSMS
Entering GSM_SetIncomingCall
SENDING frametype 0x00/length 0x0A/10
41A|54T|2B+|43C|43C|57W|41A|3D=|300|0D                          AT+CCWA=0.      
1 "AT+CCWA=0"
2 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x10/16
41A|54T|2B+|43C|43C|57W|41A|3D=|300|0D |0D |0A |4FO|4BK|0D |0A  AT+CCWA=0...OK..
Disabling incoming call notification
Leaving GSM_SetIncomingCall
Entering GSM_SetIncomingCB
Leaving GSM_SetIncomingCB
Entering GSM_SetIncomingUSSD
Terminating possible incoming USSD
SENDING frametype 0x00/length 0x0A/10
41A|54T|2B+|43C|55U|53S|44D|3D=|322|0D                          AT+CUSD=2.      
1 "AT+CUSD=2"
2 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x10/16
41A|54T|2B+|43C|55U|53S|44D|3D=|322|0D |0D |0A |4FO|4BK|0D |0A  AT+CUSD=2...OK..
Disabling incoming USSD
SENDING frametype 0x00/length 0x0A/10
41A|54T|2B+|43C|55U|53S|44D|3D=|300|0D                          AT+CUSD=0.      
1 "+CUSD: 2"
Checking line: +CUSD: 2
AT reply state: 4
RECEIVED frametype 0x00/length 0x0A/10
2B+|43C|55U|53S|44D|3A:|20 |322|0D |0A                          +CUSD: 2..      
Incoming USSD received
Parsing +CUSD: 2
 with +CUSD: @i @0
Parsed int 2
Status: 2
Parsing +CUSD: 2
 with +CUSD: @i, @r, @i @0
Parsed int 2
Parsing +CUSD: 2
 with +CUSD: @i, @r @0
Parsed int 2
1 "AT+CUSD=0"
2 "OK"
Checking line: OK
AT reply state: 1
RECEIVED frametype 0x00/length 0x10/16
41A|54T|2B+|43C|55U|53S|44D|3D=|300|0D |0D |0A |4FO|4BK|0D |0A  AT+CUSD=0...OK..
Leaving GSM_SetIncomingUSSD
[Terminating]
[Closing]

How to get USSD response?

How to send a USSD code (i.e. *140*11#) and get its response?

Here is what I have done so far:

import gammu
import unittest


class USSD(unittest.TestCase):
    test_dir = None
    config_name = '/code/config_files/config-smsd.ini'
    dummy_dir = None
    _called = False
    _state_machine = None

    def get_statemachine(self):
        state_machine = gammu.StateMachine()
        state_machine.ReadConfig(Filename=self.config_name)
        state_machine.Init()
        self._state_machine = state_machine
        return state_machine

    def ussd_callback(self, state_machine, response, data):
        """
        Callback on USSD data.
        """
        self._called = True
        self.assertEqual(response, 'USSD')
        self.assertEqual(data['Text'], 'Reply for charge rate')
        self.assertEqual(data['Status'], 'NoActionNeeded')

    def test_ussd(self):
        self._called = False
        state_machine = self.get_statemachine()
        state_machine.SetIncomingCallback(self.ussd_callback)
        state_machine.SetIncomingUSSD()
        state_machine.DialService('*140*11#')
        self.assertTrue(self._called)


if __name__ == '__main__':
    try:
        USSD().test_ussd()
    except KeyboardInterrupt:
        import sys
        sys.exit(0)

Out:

Traceback (most recent call last):
  File "ussd_2.py", line 42, in <module>
    ussd.test_ussd()
  File "ussd_2.py", line 36, in test_ussd
    self.assertTrue(self._called)
  File "/usr/lib/python3.6/unittest/case.py", line 682, in assertTrue
    raise self.failureException(msg)
AssertionError: False is not true

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Loop of long sms

Hello,
I' am trying to send loop of long text messages. I get only receive 80% percent of this sms on my own number. In the case of normal text messages, the problem doesn't occur. I would like to know what this is caused, I tried on several modems ...

This is my code responsible for sending sms:

def loop(url_get, sms, sm):
    list_sms = sms.get_sms(url_get)
    if list_sms:
        for send in list_sms:
            status = sms.long_send_message(sm, send['text'] + str(send['id']), send['phone'], 0)
            time.sleep(5)

            if status:
                msg = 'success'
                print(msg)
            else:
                msg = 'failed'
                print(msg)

            sms.post_result_sms(send['id'], status, msg, gammu.SMSCounter(send['text'])[0])
    def long_send_message(self, sm, text, number):
        smsinfo = {
            'Class': 1,
            'Unicode': False,
            'Entries': [
                {
                    'ID': 'ConcatenatedTextLong',
                    'Buffer':
                        text
                }
            ]}

        encoded = gammu.EncodeSMS(smsinfo)

        status = True
        for message in encoded:
            message['Number'] = number

            try:
                sm.SendSMS(message)
            except gammu.GSMError:
                status = False
        return status

Install fails using pip install

The installation fails by using pip install with the following message:

Perhaps you should add the directory containing `gammu.pc' to the PKG_CONFIG_PATH environment variable
No package 'gammu' found

Installation Windows

Is it possible to install/compile python-gammu in windows? i have some errors with install in windows.

Skip Database tests or make it more correct

Installed gammu 1.38.5/1.40.1, builded with postgresql. But python-gammu 2.12 fail tests:

test_inject (test.test_smsd.SMSDDummyTest) ... Fri 2019/11/01 15:50:09 python-gammu[23837]: Using SQL service
Fri 2019/11/01 15:50:09 python-gammu[23837]: Configuring Gammu SMSD...
Fri 2019/11/01 15:50:09 python-gammu[23837]: SHM token: 0x103715e (17002846)
Fri 2019/11/01 15:50:09 python-gammu[23837]: Warning: No PIN code in /var/calculate/tmp/portage/dev-python/python-gammu-2.12/temp/tmployHVJ/.gammurc file
Fri 2019/11/01 15:50:09 python-gammu[23837]: CommTimeout=1, SendTimeout=30, ReceiveFrequency=15, ResetFrequency=0, HardResetFrequency=0
Fri 2019/11/01 15:50:09 python-gammu[23837]: checks: CheckSecurity=1, CheckBattery=1, CheckSignal=1, CheckNetwork=1
Fri 2019/11/01 15:50:09 python-gammu[23837]: mode: Send=1, Receive=1
Fri 2019/11/01 15:50:09 python-gammu[23837]: deliveryreport = no
Fri 2019/11/01 15:50:09 python-gammu[23837]: phoneid = 
Fri 2019/11/01 15:50:09 python-gammu[23837]: Unknown DB driver
ERROR

(twice)

======================================================================
ERROR: test_inject (test.test_smsd.SMSDDummyTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/var/calculate/tmp/portage/dev-python/python-gammu-2.12/work/python-gammu-2.12/test/test_smsd.py", line 91, in test_inject
    smsd = self.get_smsd()
  File "/var/calculate/tmp/portage/dev-python/python-gammu-2.12/work/python-gammu-2.12/test/test_smsd.py", line 85, in get_smsd
    return gammu.smsd.SMSD(self.config_name)
ERR_UNKNOWN: {'Text': u'Unknown error.', 'Code': 27, 'Where': 'SMSD_ReadConfig'}

(twice too)

FAILED (errors=2)
Test failed: <unittest.runner.TextTestResult run=50 errors=2 failures=0>
python-gammu: WARNING: Adding USSD to queue, position 0
Gammu version (1, 40, 0), SMSD DB version 17
Gammu version (1, 40, 0), SMSD DB version 17
Log filename is "stderr"
Gammu version (1, 40, 0), SMSD DB version 17
Log filename is "stderr"
error: Test failed: <unittest.runner.TextTestResult run=50 errors=2 failures=0>

With 1.38.5 same result. Perhaps it's not bug, but need explanations...

ImportError: No module named 'gammu._gammu'

Still struggling to get python-gammu working on Ubuntu , have install 1.38.4 latest gammu and 2.9 latest python-gammu bundings, the error I see is:-

(ve) dave@crowthorne:~/Downloads/python-gammu-2.9$ python
Python 3.5.3 (default, Jan 19 2017, 14:11:04) 
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gammu
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/dave/Downloads/python-gammu-2.9/gammu/__init__.py", line 26, in <module>
    from gammu._gammu import *
ImportError: No module named 'gammu._gammu'
>>> 
LSB Version:	core-9.20160110ubuntu5-amd64:core-9.20160110ubuntu5-noarch:printing-9.20160110ubuntu5-amd64:printing-9.20160110ubuntu5-noarch:security-9.20160110ubuntu5-amd64:security-9.20160110ubuntu5-noarch
Distributor ID:	Ubuntu
Description:	Ubuntu 17.04
Release:	17.04
Codename:	zesty(ve) dave@crowthorne:~/Downloads/gammu-1.38.4$ sudo make install
make -C build-configure install
make[1]: Entering directory '/home/dave/Downloads/gammu-1.38.4/build-configure'
make[2]: Entering directory '/home/dave/Downloads/gammu-1.38.4/build-configure'
make[3]: Entering directory '/home/dave/Downloads/gammu-1.38.4/build-configure'
...
...
-- Up-to-date: /usr/share/bash-completion/completions/gammu
-- Up-to-date: /lib/systemd/system/gammu-smsd.service
make[1]: Leaving directory '/home/dave/Downloads/gammu-1.38.4/build-configure'
(ve) dave@crowthorne:~/Downloads/gammu-1.38.4$ 

(ve) dave@crowthorne:~/Downloads/python-gammu-2.9$ python setup.py install
running install
running bdist_egg
running egg_info
writing python_gammu.egg-info/PKG-INFO
writing top-level names to python_gammu.egg-info/top_level.txt
writing dependency_links to python_gammu.egg-info/dependency_links.txt
reading manifest file 'python_gammu.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'python_gammu.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
running build_ext
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/gammu
copying build/lib.linux-x86_64-3.5/gammu/_gammu.cpython-35m-x86_64-linux-gnu.so -> build/bdist.linux-x86_64/egg/gammu
copying build/lib.linux-x86_64-3.5/gammu/__init__.py -> build/bdist.linux-x86_64/egg/gammu
copying build/lib.linux-x86_64-3.5/gammu/data.py -> build/bdist.linux-x86_64/egg/gammu
copying build/lib.linux-x86_64-3.5/gammu/worker.py -> build/bdist.linux-x86_64/egg/gammu
copying build/lib.linux-x86_64-3.5/gammu/smsd.py -> build/bdist.linux-x86_64/egg/gammu
copying build/lib.linux-x86_64-3.5/gammu/exception.py -> build/bdist.linux-x86_64/egg/gammu
byte-compiling build/bdist.linux-x86_64/egg/gammu/__init__.py to __init__.cpython-35.pyc
byte-compiling build/bdist.linux-x86_64/egg/gammu/data.py to data.cpython-35.pyc
byte-compiling build/bdist.linux-x86_64/egg/gammu/worker.py to worker.cpython-35.pyc
byte-compiling build/bdist.linux-x86_64/egg/gammu/smsd.py to smsd.cpython-35.pyc
byte-compiling build/bdist.linux-x86_64/egg/gammu/exception.py to exception.cpython-35.pyc
creating stub loader for gammu/_gammu.cpython-35m-x86_64-linux-gnu.so
byte-compiling build/bdist.linux-x86_64/egg/gammu/_gammu.py to _gammu.cpython-35.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying python_gammu.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying python_gammu.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying python_gammu.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying python_gammu.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
gammu.__pycache__._gammu.cpython-35: module references __file__
creating dist
creating 'dist/python_gammu-2.9-py3.5-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing python_gammu-2.9-py3.5-linux-x86_64.egg
creating /home/dave/Env/ve/lib/python3.5/site-packages/python_gammu-2.9-py3.5-linux-x86_64.egg
Extracting python_gammu-2.9-py3.5-linux-x86_64.egg to /home/dave/Env/ve/lib/python3.5/site-packages
Adding python-gammu 2.9 to easy-install.pth file

Installed /home/dave/Env/ve/lib/python3.5/site-packages/python_gammu-2.9-py3.5-linux-x86_64.egg
Processing dependencies for python-gammu==2.9
Finished processing dependencies for python-gammu==2.9
(ve) dave@crowthorne:~/Downloads/python-gammu-2.9$ python
Python 3.5.3 (default, Jan 19 2017, 14:11:04) 
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gammu
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/dave/Downloads/python-gammu-2.9/gammu/__init__.py", line 26, in <module>
    from gammu._gammu import *
ImportError: No module named 'gammu._gammu'
>>> 

Callback not firing for incoming call when using GammuWorker

When I use GammuWorker, callback is not firing for incoming call events type. During incoming call it hangs.
For incoming SMS - ok.
Example bellow:

__author__ = 'vic'
#!/usr/bin/env python

import gammu
import time
import gammu.worker

def _event_callback(sm, type, data):
    print 'Received incoming event type %s, data:' % type
    print data

def _worker_callback(name, result, error, percents):
    print '-> %s completed %d%% with error %s , return value:' % (
            name,
            percents,
            error)
    print result
    pass

_gsm_config = {
        'StartInfo': True,
        'UseGlobalDebugFile': True,
        'DebugFile': None,
        'SyncTime': True,
        'Connection': 'at115200',
        'LockDevice': False,
        'DebugLevel': 'textalldate',
        'Device': '/dev/ttyUSB0',
        'Model': '',
        }

_sm = gammu.StateMachine()
_sm.SetConfig(0, _gsm_config)
_worker = gammu.worker.GammuWorker(_worker_callback)
_worker.configure(_gsm_config)
_worker.initiate()
_worker.enqueue('SetIncomingCallback', [_event_callback])
_worker.enqueue('SetIncomingCall')
_worker.enqueue('SetIncomingCB')
_worker.enqueue('SetIncomingSMS')


while(1):
    time.sleep(3)
    _worker.enqueue('ReadDevice')
    _worker.enqueue('GetSignalQuality')

I will appreciate if you share any information.
Thank you.

Can't get dial voice status

I use function DialVoice(Number) for dial voice, I get only Status': 'CallEnd' via SetIncomingCallback.
How I can get dial status (BUSY, NO DIALTONE, NO CARRIER, NA ANSWER, CONNECT) ?
gammu version: ('1.33.0', '2.6', '1.37.4')

It can't get the SMS-Cat's status when multi-process parallel execution the GetSMSStatus() methodใ€‚

When I execute the code as follows on two terminal at the same time, It can't get the SMS-Cat status in the correct wayใ€‚

#! /usr/bin/python
# coding: utf-8
# filename: temp_smscat_status.py 


import os
import time
import gammu


def check_smscat_status():
    try:
        print("\nGetting SMS-Cat status...")
        t_smModule = gammu.StateMachine()
        t_smModule.ReadConfig()
        t_smModule.Init()
        t_smModule.GetSMSStatus()
        print("SMS-Cat in good or useable condition. ")
        print("Success Code: %s" % t_smModule.GetSMSStatus())
    except Exception, e:
        print("\nFailed to get SMS-Cat status")
        print("Error Code: %s." % e)
        return False


def main():
    while True:
        status = check_smscat_status()


if __name__ == "__main__":
    main()

When I only execute the code on terminal 1, it works normal, the output information as follows:

# python temp_smscat_status.py 

Getting SMS-Cat status...
SMS-Cat in good or useable condition. 
Success Code: {'TemplatesUsed': 0, 'SIMUsed': 50, 'PhoneSize': 99, 'SIMUnRead': 0, 'PhoneUsed': 0, 'PhoneUnRead': 0, 'SIMSize': 50}

Getting SMS-Cat status...
SMS-Cat in good or useable condition. 
Success Code: {'TemplatesUsed': 0, 'SIMUsed': 50, 'PhoneSize': 99, 'SIMUnRead': 0, 'PhoneUsed': 0, 'PhoneUnRead': 0, 'SIMSize': 50}

Getting SMS-Cat status...
SMS-Cat in good or useable condition. 
Success Code: {'TemplatesUsed': 0, 'SIMUsed': 50, 'PhoneSize': 99, 'SIMUnRead': 0, 'PhoneUsed': 0, 'PhoneUnRead': 0, 'SIMSize': 50}

When another terminal named terminal 2 joined, this program can't get the status in the correct way.
The output information on terminal 1 :

python temp_smscat_status.py 

Getting SMS-Cat status...
SMS-Cat in good or useable condition. 
Success Code: {'TemplatesUsed': 0, 'SIMUsed': 50, 'PhoneSize': 99, 'SIMUnRead': 0, 'PhoneUsed': 0, 'PhoneUnRead': 0, 'SIMSize': 50}

Getting SMS-Cat status...

Failed to get SMS-Cat status
Error Code: {'Text': u'No response in specified timeout. Probably phone not connected.', 'Code': 14, 'Where': 'Init'}.

The output information on terminal 2:

python temp_smscat_status.py 

Getting SMS-Cat status...

Failed to get SMS-Cat status
Error Code: {'Text': u'No response in specified timeout. Probably phone not connected.', 'Code': 14, 'Where': 'Init'}.

Getting SMS-Cat status...

Failed to get SMS-Cat status
Error Code: {'Text': u'No response in specified timeout. Probably phone not connected.', 'Code': 14, 'Where': 'Init'}.

So, I guess python-gammu maybe not support the multi-process parallel execution to get the device status and send messages. (Iโ€˜m sorry for that I haven't read the gammu'ssource code yet.)

And then, I got a simple and not nicely method to solve my problem in my app as follows (but it can't essentially solve the problem):

#! /usr/bin/python
# coding: utf-8

import os
import time
import gammu

def check_smscat_status():
    """ According the temp file is exists or not to Lock call the gammu module
    """
    try:
        tmp_file_path = "/tmp/test_smscat_status.txt"
        while os.path.exists(tmp_file_path): 
            with open(tmp_file_path, "r+") as fp:
                last_time = long(fp.read().split(".")[0])
                time_interval = time.time() - last_time
                if time_interval >= 8:
                    os.system("rm -rf %s" % tmp_file_path)
                    break
                else:
                    time.sleep(3)

        os.system("echo %ld > %s" % (time.time(), tmp_file_path))
        print("\nGetting SMS-Cat status...")
        t_smModule = gammu.StateMachine()
        t_smModule.ReadConfig()
        t_smModule.Init()
        t_smModule.GetSMSStatus()
        print("Success! SMS-Cat in good or useable condition. ")
        print("Success Code: %s" % t_smModule.GetSMSStatus()) 
    except Exception, e:
        print("\nFail! Failed to get SMS-Cat status")
        print("Fail Code: %s." % e) 
        os.system("rm -rf %s" % tmp_file_path)
        return False
    os.system("rm -rf %s" % tmp_file_path)
    return True


def main():
    while True:
        check_smscat_status()
        time.sleep(1)

if __name__ == "__main__":
    main()

And the code on above executes on two terminal at the same time, will get another error information sometimes:

# python test_smscat_status.py 

Getting SMS-Cat status...
Success! SMS-Cat in good or useable condition. 
Success Code: {'TemplatesUsed': 0, 'SIMUsed': 50, 'PhoneSize': 99, 'SIMUnRead': 0, 'PhoneUsed': 0, 'PhoneUnRead': 0, 'SIMSize': 50}

Getting SMS-Cat status...

Fail! Failed to get SMS-Cat status
Fail Code: {'Text': u'Error opening device. Unknown/busy or no permissions.', 'Code': 2, 'Where': 'Init'}.

Can't connect to the phone after remove usb-cable

Xubuntu 16.04, Gammu 1.37.4, python-gammu 2.6, Philips x5500
After start my programm can initiate and terminate connection many times.
But after extrim-disconnect as removing the usb-cable and inserting it back connection can't be established. Error gammu.ERR_DEVICENOTEXIST is occure. After restart the phone connection not work aswell. After restart the computer connection work well. Where is the problem? Same problem does appear in Wammu. In wammu connection may be established after re-creating new config for telephone.

This is config file after four extrim-disconnection and re-creating new config:

`>[gammu]
connection = at
logformat = nothing
port = /dev/ttyACM0
synchronizetime = no
name= all_in_one
model=

[gammu1]
port=/dev/ttyACM0
connection=at115200
name=first
model=

[gammu2]
port=/dev/ttyUSB0
connection=at115200
name=second
model=

[gammu3]
port=/dev/ttyUSB1
connection=at115200
name=third

[gammu4]
port=/dev/ttyUSB0
connection=at115200
name=fourth

`

DailVoice <> Call Status / Call ID

Not sure if this is an issue or rather a question (if so I can update the docs / examples if others have the same issue). My "issue" is how do I query the call status after I dispatched DialVoice for example:

# this returns None 
state_machine.DialVoice(PHONENUMBER)

# respectively w/ worker.enqueue
worker.enqueue('DialVoice', (PHONENUMBER, hide_caller_id))

How do I know the status of this phone call (e.g. is it still ongoing? it's call id to CancelCall it?). Pretty sure that there is an easy way and I just don't seem to grasp it. :)

Thanks,
Livio


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

ERROR: test_emoji_folder (test.test_dummy.BasicDummyTest)

Hi,

======================================================================
ERROR: test_emoji_folder (test.test_dummy.BasicDummyTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/python-gammu-2.9/test/test_dummy.py", line 377, in test_emoji_folder
    os.path.exists(os.path.join(self.dummy_dir, 'fs', name))
  File "/usr/lib64/python2.7/genericpath.py", line 26, in exists
    os.stat(path)
UnicodeEncodeError: 'ascii' codec can't encode character u'\U0001f618' in position 35: ordinal not in range(128)
----------------------------------------------------------------------
Ran 50 tests in 32.334s
FAILED (errors=1)

full logs here : https://koji.fedoraproject.org/koji/taskinfo?taskID=21340990
what this may be ? have you any idea ?
In a new build I checked and the test failure is just in python2
Thanks


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

failed to find gammu, ubuntu 16.04

  • pkg-config installed
  • export GAMMU_PATH=/usr/bin/gammu / export GAMMU_PATH=/usr/bin/
xaxa@surf:~/python-gammu$ python3 setup.py build
Failed to find Gammu!
Either it is not installed or not found.
After install Gammu ensure that setup finds it by any of:
 * Specify path to it using GAMMU_PATH in environment.
 * Install pkg-config.

Connection state?

Hi,
I want to write a reliable mqtt sms deamon that always reconnects when the phone connection is lost. Is there a way to query the phone state? I found no way in the API to query for the phone state. There must be some AT command that responds with a simple OK, cant we use this?

I want to use this information to either close or reopen the connection. Do you have any example or suggestion to build such a relyable deamon?

Incoming SMS on a SIM800C USB modem will crash

When using SMS callbacks with a SIM800C modem, the call to ReadDevice crash the process:

gammu/src/gammu.c:430

Fatal Python error: Segmentation fault

Current thread 0x00007fd295440700 (most recent call first):
  File "/mnt/s/dd/Repos/ha/core/homeassistant/components/sms/gateway.py", line 44 in sms_pull
  File "/mnt/s/dd/Repos/ha/core/venv/lib/python3.8/site-packages/python_gammu-3.2.3-py3.8-linux-x86_64.egg/gammu/worker.py", line 247 in run
  File "/usr/lib/python3.8/threading.py", line 932 in _bootstrap_inner
  File "/usr/lib/python3.8/threading.py", line 890 in _bootstrap
(gdb) backtrace
#0  0x00000000005f26bb in PyObject_Call ()
#1  0x00007fffe12601fb in CheckIncomingEvents (sm=0x7fffe061c030) at gammu/src/gammu.c:430
#2  0x00007fffe1262790 in StateMachine_ReadDevice (self=0x7fffe061c030, args=<optimized out>, kwds=<optimized out>)
    at gammu/src/gammu.c:893
#3  0x0000000000504939 in ?? ()
#4  0x000000000056acb6 in _PyEval_EvalFrameDefault ()
#5  0x000000000050b6fe in ?? ()
#6  0x000000000056fb87 in _PyEval_EvalFrameDefault ()
#7  0x00000000005f5956 in _PyFunction_Vectorcall ()
#8  0x000000000056acb6 in _PyEval_EvalFrameDefault ()
#9  0x00000000005f5956 in _PyFunction_Vectorcall ()
#10 0x000000000056acb6 in _PyEval_EvalFrameDefault ()
#11 0x00000000005f5956 in _PyFunction_Vectorcall ()
#12 0x000000000050b7f8 in ?? ()
#13 0x00000000005f2702 in PyObject_Call ()
#14 0x000000000065578c in ?? ()
#15 0x0000000000675d48 in ?? ()
#16 0x00007fffff586609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#17 0x00007fffff6c2293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
(gdb)

More info

(gdb) print *sm

$4 = {ob_base = {ob_refcnt = 5, ob_type = 0x7fffe127dca0 <StateMachineType>}, s = 0x7fffe0020010, DebugFile = 0x0,
  IncomingCallback = 0x0, SMSStatus = 0, MessageReference = 0, IncomingCallQueue = {0x0 <repeats 11 times>},
  IncomingSMSQueue = {0x0 <repeats 11 times>}, IncomingCBQueue = {0x0 <repeats 11 times>}, IncomingUSSDQueue = {
    0x0 <repeats 11 times>}, memory_entry_cache_type = 0, memory_entry_cache = 1, todo_entry_cache = 1,
  calendar_entry_cache = 1, mutex = 0x19534e0}

Command timeout option ?

I have run into a weird problem

this is my code

    .......
    print('GETSMS: 8')

    # try:
    #     sleep(.3)
    #     sms_status = sm.GetSMSStatus()
    #     print(sms_status)
    # except Exception:
    #     print('WOW')

    print('GETSMS: 9')
    # total = sms_status['SIMUsed']
    # print(sms)
    # print(total)
    sms = []
    start = True

    while True:
        try:
            if start:
                current_sms = sm.GetNextSMS(Folder=1, Start=True)
                start = False
            else:
                current_sms = sm.GetNextSMS(Folder=1, Location=current_sms[0]['Location'])

            sms.append(current_sms)
            current_sms_length = len(current_sms)
        except Exception as e:
            print(repr(e))
            current_sms_length = 0

        if current_sms_length == 0:
            print('No messages here')
            break
        else:
            print('Found 1 message')

    linked_sms = gammu.LinkSMS(sms)
    messages = []
    .....

I run this code in a while loop, At first, it works flawlessly, but after a few runs, the program stops working
the line "GETSMS: 9" is printed and it stops, is there a timeout i can put to get out of the getNextSMS method ?

Thank you.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Can not install python-gammu in conda

gammu and gammu-smsd are installed in my Pi (Rasbian, 2018.10.9), using apt-get.

Then, I want to install all python packages in conda env. So I create a venv called PiSMS (conda create --name PiSMS python=3) and activated it.

Then, I want to install python-gammu in the venv, here is the error:

(pisms) PiSMSโžœ pip install python-gammu
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting python-gammu
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.contrib.socks.SOCKSHTTPSConnection object at 0x75852c50>: Failed to establish a new connection: Connection closed unexpectedly',)': /simple/python-gammu/
  Using cached https://files.pythonhosted.org/packages/dd/87/4200dfd2a1276a590e01bd43ff3ab498831bdf382310d4ca4939c395d698/python-gammu-2.11.tar.gz
    Complete output from command python setup.py egg_info:
    Package gammu was not found in the pkg-config search path.
    Perhaps you should add the directory containing `gammu.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'gammu' found
    Package gammu-smsd was not found in the pkg-config search path.
    Perhaps you should add the directory containing `gammu-smsd.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'gammu-smsd' found
    Can not find supported Gammu version using pkg-config!

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 100 in /tmp/pip-install-dnq3x10a/python-gammu/

And, add GAMMU_PATH=/opt/gammu or GAMMU_PATH=/usr/bin/gammu prefix, I get this error:

(pisms) PiSMS  โžœ GAMMU_PATH=/opt/gammu pip install python-gammu
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting python-gammu
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.contrib.socks.SOCKSHTTPSConnection object at 0x75834c10>: Failed to establish a new connection: Connection closed unexpectedly',)': /simple/python-gammu/
  Using cached https://files.pythonhosted.org/packages/dd/87/4200dfd2a1276a590e01bd43ff3ab498831bdf382310d4ca4939c395d698/python-gammu-2.11.tar.gz
    Complete output from command python setup.py egg_info:
    Failed to find Gammu!
    Either it is not installed or not found.
    After install Gammu ensure that setup finds it by any of:
     * Specify path to it using GAMMU_PATH in environment.
     * Install pkg-config.

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 101 in /tmp/pip-install-sxcfez2j/python-gammu/

So, how can I fix this error?


BTW, If I install it in the main env, which is the default env of conda, seems OK.

Can create invalid unicode strings

Many phones use surrogates to encode higher plane unicode chars and this gets passed through Gammu and python-gammu to Python unicode string. The problem is that these are not allowed there, do doing something with such string ends up in:

UnicodeEncodeError: 'utf-8' codec can't encode character '\ud800' in position 10316: surrogates not allowed

There has to be some bug in the surrogate conversion code:

/* Convert string without zero at the end. */
*out_len = 0;
for (i = 0; i < len; i++) {
value = (src[2 * i] << 8) + src[(2 * i) + 1];
if (value >= 0xD800 && value <= 0xDBFF) {
second = src[(i + 1) * 2] * 256 + src[(i + 1) * 2 + 1];
if (second >= 0xDC00 && second <= 0xDFFF) {
value = ((value - 0xD800) << 10) + (second - 0xDC00) + 0x010000;
i++;
} else if (second == 0) {
/* Surrogate at the end of string */
value = 0xFFFD; /* REPLACEMENT CHARACTER */
}
}
dest[(*out_len)++] = value;
}

Or there is other way this can slip through. I've seen this in Text as returned by DecodePDU.

Debug behavior different between gammu cli and python gammu

Via python-gammu neither file target nor Python file object target in conjunction with debug loglevel "textalldate" is producing more output than the content in gammu-mario-python.txt.

dbgfile = open("/tmp/gammu-mario-python.txt", 'w')
gammu.SetDebugFile(dbgfile)
gammu.SetDebugLevel("textalldate")

Instead gammu cli is producing the full output as you can see in gammu-mario-cli.txt.

Had I overseen something? I've tried different settings, and of course configuring through gammu.conf.

Can't get USSD response

I am using gammu worker (version ('1.37.91', '2.7', '1.37.91')) and I want check balance, with
_worker.enqueue('DialService', {'Number': '*111#'})

But always:
-> DialService completed 100% with error ERR_TIMEOUT , return value:
None

Log: gsm.txt

In the log I have found out than modem received "AT+CUSD=0,"_111#",15"
I tried to send direct "AT+CUSD=0,"_111#",15" and receive only OK without balance status. Then I tried to send AT+CUSD=1,"*111#",15 and I saw balance status.

AT+CUSD cmd description:
.....
Defined values:
0 disable the result code presentation in the TA
1 enable the result code presentation in the TA
2 cancel session (not applicable to read command response)

So I think the problem in the incorrect CUSD parameter.

Could you please check it?

Thank you!

Charset forced to HEX when using worker

@nijel

I'm trying to send ussd codes, using a worker, but noticed that the charset choosen or set by gammu is HEX
Even though i have the features = USSD_GSM_CHARSET set in my config file.

Using the service_numbers.py example with my same config file, works perfectly. Charset is switched to GSM and the USSD is send and the response is as expected.

Any idea how i can instruct python-gammu to switch the modem to charset GSM in order for this to work ?

Im using a WAVECOM WMOD2 USB modem @9600 and a Huawei E153 @115200 both are forced to HEX charset

Below you can also see my log file.

Your help is really appreciated.

#######snip of the worker code##############

_sm = gammu.StateMachine()
_sm.ReadConfig(Filename=sys.argv[1])
_worker = gammu.worker.GammuWorker(_worker_callback)
_worker.configure(_sm.GetConfig())
_worker.initiate()

loops = 0
while not REPLY and loops < 10:
time.sleep(1)
if gsm_init:
#time.sleep(1)
_worker.enqueue('DialService', {'Number': '*129#'})
loops += 1

##############Log file#######################
Sun 2020/07/19 11:05:43: [Gammu - 1.41.0]
Sun 2020/07/19 11:05:43: [Connection - "at9600"]
Sun 2020/07/19 11:05:43: [Connection index - 0]
Sun 2020/07/19 11:05:43: [Model type - ""]
Sun 2020/07/19 11:05:43: [Device - "/dev/ttyUSB0"]
Sun 2020/07/19 11:05:43: [Running on - Linux, kernel 3.10.0-1127.13.1.el7.x86_64 (#1 SMP Tue Jun 23 15:46:38 UTC 2020)]
Sun 2020/07/19 11:05:43: Serial device: DTR is up, RTS is up, CAR is down, CTS is up
Sun 2020/07/19 11:05:43: Setting speed to 9600
Sun 2020/07/19 11:05:43: [Module - "auto"]
Sun 2020/07/19 11:05:43: Escaping SMS mode
Sun 2020/07/19 11:05:43: SENDING frame type 0x00/length 0x02/2
Sun 2020/07/19 11:05:43: 1B |0D ..
Sun 2020/07/19 11:05:43: Sending simple AT command to wake up some devices
Sun 2020/07/19 11:05:43: SENDING frame type 0x00/length 0x03/3
Sun 2020/07/19 11:05:43: 41A|54T|0D AT.
Sun 2020/07/19 11:05:44: 1 "AT"
Sun 2020/07/19 11:05:44: 2 "OK"
Sun 2020/07/19 11:05:44: Checking line: OK
Sun 2020/07/19 11:05:44: AT reply state: 1
Sun 2020/07/19 11:05:44: RECEIVED frame type 0x00/length 0x09/9
Sun 2020/07/19 11:05:44: 41A|54T|0D |0D |0A |4FO|4BK|0D |0A AT...OK..
Sun 2020/07/19 11:05:44: Enabling echo
Sun 2020/07/19 11:05:44: SENDING frame type 0x00/length 0x05/5
Sun 2020/07/19 11:05:44: 41A|54T|45E|311|0D ATE1.
Sun 2020/07/19 11:05:44: 1 "ATE1"
Sun 2020/07/19 11:05:44: 2 "OK"
Sun 2020/07/19 11:05:44: Checking line: OK
Sun 2020/07/19 11:05:44: AT reply state: 1
Sun 2020/07/19 11:05:44: RECEIVED frame type 0x00/length 0x0B/11
Sun 2020/07/19 11:05:44: 41A|54T|45E|311|0D |0D |0A |4FO|4BK|0D |0A ATE1...OK..
Sun 2020/07/19 11:05:44: Trying Motorola mode switch
Sun 2020/07/19 11:05:44: SENDING frame type 0x00/length 0x0A/10
Sun 2020/07/19 11:05:44: 41A|54T|2B+|4DM|4FO|44D|45E|3D=|322|0D AT+MODE=2.
Sun 2020/07/19 11:05:44: 1 "AT+MODE=2"
Sun 2020/07/19 11:05:44: 2 "ERROR"
Sun 2020/07/19 11:05:44: Checking line: ERROR
Sun 2020/07/19 11:05:44: AT reply state: 3
Sun 2020/07/19 11:05:44: RECEIVED frame type 0x00/length 0x13/19
Sun 2020/07/19 11:05:44: 41A|54T|2B+|4DM|4FO|44D|45E|3D=|322|0D |0D |0A |45E|52R|52R|4FO AT+MODE=2...ERRO
Sun 2020/07/19 11:05:44: 52R|0D |0A R..
Sun 2020/07/19 11:05:44: Seems not to be supported
Sun 2020/07/19 11:05:44: Enabling CME errors
Sun 2020/07/19 11:05:44: SENDING frame type 0x00/length 0x0A/10
Sun 2020/07/19 11:05:44: 41A|54T|2B+|43C|4DM|45E|45E|3D=|311|0D AT+CMEE=1.
Sun 2020/07/19 11:05:45: 1 "AT+CMEE=1"
Sun 2020/07/19 11:05:45: 2 "OK"
Sun 2020/07/19 11:05:45: Checking line: OK
Sun 2020/07/19 11:05:45: AT reply state: 1
Sun 2020/07/19 11:05:45: RECEIVED frame type 0x00/length 0x10/16
Sun 2020/07/19 11:05:45: 41A|54T|2B+|43C|4DM|45E|45E|3D=|311|0D |0D |0A |4FO|4BK|0D |0A AT+CMEE=1...OK..
Sun 2020/07/19 11:05:45: SENDING frame type 0x00/length 0x09/9
Sun 2020/07/19 11:05:45: 41A|54T|2B+|43C|53S|43C|53S|3F?|0D AT+CSCS?.
Sun 2020/07/19 11:05:45: 1 "AT+CSCS?"
Sun 2020/07/19 11:05:45: 2 "+CSCS: "HEX""
Sun 2020/07/19 11:05:45: 3 "OK"
Sun 2020/07/19 11:05:45: Checking line: OK
Sun 2020/07/19 11:05:45: AT reply state: 1
Sun 2020/07/19 11:05:45: RECEIVED frame type 0x00/length 0x1F/31
Sun 2020/07/19 11:05:45: 41A|54T|2B+|43C|53S|43C|53S|3F?|0D |0D |0A |2B+|43C|53S|43C|53S AT+CSCS?...+CSCS
Sun 2020/07/19 11:05:45: 3A:|20 |22"|48H|45E|58X|22"|0D |0A |0D |0A |4FO|4BK|0D |0A : "HEX"....OK..
Sun 2020/07/19 11:05:45: SENDING frame type 0x00/length 0x0A/10
Sun 2020/07/19 11:05:45: 41A|54T|2B+|43C|53S|43C|53S|3D=|3F?|0D AT+CSCS=?.
Sun 2020/07/19 11:05:46: 1 "AT+CSCS=?"
Sun 2020/07/19 11:05:46: 2 "+CSCS: ("GSM","PCCP437","CUSTOM","HEX")"
Sun 2020/07/19 11:05:46: 3 "OK"
Sun 2020/07/19 11:05:46: Checking line: OK
Sun 2020/07/19 11:05:46: AT reply state: 1
Sun 2020/07/19 11:05:46: RECEIVED frame type 0x00/length 0x3B/59
Sun 2020/07/19 11:05:46: 41A|54T|2B+|43C|53S|43C|53S|3D=|3F?|0D |0D |0A |2B+|43C|53S|43C AT+CSCS=?...+CSC
Sun 2020/07/19 11:05:46: 53S|3A:|20 |28(|22"|47G|53S|4DM|22"|2C,|22"|50P|43C|43C|50P|344 S: ("GSM","PCCP4
Sun 2020/07/19 11:05:46: 333|377|22"|2C,|22"|43C|55U|53S|54T|4FO|4DM|22"|2C,|22"|48H|45E 37","CUSTOM","HE
Sun 2020/07/19 11:05:46: 58X|22"|29)|0D |0A |0D |0A |4FO|4BK|0D |0A X")....OK..
Sun 2020/07/19 11:05:46: Chosen HEX as normal charset
Sun 2020/07/19 11:05:46: Getting model
Sun 2020/07/19 11:05:46: SENDING frame type 0x00/length 0x08/8
Sun 2020/07/19 11:05:46: 41A|54T|2B+|43C|47G|4DM|4DM|0D AT+CGMM.
Sun 2020/07/19 11:05:46: 1 "AT+CGMM"
Sun 2020/07/19 11:05:46: 2 " MULTIBAND 900E 1800 "
Sun 2020/07/19 11:05:46: 3 "OK"
Sun 2020/07/19 11:05:46: Checking line: OK
Sun 2020/07/19 11:05:46: AT reply state: 1
Sun 2020/07/19 11:05:46: RECEIVED frame type 0x00/length 0x29/41
Sun 2020/07/19 11:05:46: 41A|54T|2B+|43C|47G|4DM|4DM|0D |0D |0A |20 |4DM|55U|4CL|54T|49I AT+CGMM... MULTI
Sun 2020/07/19 11:05:46: 42B|41A|4EN|44D|20 |20 |399|300|300|45E|20 |20 |311|388|300|300 BAND 900E 1800
Sun 2020/07/19 11:05:46: 20 |0D |0A |0D |0A |4FO|4BK|0D |0A ....OK..
Sun 2020/07/19 11:05:46: [Model name: MULTIBAND 900E 1800'] Sun 2020/07/19 11:05:46: [Model data: MULTIBAND 900E 1800']
Sun 2020/07/19 11:05:46: [Model data: `MULTIBAND 900E 1800']
Sun 2020/07/19 11:05:46: [Connected model - "MULTIBAND 900E 1800"]
Sun 2020/07/19 11:05:46: SENDING frame type 0x00/length 0x08/8
Sun 2020/07/19 11:05:46: 41A|54T|2B+|43C|47G|4DM|49I|0D AT+CGMI.
Sun 2020/07/19 11:05:46: 1 "AT+CGMI"
Sun 2020/07/19 11:05:46: 2 " WAVECOM MODEM"
Sun 2020/07/19 11:05:46: 3 "OK"
Sun 2020/07/19 11:05:46: Checking line: OK
Sun 2020/07/19 11:05:46: AT reply state: 1
Sun 2020/07/19 11:05:46: RECEIVED frame type 0x00/length 0x20/32
Sun 2020/07/19 11:05:46: 41A|54T|2B+|43C|47G|4DM|49I|0D |0D |0A |20 |57W|41A|56V|45E|43C AT+CGMI... WAVEC
Sun 2020/07/19 11:05:46: 4FO|4DM|20 |4DM|4FO|44D|45E|4DM|0D |0A |0D |0A |4FO|4BK|0D |0A OM MODEM....OK..
Sun 2020/07/19 11:05:46: Manufacturer info received
Sun 2020/07/19 11:05:46: [Manufacturer: Wavecom]
Sun 2020/07/19 11:05:46: Checking for OBEX support
Sun 2020/07/19 11:05:46: SENDING frame type 0x00/length 0x0B/11
Sun 2020/07/19 11:05:46: 41A|54T|2B+|43C|50P|52R|4FO|54T|3D=|3F?|0D AT+CPROT=?.
Sun 2020/07/19 11:05:46: 1 "AT+CPROT=?"
Sun 2020/07/19 11:05:46: 2 "ERROR"
Sun 2020/07/19 11:05:46: Checking line: ERROR
Sun 2020/07/19 11:05:46: AT reply state: 3
Sun 2020/07/19 11:05:46: RECEIVED frame type 0x00/length 0x14/20
Sun 2020/07/19 11:05:46: 41A|54T|2B+|43C|50P|52R|4FO|54T|3D=|3F?|0D |0D |0A |45E|52R|52R AT+CPROT=?...ERR
Sun 2020/07/19 11:05:46: 4FO|52R|0D |0A OR..
Sun 2020/07/19 11:05:46: Checking for SYNCML/OBEX support
Sun 2020/07/19 11:05:46: SENDING frame type 0x00/length 0x0C/12
Sun 2020/07/19 11:05:46: 41A|54T|2B+|53S|59Y|4EN|43C|4DM|4CL|3D=|3F?|0D AT+SYNCML=?.
Sun 2020/07/19 11:05:46: 1 "AT+SYNCML=?"
Sun 2020/07/19 11:05:46: 2 "ERROR"
Sun 2020/07/19 11:05:46: Checking line: ERROR
Sun 2020/07/19 11:05:46: AT reply state: 3
Sun 2020/07/19 11:05:46: RECEIVED frame type 0x00/length 0x15/21
Sun 2020/07/19 11:05:46: 41A|54T|2B+|53S|59Y|4EN|43C|4DM|4CL|3D=|3F?|0D |0D |0A |45E|52R AT+SYNCML=?...ER
Sun 2020/07/19 11:05:46: 52R|4FO|52R|0D |0A ROR..
Sun 2020/07/19 11:05:46: SENDING frame type 0x00/length 0x0D/13
Sun 2020/07/19 11:05:46: 41A|54T|24$|54T|53S|53S|50P|43C|53S|57W|3D=|3F?|0D AT$TSSPCSW=?.
Sun 2020/07/19 11:05:46: 1 "AT$TSSPCSW=?"
Sun 2020/07/19 11:05:46: 2 "ERROR"
Sun 2020/07/19 11:05:46: Checking line: ERROR
Sun 2020/07/19 11:05:46: AT reply state: 3
Sun 2020/07/19 11:05:46: RECEIVED frame type 0x00/length 0x16/22
Sun 2020/07/19 11:05:46: 41A|54T|24$|54T|53S|53S|50P|43C|53S|57W|3D=|3F?|0D |0D |0A |45E AT$TSSPCSW=?...E
Sun 2020/07/19 11:05:46: 52R|52R|4FO|52R|0D |0A RROR..
Sun 2020/07/19 11:05:46: SENDING frame type 0x00/length 0x0A/10
Sun 2020/07/19 11:05:46: 41A|54T|2B+|43C|48H|55U|50P|3D=|3F?|0D AT+CHUP=?.
Sun 2020/07/19 11:05:46: 1 "AT+CHUP=?"
Sun 2020/07/19 11:05:46: 2 "OK"
Sun 2020/07/19 11:05:46: Checking line: OK
Sun 2020/07/19 11:05:46: AT reply state: 1
Sun 2020/07/19 11:05:46: RECEIVED frame type 0x00/length 0x10/16
Sun 2020/07/19 11:05:46: 41A|54T|2B+|43C|48H|55U|50P|3D=|3F?|0D |0D |0A |4FO|4BK|0D |0A AT+CHUP=?...OK..
Sun 2020/07/19 11:05:46: [Module - "A2D|iPAQ|at|M20|S25|MC35|TC35|C35i|S65|S300|5110|5130|5190|5210|6110|6130|6150|6190|6210|6250|6310|6310i|6510|7110|8210|8250|8290|8310|8390|8850|8855|8890|8910|9110|9210"]
Sun 2020/07/19 11:05:46: Escaping SMS mode
Sun 2020/07/19 11:05:46: SENDING frame type 0x00/length 0x02/2
Sun 2020/07/19 11:05:46: 1B |0D ..
Sun 2020/07/19 11:05:46: Sending simple AT command to wake up some devices
Sun 2020/07/19 11:05:46: SENDING frame type 0x00/length 0x03/3
Sun 2020/07/19 11:05:46: 41A|54T|0D AT.
Sun 2020/07/19 11:05:46: 1 "AT"
Sun 2020/07/19 11:05:46: 2 "OK"
Sun 2020/07/19 11:05:46: Checking line: OK
Sun 2020/07/19 11:05:46: AT reply state: 1
Sun 2020/07/19 11:05:46: RECEIVED frame type 0x00/length 0x09/9
Sun 2020/07/19 11:05:46: 41A|54T|0D |0D |0A |4FO|4BK|0D |0A AT...OK..
Sun 2020/07/19 11:05:46: Enabling echo
Sun 2020/07/19 11:05:46: SENDING frame type 0x00/length 0x05/5
Sun 2020/07/19 11:05:46: 41A|54T|45E|311|0D ATE1.
Sun 2020/07/19 11:05:47: 1 "ATE1"
Sun 2020/07/19 11:05:47: 2 "OK"
Sun 2020/07/19 11:05:47: Checking line: OK
Sun 2020/07/19 11:05:47: AT reply state: 1
Sun 2020/07/19 11:05:47: RECEIVED frame type 0x00/length 0x0B/11
Sun 2020/07/19 11:05:47: 41A|54T|45E|311|0D |0D |0A |4FO|4BK|0D |0A ATE1...OK..
Sun 2020/07/19 11:05:47: Trying Motorola mode switch
Sun 2020/07/19 11:05:47: SENDING frame type 0x00/length 0x0A/10
Sun 2020/07/19 11:05:47: 41A|54T|2B+|4DM|4FO|44D|45E|3D=|322|0D AT+MODE=2.
Sun 2020/07/19 11:05:47: 1 "AT+MODE=2"
Sun 2020/07/19 11:05:47: 2 "ERROR"
Sun 2020/07/19 11:05:47: Checking line: ERROR
Sun 2020/07/19 11:05:47: AT reply state: 3
Sun 2020/07/19 11:05:47: RECEIVED frame type 0x00/length 0x13/19
Sun 2020/07/19 11:05:47: 41A|54T|2B+|4DM|4FO|44D|45E|3D=|322|0D |0D |0A |45E|52R|52R|4FO AT+MODE=2...ERRO
Sun 2020/07/19 11:05:47: 52R|0D |0A R..
Sun 2020/07/19 11:05:47: Seems not to be supported
Sun 2020/07/19 11:05:47: Enabling CME errors
Sun 2020/07/19 11:05:47: SENDING frame type 0x00/length 0x0A/10
Sun 2020/07/19 11:05:47: 41A|54T|2B+|43C|4DM|45E|45E|3D=|311|0D AT+CMEE=1.
Sun 2020/07/19 11:05:47: 1 "AT+CMEE=1"
Sun 2020/07/19 11:05:47: 2 "OK"
Sun 2020/07/19 11:05:47: Checking line: OK
Sun 2020/07/19 11:05:47: AT reply state: 1
Sun 2020/07/19 11:05:47: RECEIVED frame type 0x00/length 0x10/16
Sun 2020/07/19 11:05:47: 41A|54T|2B+|43C|4DM|45E|45E|3D=|311|0D |0D |0A |4FO|4BK|0D |0A AT+CMEE=1...OK..
Sun 2020/07/19 11:05:47: SENDING frame type 0x00/length 0x09/9
Sun 2020/07/19 11:05:47: 41A|54T|2B+|43C|53S|43C|53S|3F?|0D AT+CSCS?.
Sun 2020/07/19 11:05:47: 1 "AT+CSCS?"
Sun 2020/07/19 11:05:47: 2 "+CSCS: "HEX""
Sun 2020/07/19 11:05:47: 3 "OK"
Sun 2020/07/19 11:05:47: Checking line: OK
Sun 2020/07/19 11:05:47: AT reply state: 1
Sun 2020/07/19 11:05:47: RECEIVED frame type 0x00/length 0x1F/31
Sun 2020/07/19 11:05:47: 41A|54T|2B+|43C|53S|43C|53S|3F?|0D |0D |0A |2B+|43C|53S|43C|53S AT+CSCS?...+CSCS
Sun 2020/07/19 11:05:47: 3A:|20 |22"|48H|45E|58X|22"|0D |0A |0D |0A |4FO|4BK|0D |0A : "HEX"....OK..
Sun 2020/07/19 11:05:47: SENDING frame type 0x00/length 0x0A/10
Sun 2020/07/19 11:05:47: 41A|54T|2B+|43C|53S|43C|53S|3D=|3F?|0D AT+CSCS=?.
Sun 2020/07/19 11:05:47: 1 "AT+CSCS=?"
Sun 2020/07/19 11:05:47: 2 "+CSCS: ("GSM","PCCP437","CUSTOM","HEX")"
Sun 2020/07/19 11:05:47: 3 "OK"
Sun 2020/07/19 11:05:47: Checking line: OK
Sun 2020/07/19 11:05:47: AT reply state: 1
Sun 2020/07/19 11:05:47: RECEIVED frame type 0x00/length 0x3B/59
Sun 2020/07/19 11:05:47: 41A|54T|2B+|43C|53S|43C|53S|3D=|3F?|0D |0D |0A |2B+|43C|53S|43C AT+CSCS=?...+CSC
Sun 2020/07/19 11:05:47: 53S|3A:|20 |28(|22"|47G|53S|4DM|22"|2C,|22"|50P|43C|43C|50P|344 S: ("GSM","PCCP4
Sun 2020/07/19 11:05:47: 333|377|22"|2C,|22"|43C|55U|53S|54T|4FO|4DM|22"|2C,|22"|48H|45E 37","CUSTOM","HE
Sun 2020/07/19 11:05:47: 58X|22"|29)|0D |0A |0D |0A |4FO|4BK|0D |0A X")....OK..
Sun 2020/07/19 11:05:47: Chosen HEX as normal charset
Sun 2020/07/19 11:05:47: SENDING frame type 0x00/length 0x08/8
Sun 2020/07/19 11:05:47: 41A|54T|2B+|43C|47G|4DM|49I|0D AT+CGMI.
Sun 2020/07/19 11:05:47: 1 "AT+CGMI"
Sun 2020/07/19 11:05:47: 2 " WAVECOM MODEM"
Sun 2020/07/19 11:05:47: 3 "OK"
Sun 2020/07/19 11:05:47: Checking line: OK
Sun 2020/07/19 11:05:47: AT reply state: 1
Sun 2020/07/19 11:05:47: RECEIVED frame type 0x00/length 0x20/32
Sun 2020/07/19 11:05:47: 41A|54T|2B+|43C|47G|4DM|49I|0D |0D |0A |20 |57W|41A|56V|45E|43C AT+CGMI... WAVEC
Sun 2020/07/19 11:05:47: 4FO|4DM|20 |4DM|4FO|44D|45E|4DM|0D |0A |0D |0A |4FO|4BK|0D |0A OM MODEM....OK..
Sun 2020/07/19 11:05:47: Manufacturer info received
Sun 2020/07/19 11:05:47: [Manufacturer: Wavecom]
Sun 2020/07/19 11:05:47: Checking for OBEX support
Sun 2020/07/19 11:05:47: SENDING frame type 0x00/length 0x0B/11
Sun 2020/07/19 11:05:47: 41A|54T|2B+|43C|50P|52R|4FO|54T|3D=|3F?|0D AT+CPROT=?.
Sun 2020/07/19 11:05:47: 1 "AT+CPROT=?"
Sun 2020/07/19 11:05:47: 2 "ERROR"
Sun 2020/07/19 11:05:47: Checking line: ERROR
Sun 2020/07/19 11:05:47: AT reply state: 3
Sun 2020/07/19 11:05:47: RECEIVED frame type 0x00/length 0x14/20
Sun 2020/07/19 11:05:47: 41A|54T|2B+|43C|50P|52R|4FO|54T|3D=|3F?|0D |0D |0A |45E|52R|52R AT+CPROT=?...ERR
Sun 2020/07/19 11:05:47: 4FO|52R|0D |0A OR..
Sun 2020/07/19 11:05:47: Checking for SYNCML/OBEX support
Sun 2020/07/19 11:05:47: SENDING frame type 0x00/length 0x0C/12
Sun 2020/07/19 11:05:47: 41A|54T|2B+|53S|59Y|4EN|43C|4DM|4CL|3D=|3F?|0D AT+SYNCML=?.
Sun 2020/07/19 11:05:47: 1 "AT+SYNCML=?"
Sun 2020/07/19 11:05:47: 2 "ERROR"
Sun 2020/07/19 11:05:47: Checking line: ERROR
Sun 2020/07/19 11:05:47: AT reply state: 3
Sun 2020/07/19 11:05:47: RECEIVED frame type 0x00/length 0x15/21
Sun 2020/07/19 11:05:47: 41A|54T|2B+|53S|59Y|4EN|43C|4DM|4CL|3D=|3F?|0D |0D |0A |45E|52R AT+SYNCML=?...ER
Sun 2020/07/19 11:05:47: 52R|4FO|52R|0D |0A ROR..
Sun 2020/07/19 11:05:47: SENDING frame type 0x00/length 0x0D/13
Sun 2020/07/19 11:05:47: 41A|54T|24$|54T|53S|53S|50P|43C|53S|57W|3D=|3F?|0D AT$TSSPCSW=?.
Sun 2020/07/19 11:05:47: 1 "AT$TSSPCSW=?"
Sun 2020/07/19 11:05:47: 2 "ERROR"
Sun 2020/07/19 11:05:47: Checking line: ERROR
Sun 2020/07/19 11:05:47: AT reply state: 3
Sun 2020/07/19 11:05:47: RECEIVED frame type 0x00/length 0x16/22
Sun 2020/07/19 11:05:47: 41A|54T|24$|54T|53S|53S|50P|43C|53S|57W|3D=|3F?|0D |0D |0A |45E AT$TSSPCSW=?...E
Sun 2020/07/19 11:05:47: 52R|52R|4FO|52R|0D |0A RROR..
Sun 2020/07/19 11:05:47: SENDING frame type 0x00/length 0x0A/10
Sun 2020/07/19 11:05:47: 41A|54T|2B+|43C|48H|55U|50P|3D=|3F?|0D AT+CHUP=?.
Sun 2020/07/19 11:05:47: 1 "AT+CHUP=?"
Sun 2020/07/19 11:05:47: 2 "OK"
Sun 2020/07/19 11:05:47: Checking line: OK
Sun 2020/07/19 11:05:47: AT reply state: 1
Sun 2020/07/19 11:05:47: RECEIVED frame type 0x00/length 0x10/16
Sun 2020/07/19 11:05:47: 41A|54T|2B+|43C|48H|55U|50P|3D=|3F?|0D |0D |0A |4FO|4BK|0D |0A AT+CHUP=?...OK..
Sun 2020/07/19 11:05:47: Setting date & time
Sun 2020/07/19 11:05:47: SENDING frame type 0x00/length 0x1F/31
Sun 2020/07/19 11:05:47: 41A|54T|2B+|43C|43C|4CL|4BK|3D=|22"|322|300|2F/|300|377|2F/|311 AT+CCLK="20/07/1
Sun 2020/07/19 11:05:47: 399|2C,|311|311|3A:|300|355|3A:|344|377|2D-|300|333|22"|0D 9,11:05:47-03".
Sun 2020/07/19 11:05:47: 1 "AT+CCLK="20/07/19,11:05:47-03""
Sun 2020/07/19 11:05:47: 2 "+CME ERROR: 3"
Sun 2020/07/19 11:05:47: Checking line: +CME ERROR: 3
Sun 2020/07/19 11:05:47: AT reply state: 6
Sun 2020/07/19 11:05:47: RECEIVED frame type 0x00/length 0x30/48
Sun 2020/07/19 11:05:47: 41A|54T|2B+|43C|43C|4CL|4BK|3D=|22"|322|300|2F/|300|377|2F/|311 AT+CCLK="20/07/1
Sun 2020/07/19 11:05:47: 399|2C,|311|311|3A:|300|355|3A:|344|377|2D-|300|333|22"|0D |0D 9,11:05:47-03"..
Sun 2020/07/19 11:05:47: 0A |2B+|43C|4DM|45E|20 |45E|52R|52R|4FO|52R|3A:|20 |333|0D |0A .+CME ERROR: 3..
Sun 2020/07/19 11:05:47: CME Error 3: "operation not allowed"
Sun 2020/07/19 11:05:47: Getting firmware versions
Sun 2020/07/19 11:05:47: SENDING frame type 0x00/length 0x08/8
Sun 2020/07/19 11:05:47: 41A|54T|2B+|43C|47G|4DM|52R|0D AT+CGMR.
Sun 2020/07/19 11:05:48: 1 "AT+CGMR"
Sun 2020/07/19 11:05:48: 2 "430d09gm.2C 1208564 012102 12:43"
Sun 2020/07/19 11:05:48: 3 "OK"
Sun 2020/07/19 11:05:48: Checking line: OK
Sun 2020/07/19 11:05:48: AT reply state: 1
Sun 2020/07/19 11:05:48: RECEIVED frame type 0x00/length 0x32/50
Sun 2020/07/19 11:05:48: 41A|54T|2B+|43C|47G|4DM|52R|0D |0D |0A |344|333|300|64d|300|399 AT+CGMR...430d09
Sun 2020/07/19 11:05:48: 67g|6Dm|2E.|322|43C|20 |311|322|300|388|355|366|344|20 |300|311 gm.2C 1208564 01
Sun 2020/07/19 11:05:48: 322|311|300|322|20 |311|322|3A:|344|333|0D |0A |0D |0A |4FO|4BK 2102 12:43....OK
Sun 2020/07/19 11:05:48: 0D |0A ..
Sun 2020/07/19 11:05:48: Received firmware version: "430d09gm.2C 1208564 012102 12:43"
Sun 2020/07/19 11:05:48: Number version is "43009.212086"
Sun 2020/07/19 11:05:48: [Firmware version - "430d09gm.2C 1208564 012102 12:43"]
Sun 2020/07/19 11:05:48: [Connected]
Sun 2020/07/19 11:05:48: Entering GSM_SetIncomingUSSD
Sun 2020/07/19 11:05:48: Enabling incoming USSD
Sun 2020/07/19 11:05:48: SENDING frame type 0x00/length 0x0A/10
Sun 2020/07/19 11:05:48: 41A|54T|2B+|43C|55U|53S|44D|3D=|311|0D AT+CUSD=1.
Sun 2020/07/19 11:05:48: 1 "AT+CUSD=1"
Sun 2020/07/19 11:05:48: 2 "OK"
Sun 2020/07/19 11:05:48: Checking line: OK
Sun 2020/07/19 11:05:48: AT reply state: 1
Sun 2020/07/19 11:05:48: RECEIVED frame type 0x00/length 0x10/16
Sun 2020/07/19 11:05:48: 41A|54T|2B+|43C|55U|53S|44D|3D=|311|0D |0D |0A |4FO|4BK|0D |0A AT+CUSD=1...OK..
Sun 2020/07/19 11:05:48: Leaving GSM_SetIncomingUSSD
Sun 2020/07/19 11:05:49: Entering GSM_DialService
Sun 2020/07/19 11:05:49: SENDING frame type 0x00/length 0x1A/26
Sun 2020/07/19 11:05:49: 41A|54T|2B+|43C|55U|53S|44D|3D=|311|2C,|22"|322|41A|333|311|333 AT+CUSD=1,"2A313
Sun 2020/07/19 11:05:49: 322|333|399|322|333|22"|2C,|311|355|0D 23923",15.
Sun 2020/07/19 11:05:49: 1 "AT+CUSD=1,"2A31323923",15"
Sun 2020/07/19 11:05:49: 2 "OK"
Sun 2020/07/19 11:05:49: Checking line: OK
Sun 2020/07/19 11:05:49: AT reply state: 1
Sun 2020/07/19 11:05:49: RECEIVED frame type 0x00/length 0x20/32
Sun 2020/07/19 11:05:49: 41A|54T|2B+|43C|55U|53S|44D|3D=|311|2C,|22"|322|41A|333|311|333 AT+CUSD=1,"2A313
Sun 2020/07/19 11:05:49: 322|333|399|322|333|22"|2C,|311|355|0D |0D |0A |4FO|4BK|0D |0A 23923",15...OK..
Sun 2020/07/19 11:05:49: Leaving GSM_DialService
Sun 2020/07/19 11:05:50: Entering GSM_DialService
Sun 2020/07/19 11:05:50: SENDING frame type 0x00/length 0x1A/26
Sun 2020/07/19 11:05:50: 41A|54T|2B+|43C|55U|53S|44D|3D=|311|2C,|22"|322|41A|333|311|333 AT+CUSD=1,"2A313
Sun 2020/07/19 11:05:50: 322|333|399|322|333|22"|2C,|311|355|0D 23923",15.
Sun 2020/07/19 11:05:50: 1 "AT+CUSD=1,"2A31323923",15"
Sun 2020/07/19 11:05:50: 2 "OK"
Sun 2020/07/19 11:05:50: Checking line: OK
Sun 2020/07/19 11:05:50: AT reply state: 1
Sun 2020/07/19 11:05:50: RECEIVED frame type 0x00/length 0x20/32
Sun 2020/07/19 11:05:50: 41A|54T|2B+|43C|55U|53S|44D|3D=|311|2C,|22"|322|41A|333|311|333 AT+CUSD=1,"2A313
Sun 2020/07/19 11:05:50: 322|333|399|322|333|22"|2C,|311|355|0D |0D |0A |4FO|4BK|0D |0A 23923",15...OK..
Sun 2020/07/19 11:05:50: Leaving GSM_DialService
Sun 2020/07/19 11:05:51: Entering GSM_DialService
Sun 2020/07/19 11:05:51: SENDING frame type 0x00/length 0x1A/26
Sun 2020/07/19 11:05:51: 41A|54T|2B+|43C|55U|53S|44D|3D=|311|2C,|22"|322|41A|333|311|333 AT+CUSD=1,"2A313
Sun 2020/07/19 11:05:51: 322|333|399|322|333|22"|2C,|311|355|0D 23923",15.
Sun 2020/07/19 11:05:51: 1 "+CUSD: 4"
Sun 2020/07/19 11:05:51: Checking line: +CUSD: 4
Sun 2020/07/19 11:05:51: AT reply state: 4
Sun 2020/07/19 11:05:51: RECEIVED frame type 0x00/length 0x0A/10
Sun 2020/07/19 11:05:51: 2B+|43C|55U|53S|44D|3A:|20 |344|0D |0A +CUSD: 4..
Sun 2020/07/19 11:05:51: Incoming USSD received
Sun 2020/07/19 11:05:51: Parsing +CUSD: 4
Sun 2020/07/19 11:05:51: with +CUSD: @i @0
Sun 2020/07/19 11:05:51: Parsed int 4
Sun 2020/07/19 11:05:51: Status: 4
Sun 2020/07/19 11:05:51: 1 "+CUSD: 4"
Sun 2020/07/19 11:05:51: Checking line: +CUSD: 4
Sun 2020/07/19 11:05:51: AT reply state: 4
Sun 2020/07/19 11:05:51: RECEIVED frame type 0x00/length 0x0A/10
Sun 2020/07/19 11:05:51: 2B+|43C|55U|53S|44D|3A:|20 |344|0D |0A +CUSD: 4..
Sun 2020/07/19 11:05:51: Incoming USSD received
Sun 2020/07/19 11:05:51: Parsing +CUSD: 4
Sun 2020/07/19 11:05:51: with +CUSD: @i @0
Sun 2020/07/19 11:05:51: Parsed int 4
Sun 2020/07/19 11:05:51: Status: 4
Sun 2020/07/19 11:05:51: 1 "AT+CUSD=1,"2A31323923",15"
Sun 2020/07/19 11:05:51: 2 "OK"
Sun 2020/07/19 11:05:51: Checking line: OK
Sun 2020/07/19 11:05:51: AT reply state: 1
Sun 2020/07/19 11:05:51: RECEIVED frame type 0x00/length 0x20/32
Sun 2020/07/19 11:05:51: 41A|54T|2B+|43C|55U|53S|44D|3D=|311|2C,|22"|322|41A|333|311|333 AT+CUSD=1,"2A313
Sun 2020/07/19 11:05:51: 322|333|399|322|333|22"|2C,|311|355|0D |0D |0A |4FO|4BK|0D |0A 23923",15...OK..
Sun 2020/07/19 11:05:51: Leaving GSM_DialService
Sun 2020/07/19 11:05:52: Entering GSM_DialService
Sun 2020/07/19 11:05:52: SENDING frame type 0x00/length 0x1A/26
Sun 2020/07/19 11:05:52: 41A|54T|2B+|43C|55U|53S|44D|3D=|311|2C,|22"|322|41A|333|311|333 AT+CUSD=1,"2A313
Sun 2020/07/19 11:05:52: 322|333|399|322|333|22"|2C,|311|355|0D 23923",15.
Sun 2020/07/19 11:05:52: 1 "AT+CUSD=1,"2A31323923",15"
Sun 2020/07/19 11:05:52: 2 "OK"
Sun 2020/07/19 11:05:52: Checking line: OK
Sun 2020/07/19 11:05:52: AT reply state: 1
Sun 2020/07/19 11:05:52: RECEIVED frame type 0x00/length 0x20/32
Sun 2020/07/19 11:05:52: 41A|54T|2B+|43C|55U|53S|44D|3D=|311|2C,|22"|322|41A|333|311|333 AT+CUSD=1,"2A313
Sun 2020/07/19 11:05:52: 322|333|399|322|333|22"|2C,|311|355|0D |0D |0A |4FO|4BK|0D |0A 23923",15...OK..
Sun 2020/07/19 11:05:52: Leaving GSM_DialService

call method for python

Is it posible to implement call functionality for python api?
This would be a big improvement for self developped sms gateways.

Kind regards,
Thomas

If SMSD is not running, calls to InjectSMS and GetStatus cause python to quit

To replicate:

  1. Install gammu-smsd (and gammu if needed)
  2. Install or compile the binary distribution of python-gammu
  3. Prepare a working gammu-smsdrc -file (depending on the distro)
  4. Run the following python code
import gammu
smsd = gammu.SMSD('/path/to/gammu-smsdrc')
smsd.GetStatus()
# Or alternatively, attempt to send an SMS
smsd.InjectSMS([ {
    'Text': 'This is a test',
    'SMSC': {'Location': 1},
    'Number': '+1555123456'
}])

Expected results: python-gammu raises an exception or returns an appropriate error value.
Actual results: the python interpreter exits. See below:

~ # ipython
Python 3.6.3 (default, Nov 21 2017, 14:55:19) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.4.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import gammu

In [2]: smsd = gammu.SMSD('/etc/gammu-smsdrc')

In [3]: smsd.GetStatus()
python-gammu[1065]: Failed to allocate shared memory segment!, Error 2: No such file or directory

~ #
# Exit code is 255

OS: Alpine Linux 3.7
Gammu SMSD version: 1.38.5
python-gammu version: 2.11 (installed from source via pip)
Python version: 3.6.3

This is particularly annoying, since gammu.SMSD.Shutdown() raises an exception (ERR_NOTRUNNING) which is catchable. In the use case here, we cannot assume the SMSD is always running, thus GetStatus should indicate that without causing the whole program to quit.

The issue also occurs if the SHM is not accessible due to permissions, then the error returned is python-gammu[11522]: Failed to map shared memory segment!, Error 13: Permission denied.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Catching gammu.ERR_DEVICENOTEXIST

Hi,

except gammu.ERR_DEVICENOTEXIST as e:
  print "Cannot open modem: {error}".format(error=e)

Returns:

Cannot open modem: {'Text': "Error opening device, it doesn't exist.", 'Code': 4, 'Where': 'Init'}

I tried to use e.Text and e['Text'], but both seem not to work. How can I get the text from the exception? Or let the exception print only the text without other fields..

Delete only one SMS

The command line gammu deleteallsms works but, I can not do it directly in my python code, and that's the problem, because it's an robot which responds automatically, and when sim is full the robot cannot do anymore it's job! If I interrupt the process to launch the os gammu deleteallsms command line, I risk to lose an arriving message. I would have preferred to delete the SMS one by one.

[2020-07-04 22:02:01,095] ERROR in app: Exception on /sms [DELETE]
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.7/dist-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functionsrule.endpoint
File "/usr/local/lib/python3.7/dist-packages/flask_restful/init.py", line 468, in wrapper
resp = resource(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/flask/views.py", line 89, in view
return self.dispatch_request(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/flask_restful/init.py", line 583, in dispatch_request
resp = meth(*args, **kwargs)
File "./run.py", line 55, in delete
return machine.DeleteSMS(Folder=int(args['folder']),Location=int(args['location']))
gammu.ERR_MEMORY_NOT_AVAILABLE: {'Text': 'The type of memory is not available or has been disabled.', 'Where': 'DeleteSMS', 'Code': 81}
192.168.1.10 - - [04/Jul/2020 22:02:01] "DELETE /sms HTTP/1.1" 500 -

System: Raspbian GNU/Linux 10 (buster) 4.19.118-v7+ #1311 SMP Mon Apr 27 14:21:24 BST 2020 armv7l GNU/Linux
Python 3.7.3 / python-gammu 3.0

IncomingCallback doesn't call, when gammu inside a thread

I am developing app with multithreading. I created the thread for gammu, when I use gammu inside the thread, IncomingCallback doesn't call. When I use without thread all ok.
gammu version: ('1.33.0', '2.6', '1.37.4')

import gammu
import time
import threading


class GsmThread():
    def __init__(self):
        self.thread = threading.Thread(target=self._run, args=())
        self.sm = None
        self._gsm_config = {
            'StartInfo': True,
            'UseGlobalDebugFile': True,
            'DebugFile': None,
            'SyncTime': True,
            'Connection': 'at115200',
            'LockDevice': True,
            'DebugLevel': 'textalldate',
            'Device': '/dev/ttyUSB0',
            'Model': '',
        }

    def callback(self, sm, type, data):
        '''
        This callback receives notification about incoming event.
        @param sm: state machine which invoked action
        @type sm: gammu.StateMachine
        @param type: type of action, one of Call, SMS, CB, USSD
        @type type: string
        @param data: event data
        @type data: hash
        '''
        print 'Received incoming event type %s, data:' % type
        print data

    def _init(self):
        print gammu.Version()
        self.sm = gammu.StateMachine()
        try:
            self.sm.SetConfig(0, self._gsm_config)
            self.sm.Init()
            self.sm.SetIncomingCallback(self.callback)

            netinfo = self.sm.GetNetworkInfo()
            print 'Network name: %s' % netinfo['NetworkName']
            print 'Network code: %s' % netinfo['NetworkCode']
            print 'LAC: %s' % netinfo['LAC']
            print 'CID: %s' % netinfo['CID']

            # Enable notifications from calls
            try:
                self.sm.SetIncomingCall()
            except gammu.ERR_NOTSUPPORTED:
                print 'Incoming calls notification is not supported.'

            # Enable notifications from cell broadcast
            try:
                self.sm.SetIncomingCB()
            except gammu.ERR_NOTSUPPORTED:
                print 'Incoming CB notification is not supported.'
            except gammu.ERR_SOURCENOTAVAILABLE:
                print 'Cell broadcasts support not enabled in Gammu.'

            # Enable notifications from incoming SMS
            try:
                self.sm.SetIncomingSMS()
            except gammu.ERR_NOTSUPPORTED:
                print 'Incoming SMS notification is not supported.'

            # Enable notifications for incoming USSD
            try:
                self.sm.SetIncomingUSSD()
            except gammu.ERR_NOTSUPPORTED:
                print 'Incoming USSD notification is not supported.'

        except Exception, e:
            print e

    def _run(self):
        self._init()

        while True:
            time.sleep(1)


if __name__ == "__main__":
    gsm_thread = GsmThread()
    gsm_thread.thread.start()
    gsm_thread.thread.join()

`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.