Solved

How to parse AT command

Posted on 2011-09-27
3
3,088 Views
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.
0
Comment
Question by:nnemo33
  • 2
3 Comments
 
LVL 13

Accepted Solution

by:
Hugh McCurdy earned 500 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 );
        break;

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

......

}


function Third_A ( char *pCh )
{
    switch ( *pCh )
    {
        case '0':
        case '\0':
            AnswerCall();
            break;

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

        default:
            ErrorHandlerForUnknownCommand();
            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.
0
 
LVL 8

Expert Comment

by:ssnkumar
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/
0
 
LVL 8

Expert Comment

by:ssnkumar
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/
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

I'm Dumb-phoned(ed) Last week, I noticed this message when adding events to my Google Calendar: On June 27th (2015), Google is removing SMS as a notification option for Google Calendar events.  Their assumption is that enough people have smart p…
Healthcare providers, insurance companies and other covered entities trust eFax Corporate to transmit their most sensitive documents. eFax Corporate can help your organization implement a HIPAA compliant cloud faxing solution.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now