1
\$\begingroup\$

I am trying to send some hex data over TCP using SIM900A module. But the sequence of data has a byte with value of 0x1B which is the escape character. As a result the module terminates the command immediately.

Does anyone know by which I can overcome this problem?

I am trying to access the google maps (http://www.google.com/glm/mmap) api. It needs some data that should be some hex characters. Some sample data array of the format (0x12,0x15,0x1b.....) that needs to be posted. So I am using the following commands

AT+CIPSTART="TCP","www.google.com","80"
AT+CIPSEND

So here I get the > prompt from the module. So I send the following data afterwards

POST maps/glm HTTP1/0
Content-type: application/binary
Content-length: 100

After this I send the hex data. So I am using linux echo to send the hex data. So I send as

echo -ne "/x12/x15/1b/......." > /dev/ttyUSB1

But in sim900 usually we send 0x1A(ctrl+z) to send the data to the server. But it also uses (Esc) or 0x1B to exit sending the data. So this 0x1b I am sending causes a exit skipping the rest of data.

\$\endgroup\$
  • \$\begingroup\$ Have you tried sending three characters "\1B" instead of the single byte Escape character? \$\endgroup\$ – RedGrittyBrick Dec 28 '13 at 22:05
  • \$\begingroup\$ There seems to be plenty of documentation available for this module. (Also here.) Do you have a specific question that isn't covered? \$\endgroup\$ – Dave Tweed Dec 29 '13 at 0:09
  • \$\begingroup\$ @RedGrittyBrick I tried the following and none works echo -ne "\\x1B" > /dev/ttyUSB1 echo -ne "x1B" > /dev/ttyUSB1 I also tried entering \ from keyboard followed by Esc character still it exits \$\endgroup\$ – Lonewolf Dec 29 '13 at 7:29
  • \$\begingroup\$ @DaveTweed I have read the documentation, but i cant find the reference as to how the Esc character can be sent.. \$\endgroup\$ – Lonewolf Dec 29 '13 at 7:33
  • \$\begingroup\$ What byte sequence can you successfully send and what sequence fails? Do you get an error or return code? How exactly are you sending the data, can you give an example of setting up? \$\endgroup\$ – jippie Dec 29 '13 at 8:39
4
\$\begingroup\$

I found one way by which escape character can be sent... You do this by specifying the length to AT+CIPSEND command. So the commands exits only after you have sent all data specified by the length...

AT+CIPSEND=12

By doing it this way... the escape character can be sent..

\$\endgroup\$
0
\$\begingroup\$

In the future, when asking questions about some specific piece of hardware, please link to the documentation page for that hardware -- in this case, something like SIM900 documentation .

The SIM900 AT Commands Set document seems to give a few ways to send arbitrary binary bytes -- would perhaps one of them work for you?

On p. 73, they suggest expanding difficult bytes into a backslash "\" followed by two hexadecimal digits. In particular, sending the backslash character itself itself "\" involves sending the backslash (ASCII 5C) character, the "5" character (ASCII 35), and the "C" character (ASCII 43).

So perhaps you want something like this:

# (warning: untested code)
echo -ne "The "
echo -ne "\\5C" # backslash
echo -ne "\\1B" # escape
echo -ne "\\22" # quote
echo -ne " " # space
echo -ne "\\1A" # ctrl+Z to Google
echo -ne " string."
echo -ne "\x1A" # ctrl+Z to the SIM900

The "echo" command with the "-e" option, when it sees a double-backslash, eats the first backslash and passes the second one through. Then the SIM900 (if I'm reading the document correctly) replaces the 3-character groups (backslash, digit, digit) with a single byte. Then the Google server at the far end receives that single byte.

p. 183 of that manual and also the "Application Note: GPRS Transparent Connection using SIM900". mention "AT+CIPCCFG Configure Transparent Transfer Mode" -- perhaps that would work better for you. I'm still a little unclear about how that works.

p.s.: I've shaken hands with the guy who maintains https://github.com/Mohammed90/SIM900GSM . Perhaps you could help?

p.s.: All the Google APIs I've used so far allow me to use normal printable characters, so I don't have to worry about escaping control characters. Could you post a link to the specific page that led you to believe you needed to send control characters to Google?

\$\endgroup\$
  • \$\begingroup\$ This page has a php code that shows the data to be sent open-electronics.org/how-to-find-the-location-with-gsm-cells \$\endgroup\$ – Lonewolf Dec 30 '13 at 6:43
  • \$\begingroup\$ I tried the escape sequence but it does not seem to be working... i tried the following at+cpbw=2,"123456789",129,"tdck\5C\22" OK So when i read it back again at+cpbr=2 +CPBR: 2,"123456789",129,"tdck/5C/22" \$\endgroup\$ – Lonewolf Dec 30 '13 at 7:45
  • \$\begingroup\$ Good test. So you sent back-slashes, but you got back forward-slashes? I am surprised. Try sending "\41" in the at+cpbw string -- does that give "A" or "/41" when you read it with at+cpbr ? \$\endgroup\$ – davidcary Jan 6 '14 at 13:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.