neumotngayem
Posts: 11
Joined: Sat Jul 28, 2018 2:21 am

Can't get readable USSD return message

Sat Jul 28, 2018 2:26 am

Hi everyone, I am doing a program to check the balance of the sim, I using the module GSM A6, and here is my python code for that:

Code: Select all

port.write('AT+CMGF=0'+'\r\n')
time.sleep(2)
port.write('AT+CSCS="HEX"'+'\r\n')
time.sleep(2)
port.write('AT+CUSD=1'+'\r\n')
time.sleep(2)
port.write('AT+CUSD=1,"*101#",15'+'\r\n')
print('Waiting....')
time.sleep(5)
reply = port.read(port.inWaiting())
And here is what it return:

AT+CMGF=0

OK

AT+CSCS="HEX"

OK

AT+CUSD=1

OK

AT+CUSD=1,"*101#",15

OK

+CUSD: 1, "D8B41B344687DF20580C879BC56AB8586EA6A02E873A50CCE68AE17264450CD4AC8741E7771A4445BFC369903D0C9A36A70A19A8590F83CEEF348818A687153350B31E0691D36334C85E0739D1E131688C7E2B68A0633A9C06D1E56910F2495500" ,15

I try to translate the hex return message to normal text via online tool like http://www.convertstring.com/vi/EncodeDecode/HexDecode but what I get is something like that: Ø´4Fß XÅj¸Xn¦ .:PÌæárdEÔ¬AçwDE¿Ãi=6§ ¨YÎï4¦3P³Óc4È^9Ñá1h~+h c:ÑåiòIU

Is something wrong when I sent my USSD code, or I have to convert the hex value return with what technique to the readable message ? Thank you

User avatar
DougieLawson
Posts: 39120
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Can't get readable USSD return message

Sat Jul 28, 2018 1:27 pm

Looks like the data is 7-bit
http://smstools3.kekekasvi.com/topic.php?id=288
makes sense of it.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

neumotngayem
Posts: 11
Joined: Sat Jul 28, 2018 2:21 am

Re: Can't get readable USSD return message

Sun Jul 29, 2018 12:30 pm

Oh thank u so much I try to convert with USSD Entry/Display and I got the data I need, thank u so much :D

Return to “Python”