1
echo -ne "ATZ\r\n" > /dev/ttyUSB0
echo -ne "AT+CMGF=1\r\n" > /dev/ttyUSB0
echo -ne "AT+CMGS=\"888XXXXXXX\"\rhello\x1a\n" > /dev/ttyUSB0

Since CMS ERROR-96 is for mandatory information missing.

  • I strongly object to closing this question as "unclear what you are asking about". The question is perhaps a bit short on prose text, but the required intormation is present. In fact the question is actually well asked for a new user. It is nicely formatted, and Venkat has looked up the error value 96 and included the description. – hlovdal Feb 23 '16 at 14:53

1 Answers1

0

No, you cannot send AT commands in this way. Start by reading the V.250 (all of chapter 5) and 27.005 specifications (the AT+CMGS command), links are in the tag info page. Those documents will teach you a lot with regards to AT command handling, syntax and behaviour.

The worst mistake is to send AT command lines without waiting for the final result code. In the same way you would not write a HTTP client that totally ignores responses from the HTTP server, you should not send AT commands and totally ignore responses from the modem.

And for the AT+CMGS command you have to wait with sending the sms payload data until after you have received the "\r\n> " prefix (see the first part of this answer for details).

Other things, AT command lines should be terminated with \r only and not \r\n. Opening and closing the modem device over and over again like multiple shell command redirects will cause might be an issue. That totally depends on the specific modem, and there is no guarantee that this will work reliably.

To address these last points I wrote the atinout program to make sending AT command from the command line simple and reliable. The first two AT commands can be sent as

$ echo ATZ | atinout - /dev/ttyUSB0 -
ATZ
OK
$ echo AT+CMGF=1 | atinout - /dev/ttyUSB0 -
AT+CMGF=1
OK
$

or alternatively

$ echo ATZ > commands.txt
$ echo AT+CMGF=1 >> commands.txt
$ atinout commands.txt /dev/ttyUSB0 output.txt

but for AT+CMGS I guess you have to use expect for the time being (in the future atinout will have a companion program specifically for sending AT+CMGS).

Community
  • 1
  • 1
hlovdal
  • 26,565
  • 10
  • 94
  • 165