Comments (10)
copied from faucamp#43 - just stumbled about this fork by accident but am not actively using the library anymore, so I am unlikely to be of much further help - sorry
According to the GSM spec, USSD responses can have the following status codes:
0 no further user action required (network initiated USSD-Notify, or no further information needed after mobile initiated operation)
1 further user action required (network initiated USSD-Request, or further information needed after mobile initiated operation)
2 USSD terminated by network
3 other local client has responded
4 operation not supported
5 network time out
I've never seen 0 or 3, but the 4s and 5s don't have any message text fields (e.g. +CUSD: 4
).
This response isn't matched by the cusd regex, which leads to a nullpointer exception in parseCusdResponse.
Also, having access to the statuscodes would be nice, to be able to differentiate between a network timeout and unsopperted operation.
I've made a rough patch which changes the second regex group to optional (improvements welcome...), adds the statuscode as variable to USSD() and changes sessionActive to a property.
However, I am unsure how to adapt this if block. It looks to me like that is basically setting the message to the last CUSD indication with statuscode !=2
. Is that really intended behaviour? Because in the "normal" case, statuscode 2 is what you get for succesfull "oneshot" USSD commands (e.g. checking credit).
from python-gsmmodem.
Hi jthurner, it seems that I missed your USSD-statuscode-fixes
branch in your repo. Is it safe to merge your commit?
from python-gsmmodem.
hi @jthurner and @babca what is the best way to fix this problem?
should i use @jthurner's fork?
from python-gsmmodem.
I merged his code into my USSD-statuscode-fixes
branch. Please test this: https://github.com/babca/python-gsmmodem/tree/USSD-statuscode-fixes
If it will work, I will merge it to master.
from python-gsmmodem.
doesn't seem to work
first try it doesn't show response properly
Initializing modem...
Sending USSD string: *888#
USSD reply received:
+CGREG: 2
USSD session was ended by
second try i got error
Initializing modem...
Process Process-2:
Traceback (most recent cal
File "C:\Python27\lib\mu
self.run()
File "C:\Python27\lib\mu
self._target(*self._ar
File "D:\Work Data\Serve
modem.waitForNetworkCo
File "build\bdist.win32
erage
raise TimeoutException
TimeoutException: None
third try
Initializing modem..
Sending USSD string:
None
fourth try the device just become unusable like some other program is using it
could not open port u'com3': WindowsError(5, 'Access is denied.')
fifth
Initializing modem...
Sending USSD string: *888#
USSD reply received: None
USSD session was ended by network.
from python-gsmmodem.
Well I'm not on PC at the moment to test it myself, it would be needed to setup a logger and see what is going on. You can setup the logger to stdout/stderr, or to a file (set the log level to debug and show the live log with a command $ tail -f /tmp/path/to/my/logfile.log
) and see an actual communication with the modem.
I will try to help, but I have two weeks of vacation now. :-)
from python-gsmmodem.
here is the AT command log when the error occur
the response is
DEBUG: write: AT+CUSD=1,"*111#",15
DEBUG: response: ['OK']
DEBUG: notification: ['+CUSD: 4']
meanwhile the non-error response is
DEBUG: write: AT+CUSD=1,"*111#",15
DEBUG: response: ['OK']
DEBUG: notification: ['+CUSD: 1,"Bal: Rp 2000.0\n1. Info pulsa/internet hemat\n2. Bonus Pulsa\n3. Isi Ulang Promo\n4. Cek Kuota\n5. Cek Pulsa Internet\n6. Yuk Solat\n7. Mau Cepat Kaya?\n8. Facebook",15']
DEBUG: write: AT+CUSD=2
DEBUG: response: ['OK']
from python-gsmmodem.
ups sorry misclicked the comment button
from python-gsmmodem.
Initializing modem...
Sending USSD string: *888#
USSD reply received:
+CGREG: 2
USSD session was ended by
The regex in the patch is rubbish, then. I'll fix this, though it may take another weak or so because I'm rather tied up with work atm.
from python-gsmmodem.
for now all i can do is this
#sessionActive = cusdMatches[0].group(1) == '1'
sessionActive = False
#message = cusdMatches[0].group(2)
message = lines
just so it doesn't crash and stop the script but still return the response
updated version
#sessionActive = cusdMatches[0].group(1) == '1'
linesJoined = ''.join(lines)
sessionEnd = linesJoined.startswith('+CUSD: 2')
if sessionEnd:
sessionActive = False
#message = cusdMatches[0].group(2)
message = lines
from python-gsmmodem.
Related Issues (20)
- Question: Support for modems with multiple SIMS ? HOT 1
- dial_polling_demo.py throws gsmmodem.exceptions.TimeoutException: ['NO CARRIER']
- TimeoutException with Sim800 module HOT 1
- Delivery Reports can't be disabled when in PDU mode HOT 2
- Modem working but having Timeout Exception HOT 3
- CMSError: CMS 321 HOT 3
- incompatibility with latest pyserial 3.5
- (removed - useless)
- Sms not receiving
- Support for RFC2217 (serial port over network)
- how best to extend? HOT 1
- Add an example to demonstrate the Sending SMS HOT 2
- Does not work on Python 3.x HOT 2
- Still Alive? HOT 5
- Question: support for windows? HOT 12
- Timeout exception raised for any command. HOT 16
- Error: 'GsmModem' object has no attribute 'rxThread' HOT 3
- sms_handler fails HOT 2
- Instant timeout exception
- PDU Decoding Error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-gsmmodem.