How to parse AT command

Posted on 2011-09-27
Medium Priority
Last Modified: 2012-05-12
I'm starting a project that create a virtual modem. The modem receive an AT command and response it follow the command. But I don't know (don't have the idea) to parse the AT command to cover all of the cases.Anyone have the source code or document relate how to parse AT command using C language please suggest me. Thanks so much.
Question by:nnemo33
  • 2
LVL 13

Accepted Solution

Hugh McCurdy earned 2000 total points
ID: 36712837
Do you have the AT command set?  If not, I found this -- http://en.wikipedia.org/wiki/Hayes_command_set

I don't have code for you but I have a plan.  I would treat the commands as a tree an implement using mostly switch statements.  I would also use if statements near the bottom as applicable.  Here's an example of the top.  This is assuming that I've already determined the first two characters were indeed AT.

pCh is a pointer to the 3rd character at this point in execution.

switch ( *pCh )
    case 'A':
        Third_A ( pCh + 1 );

    case 'D':
        Dial ( pCh + 1 );



function Third_A ( char *pCh )
    switch ( *pCh )
        case '0':
        case '\0':

        case '/':
            RepeatLastCommand();   // Somehow you'd have to know what this is.  I have ideas if you don't.

            return -1;

    return 0;

Open in new window

As I think about the problems, it occurs to me that C++ might be a better choice.  But that's up to you.

Expert Comment

ID: 36889949
Have you looked at mgetty and vgetty - that is an opensource software related to modem, fax, etc.
You can look at it at: http://mgetty.greenie.net/

Expert Comment

ID: 36889961
Here is a page regarding "Controlling your Modem with AT Commands": http://www.zoltrix.com/support_html/modem/usemodem.htm

You can see the implementation of "Linux Generic Soft Modem" at: http://bellard.org/linmodem.html
The above software has a AT command parser.

And also, you can refer the following link to look at "Simple Hayes AT Command Parser": http://embeddedfreak.wordpress.com/2008/11/03/simple-hayes-at-command-parser/

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Transferring data across the virtual world became simpler but protecting it is becoming a real security challenge.  How to approach cyber security  in today's business world!
If your business is like most, chances are you still need to maintain a fax infrastructure for your staff. It’s hard to believe that a communication technology that was thriving in the mid-80s could still be an essential part of your team’s modern I…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question