AT command

Hi Guys,

I am working on Telit GM-862 GPS & learning python and AT commands.

I see many places a command “AT\r” being used and some times in a python statement “\r” is used.

What does these 2 command do?

It would be really helpful for beginners like us.

Thanks

A ‘\r’ produces an ASCII carriage return code (CR) or 0x0D in hex. This is used due to a CR is not a printable ASCII character.

‘AT\r’ is the ASCII letters ‘A’ and ‘T’ then a CR.

Try the following Python code (note: you can do this on the command line):

import binascii

a = ‘AT\r’

print a

h = binascii.b2a_hex(a)

print h

the print a shows the printable ASCII characters

the print h shows the hex values of the ASCII characters

In the first case you see AT printed in the second case you see 41540d printed, the hex values of the three ASCII charcters.

I don’t know the Telit GM-862 GPS but apparently it is expecting the ASCII characters ‘AT’ followed by a carriage return (Enter key on newer computers).

that was really an explanatory answer.

Thanks for a quick response.

Also can you please tell me the difference between Carriage Return and Enter key? Does they have same functionality?

A Carriage Return is a defined ASCII code. Look up ASCII in google or Wiki, if you continue programming you will want to print the ASCII table (7bit) and the Extended ASCII table (8bit).

The Return key by tradition should translate into an editor or a program input as a Carriage Return. Depending on what kind of computer you are using the code that actually comes from the keyboard could be different and is called the ‘keyboard code’. See: http://tlt.its.psu.edu/suggestions/inte … dealt.html

This is so the same keyboard codes can be used for any language.

Does they have same functionality?

So in most practical cases, yes.

Oh, to add to your original post: there is also a ‘\n’ that can be used like the ‘\r’. A ‘\n’ is known as a ‘new line’ and is a Carriage Return and a Line Feed which in hex is 0d0a. Yep, these terms do come from the early days of computers where the output device was the Teletype.

Thanks for sharing your knowledge.