USSD Commands returning NO CARRIER

nmvictor

New Member
Joined
Aug 30, 2011
Messages
6
Reaction score
0
Hi guys, I have a Huwaei modem(E175). I am programatically(via Java) sending commands to the modems serial port (/dev/ttyUSB0) and things seem to be ok except when I started handling the USSD commands, I simply get the response ERROR / NO CARRIER from the modem depending on how I have sent the USSD command(See below for details). I understand that we have data mode and command mode, what I don't understand is how to explicitly switch between the modes. I would also like to know the detailed meaning of NO CARRIER, does it call for my explicit registration into a GSM network, or what is NO CARRIER supposed to mean in this context? Or is their something I am supposed to do before a USSD session, because if its the network, I am able to send SMS with the modem without the NO CARRIER response. Please help, if you know the workaround, I'd appreciate. A section of the outputs of my program are pasted below.

When sending the USSD command using AT+CUSD:
Code:
Submitted AT command: AT+CMGF=1

OK

Submitted AT command: AT+CGREG?

+CGREG: 0,1

OK

Submitted AT command: AT+CUSD=1,"*144#"

ERROR
If i try to send USSD using ADT, i get the NO CARRIER response.
Code:
Successfully opened the serial port /dev/ttyUSB0
Submitted AT command: AT+CMGF=1

OK

Submitted AT command: AT+CGREG?

+CGREG: 0,1

OK

Submitted AT command: ATD*144#

NO CARRIER

Note: *144# is the USSD code used to check balance with my SIM Operator.
 
Last edited:
Thanks for the reply. I have tried with that but I still get the ERROR response.

Code:
Successfully opened the serial port /dev/ttyUSB0
Submitted AT command: AT+CMGF=1

OK

Submitted AT command: AT+CGREG?

+CGREG: 0,0

OK

Submitted AT command: AT+CUSD=1,"*144#",15

ERROR

Submitted AT command: ATi6

Manufacturer: huawei
Model: E160
Revision: 11.609.06.02.94
IMEI: 351596037574078
+GCAP: +CGSM,+DS,+ES

OK

nmvictor@nmvictors-linuxbox:~$
I wish this could work, Im so close with my application, save for this part.
 
Manufacturer: huawei
Model: E160
Aha! This modem requires USSD commands to be PDU encoded. [-]I'll post some info if I can find it.[/-]
Take it away, GreGorGy!
 
Last edited:
I have posted this before but can't find where. Here is a little bit about PDUs.

Lemme quickly find the PDU for *141#

EDIT: found
AT+CUSD=1,"AA182C3602",15
 
Last edited:
For *144#, use:

AT+CUSD=1,"AA188D3602",15


I have a quick PHP script that goes PDU <==> Text but cannot vouch for its accuracy or anything else - haven't even bothered refactoring the code so its just a quick thing that might help. Save as a PHP (dopdu.php) and run from browser.

Code:
<?php
$PDUin = "";
$PDUout = "";
if (isset($_REQUEST["PDUin"]))
	{
	$PDUin = $_REQUEST["PDUin"];
	}
if ($PDUin != "")
	{
	$PDUout = '<BR>Last PDU=<B>'.PtoT($PDUin).'</B>';
	}
	
$Textin = "";
$Textout = "";
if (isset($_REQUEST["Textin"]))
	{
	$Textin = $_REQUEST["Textin"];
	}
if ($Textin != "")
	{
	$Textout = '<BR>Last Text=<B>'.TtoP($Textin).'</B>';
	}

function PtoT($pdu)
	{
	$hexlen = (strlen($pdu)/2) - 1;
	$hexes = array();
	for ($i = 0; $i <= $hexlen; $i++)
		{
		$hexes[] = substr("00000000".base_convert((substr($pdu,($i*2), 2)),16,2),-8);
		}
	$LeftOver = "";
	$Take = 7;
	$FullBin = "";
	for ($i=0 ; $i<= $hexlen ; $i++)
		{
		$rhs = 0 - $Take;
		$FullBin .= substr($hexes[$i] , $rhs).$LeftOver;
		$lhs = 8-$Take;
		$LeftOver = substr($hexes[$i] ,0, $lhs);
		$Take = $Take-1;
		if ($Take == 0) {$Take = 7;}
		if (strlen($LeftOver) == 7)
			{
			$FullBin .= $LeftOver;
			$LeftOver = "";
			}
		}
	$chrnum = array();
	while ($FullBin != "")
		{
		$chrnum[] = chr(bindec(substr($FullBin,0,7)));
		$FullBin = substr($FullBin,7);
		}
	
	return implode("",$chrnum);
	}

function TtoP($text)
	{
	$bins = str_split($text);
	foreach ($bins as $k=>$v)
		{
		$bins[$k] = substr("0000000".base_convert(ord($v),10,2) , -7);
		}
	$hexes = array();
	$maxbins = count($bins) - 1;
	for ($i = 0 ; $i <= $maxbins ; $i++)
		{
		if ($i == $maxbins)
			{
			$hexes[] = substr("00000000".$bins[$i] , -8);
			}
		else
			{
			$hl = strlen($bins[$i]);
			if ($hl > 0)
				{
				$steal = $hl - 8;
				$hexes[] = substr($bins[$i+1],$steal).$bins[$i];
				$bins[$i+1] = substr($bins[$i+1],0,7+$steal);
				}
			}
		}
	$pdu = array();
	foreach ($hexes as $v)
		{
		if ($v != "00000000")
		{ $pdu[] = substr("0".strtoupper(base_convert($v, 2, 16)),-2); }
		}
	return implode("", $pdu);
	}

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
	"http://www.w3.org/TR/html4/loose.dtd">
