Search code examples
perlserial-portgsmat-commandussd

+CME ERROR: 100 when executing USSD command in perl


I'm using this script to check the credit on my SIM card using USSD command it works fine using a an old Nokia phone connected with USB cable to my PC , the issue is the same script is not working when I use this device :
Huawei USB device ,
what possibly might be wrong ? here is my Perl script and please note that communication is working fine through the COM7 port:

    use strict;
    use Win32::SerialPort 0.11;
    my $ob = Win32::SerialPort->start ("config.cfg") || die;
    $ob->write("AT+CUSD=1,\"*200#\",15");
    sleep 5;
    my $credit = $ob->input;
    my($directory) = $credit =~ /(.*) DA/;
    print "$directory\n";

my configuration file config.cfg:

Win32::SerialPort_Configuration_File -- DO NOT EDIT --
\\.\COM7
CFG_1,none
eol,10
clear,-@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@-
RCONST,0
istrip,0
CFG_2,none
XOFFCHAR,0
PARITY_EN,0
WCONST,200
intr,3
U_MSG,1
STOP,1
XONLIM,0
erase,8
XONCHAR,0
BINARY,1
RTOT,0
echonl,0
XOFFLIM,0
icrnl,0
inlcr,0
READBUF,2097152
igncr,0
EOFCHAR,0
WRITEBUF,0
RINT,4294967295
ocrnl,0
bsdel, 
opost,0
echoke,1
PARITY,none
HNAME,localhost
echoctl,0
CFG_3,none
EVTCHAR,0
icanon,0
isig,0
HADDR,0
E_MSG,1
DATA,8
DVTYPE,none
echo,0
quit,4
s_eof,26
s_kill,21
ERRCHAR,0
onlcr,1
ALIAS,COM7
HSHAKE,rts
DATYPE,raw
echok,1
echoe,1
BAUD,9600
WTOT,10

Solution

  • i am a javascript guy, but this is pretty much the steps to fix the issue.

    first run this AT : AT+CSCS="IRA"

    goto http://www.rednaxela.net/pdu.php

    under the "PDU SMS message creator", set alphabet size: 7

    clear the 1st box and enter your USSD code (eg. *124#) , click convert

    in the 2nd box, copy the last line (eg. *124# -> AA988C3602)

    add it to your ussd section: AT+CUSD=1,"AA988C3602", 15

    run

    to decode the response, goto http://smstools3.kekekasvi.com/topic.php?id=288

    paste the response in "USSD Entry/Display" box,make sure GSM 7bit packed is selected, then click convert

    this is a javascript library for the 7bit pdu conversion -> https://github.com/IAmDarush/ussd-pdu-text-converter

    can't find one for perl