AT+CMGS returns ERROR - serial-port

I am using SIM900 GSM module connect to my AVR Microcontroller.
I tested it with FT232 to see transmitting data.
First Micro sends AT it will response OK
AT OK
AT+CMGF=1 OK
AT+CMGS="+9893XXXXXX" returns ERROR and doesn't show ">"
Could anybody advise me what to do?

Command AT+CSCS? will answer You what type of sms-encoding is used. Properly answer is "GSM", and if not, You should set it by command AT+CSCS="GSM".
And remember about "Ctrl+Z" (not "Enter") as a finish of sms text, please.

You aren't passing all the parameters to the command.
The command format is:
AT+CMGS=<number><CR><message><CTRL-Z>
Where:
<CR> = ASCII character 13
<CTRL-Z> = ASCII character 26
You have passed only the number and without the <CR> you won't see the > note for the message.
Example:
AT+CMGS="+9893XXXXXX"
> This is the message.→
The response is:
+CMGS:<mr>
OK
Where <mr> is the message reference.

If AT+CSCS? command returns UCS2, then many arguments need to be encoded as hex string of UTF-16 encoding, so the phone number would become "002B0039003800390033...", and the SMS text would need to be encoded in the same way. If you don't need UCS2 encoding, then the easiest thing to do is to switch to GSM encoding (or another encoding from the available set as shown by AT+CSCS=? command)

Sometimes the issue is the text mode you are in. Enter AT+CMGF? and you should receive +CMGF: 1. If instead you receive +CMGF: 0, enter AT+CMGF=1. This changes the message format from PDU mode to Text mode. I'm not sure what either of those mean exactly, but this fixed my issue.
SIM 800 AT command manual

Related

Decoding Binary Data in Tcl

I am reading data from a TCP port in TCL using a socket. The messages do not end with any newline, but they do container a header containing the number of bytes of data.
I have the following code to read two byte of data from the socket (16bit little endian) and convert that into an integer I can then use in a loop to read the rest of the data:
binary scan [read $Socket 2] s* length
In this case $Socket is my socket and it has been configured to use binary encoding.
This works well except where either the upper or lower byte is 0x0D. It appears TCL reads 0x0D and 0x0A both as '\n', which then defaults to 0x0A, so the code does work correctly. For example 13 is read as 10. How do I stop this from happening?
The socket should be placed into binary mode if you're moving binary data across it.
chan configure $Socket -translation binary
# Use [fconfigure] instead of [chan configure] in older Tcl versions
This disables all the automatic processing that Tcl usually does — your description says you're having a problem with end-of-line conversion — and makes it so that read will just deliver a string of the bytes (formally a string of characters between U+000000 and U+0000FF, and internally using an efficient in-memory encoding scheme).
For files, you can include b in the control mode when opening to get this done for you. For sockets, you need to do this yourself.
In addition to configuring binary encoding, you also need to set the translation to 'lf'. As this is a frequently occurring situation, there is a shorthand for making these two settings:
fconfigure $Socket -translation binary

How to terminate outgoing CSD call?

I have a gsm modem called iRZ. I use it for CSD call(getting meterage from meter). I call to meter like this: ATDpho0ne_number
Then I exchange data.
And finally I need to terminate this call, but how?
I tried: "+++" next "ATH", and "ATH0". But it doesn't work...
Help, please...
You did not specify the exact modem type so I tell you two options.
Option 1:
The +++ character sequence must be preceded and
followed by a pause of at least 1000 ms. The +++ characters must be entered in quick succession, all within 1000 ms.
Option 2:
You have to set up a "code word" by ATM Control utility and that code word will switch back the modem to AT mode and then you can issue the ATH command.

AT Command to change frame size gives ERROR

I'm using a SIM900A GSM Shield to communicate between an arduino due and an API.
I currently using it's default values in the multiplexer of GSM Shield. But now I'm in need of changing it's frame size to 255. When I check the current frame size, it gives following response which indicates the frame size as 127.
CMUX Read:AT+CMUX?
+CMUX: 0,0,5,127,10,3,30,10,2
OK
Then I used following AT command to change it to 255. But it gives an ERROR.
sim900_send_cmd("AT+CMUX=0[,0[,1[,255[,10[,3[,30[,10[,2]]]]]]]]\r\n");
CMUX Read:AT+CMUX=0[,0[,5[,255[,10[,3[,30[,10[,2]]]]]]]]
ERROR
What am I doing wrong here ? am I missing a step ? Any insight will be much appreciated. Thank you
I'm not an expert in AT commands, but I bet you don't need all the brackets in yours. Brackets are used to indicate parameters which could be omitted. So your command should look like this:
CMUX Read:AT+CMUX=0,0,5,255,10,3,30,10,2
Maybe even a shoter version will work:
CMUX Read:AT+CMUX=0,0,5,255

Expect script arrow keys

I didn't know that how to send arrow keys using expect, hence I generated autoexpect script for all the arrow keys and found out that autoexpect generates this character for right arrow key:
send -- "^[\[C"
I used the same send command in my custom script and I'm getting a following error:
while executing
"send -- "^[\[C"
expect eof
"
(file "script_auto.exp" line 38)
What exactly shall I do to send the right arrow key. Any help would be appreciated.
"^[\[C" is an invalid string in Tcl. ^[ should be the ESC char which is \033. So try this:
send "\033\[C"
UPDATE:
The safest way to get the correct RIGHT ARROW key for current terminal (as in $TERM) is to use tput:
[bash] # v=$(tput cuf1)
[bash] # printf '%q\n' "$v"
$'\E[C'
[bash] #
To know what cuf1 means, search terminfo's man page. :)
For Arrow up key you have to send as shown below
send "\033\[A"
I have tested this

Basic calculator script in UNIX - Want to make error messages disappear if no variables are entered

Here is a basic script with getopt command and assigned variables.
If someone were to type in
MyScript -a
with no words or numbers added after the -a, then an error message would pop up! The same happens if you replace -a with any other assigned variables. If I wanted no error message to appear, how would I go about doing this?
Hints/advice is preferred over a simply strict answer!
From the bash manual:
getopts can report errors in two ways. If the first character of optstring is a colon, silent error reporting is used. In normal operation diagnostic messages are printed when invalid options or missing option arguments are encountered. If the variable OPTERR is set to 0, no error messages will be displayed, even if the first character of optstring is not a colon.
Since you tag the question with Unix and don't mention bash, you may or may not be so lucky, but the answer is to read the manual page carefully.

Resources