<HTML LANG="en">
<HEAD>
	<META HTTP-EQUIV=CONTENT-TYPE CONTENT="text/html; charset=utf-8">
	<TITLE>PDU in and out</TITLE>
	<META NAME="generator" CONTENT="BBEdit 9.6">
</HEAD>
<BODY>
<FORM METHOD="post" ACTION="dopdu.php">
Enter PDU:<BR>
<TEXTAREA NAME="PDUin" ROWS=5 COLS=50><?php echo $PDUin; ?></TEXTAREA><?php echo $PDUout; ?><BR><BR>
Enter TEXT:<BR>
<TEXTAREA NAME="Textin" ROWS=5 COLS=50><?php echo $Textin; ?></TEXTAREA><?php echo $Textout; ?><BR><BR>
<INPUT TYPE="submit" VALUE="Decode / Encode">
</FORM>

</BODY>
</HTML>
 
I have tried with both this codes:

AT+CUSD=1,"AA182C3602",15
and
AT+CUSD=1,"AA188D3602",15
and it works but only gets me the OK response. Thanks for that, however, I am still not getting the Current balance response, despite keeping the code that checks & fetches the response in a while loop that lasts 2 mins. Is their a step am missing? JJust to mention, I am coding with java.
 
Last edited:
I want you to consider the following session, bearing in mind that Huaweis do send unsolicited data all the time (for diagnostics, etc). I am on Cell C and will send the USD *101# (check balance). Things in BOLDRED are instructions I am sending to the modem. Things in BOLDGREEN are the modems direct responses to my commands.

ATI

Manufacturer: huawei
Model: E1820
Revision: 11.831.03.00.00
IMEI: --
+GCAP: +CGSM,+DS,+ES

OK


^BOOT:31355834,0,0,0,99

at+cusd=1,"AA182C3602",15

OK

^CSNR:-99,-14

^RSSI:9

+CUSD: 0,"C2303BEC1E97413D90140473C1602050110F4FCBF32072985ED6C1622F58EC2583CD602EA3BC5C0611C3F430A80792E164AE180CD414BA1A",15

^CSNR:-99,-14

^RSSI:9


Look at the blue - unsolicited stuff. That bold blue line starting +CUSD is the response from the operator to my USSD, which you need to pick up. See that rubbish in the "" - it is a PDU response. My php page translates that as:

Balance = R 0.00 Expiry date:01/01/2030.Free Data = 282.10 MB.

See how the month-end balance on cell c is used up :)
 
Thanks, I got all your saying and I appreciate you information. I apologize for my nagging, but my real problem seems to be picking the bold blue line, which is the operators response to my USSD command, I am only able to pick the green responses from the modem. Please help me past this, and thanks in advance for your patience with me.
 
Hi nmvictor

I am unfamiliar with java and therefore cannot answer how you would do this. Do you get those unsolicited responses at all? In my app, I tell it to read every line of information from the modem. If the line matches an instruction I have sent, I discard it. If the line matches the information codes (RSSI, BOOT, DSFLOW, etc) I handle it accordingly. If the line starts with a response I am expecting from, say, a USSD, I look out for the line beginning "+CUSD" and then I split it into an array based on the comma. From that array, I find the response and handle it.

ginggs and I have both suffered through this process so we have the patience but not necessarily the complete know how for your programming situation.
 
Do you get those unsolicited responses at all?
Thanks again.To answer the above question, I'd say No. I don't get unsolicited responses in normals situation, when I send a command, in my case its the modem response that gets back. The responses prefixed with ^ don't show, I don't know if its because I'm not letting the thread run long enough to capture them, but like I said, I have the check and fetch code wrapped in a while loop to run for 2 mins, reading every possible line and if any, appending it to a StringBuilder. I could try to make the time longer and get back with the results. On the other hand, are the unsolicited response a feature that could be disabled? Please let me know. Thanks a lot GreGorGy, and ginggs, I am not taking your patience for granted.
 
You're definitely gonna have to give it a little longer to respond. To disable the ^ responses Huawei only:

Code:
AT^CURC=0
(=1 reenables)

Greg
 
Hi, I have been doing some Goooogling and I stumbled upon some info that Huawei modems attach to 3 ports[http://ubuntuforums.org/showthread.php?t=1017630&page=3 See the last post on that thread], in case of linux (/dev/ttyUSB0, /dev/ttyUSB1 and /dev/ttyUSB2). I have tried opening these ports and sending commands to the three ports and they all work save for /dev/ttyUSB2. Either way, I have an extra port, Im thinking I could have a thread monitoring /dev/ttyUSB1 for these "unsolicited responses and anything from the network, then have /dev/ttyUSB0 for normal AT commands and responses operation. Am telling you all these just in case you have a better suggestion. Back to coding, I'll check in just in case you post that suggestion or anything new. I appreciate your help through this, I nagged a lot but bottom-line, I am learning more which I owe to you and your patience. Thanks again.
 
Last edited:
Top
Sign up to the MyBroadband newsletter
X