3

I am working on some embedded system, where I use low-end uC, i.e. Atmega128. My system also includes modem, driven via AT commands. I tried to look for any appropriate C library (for GCC), but couldn't find any. Although I know that putting "all" the possible AT command set into uC memory and so having "general purpose" library is unreasonable (and I just need around 30 commands for whole operation), I just need to get some suitable (i.e. lightweight, robust) control mechanism for handling transmitted and received UART strings in uC. Does anybody know of any proven libraries or functions? Or maybe anyone could point me to some good resources/suggestions?

TomiL
  • 671
  • 2
  • 11
  • 25
  • Do you want the ability to talk to an RS-232 interface, or do you already have this ability and need to capture the UART strings? – Robert Harvey Feb 26 '13 at 17:56
  • I don't need help with UART, I already make it working. I need help with program design. :) – TomiL Feb 26 '13 at 17:59
  • See: http://git.ozlabs.org/?p=ppp.git;a=blob;f=chat/chat.c;hb=HEAD You didn't say what license. I think the `chat.c` is BSD. – artless noise Feb 27 '13 at 18:23
  • ATcommands just call for simple Serial transfer that's why a library not needed, did a lot myself with the SIM900 module and XBee's etc never thought of a need for it. – Naaz Nov 07 '13 at 05:40

1 Answers1

0

I hope you might be using this for the GSM or GPRS Modem interfacing, assuming as you have not specified application.

Brief : GSM, GPRS modem is also using AT command inteface for communication with external controller.

See detailed explanation here:

Microchip AN1373 - Using PIC32 MCUs to Develop GSM/GPRS/GPS Solutions

void UART_Buf(void)
{
        ch=SCI2D;
        if(rx_buffer[2] == 'O' && rx_buffer[3] =='K')
        {   
          rx_buffer[5] = '\0';
          msgindex=2;    // code for OK
          rx_wr_i=0;    
        }
        if(rx_buffer[2] == 'B' && rx_buffer[3] =='U' && rx_buffer[4] == 'S' && rx_buffer[5] =='Y')
        {   
          msgindex=3;    // Code for Busy
          rx_wr_i=0;    
        }
        
        if(rx_buffer[2] == 'N' && rx_buffer[3] =='O' && rx_buffer[4] == ' ' && rx_buffer[5] =='C' && rx_buffer[6] =='A' && rx_buffer[7] =='R'&& rx_buffer[8] =='R' && rx_buffer[9] =='I' && rx_buffer[10] =='E' && rx_buffer[11] =='R')
        {   
          msgindex=3;    // Code for  No Carrier
          rx_wr_i=0;    
        }
        if(rx_buffer[2] == 'E' && rx_buffer[3] =='R' && rx_buffer[4] == 'R' && rx_buffer[5] =='O' && rx_buffer[6] =='R' )
        {   
          msgindex=4;    // Code for Error
            rx_wr_i=0;  
        } 
         if(rx_buffer[2]=='+' && rx_buffer[3]=='C' && rx_buffer[4] == 'M' && rx_buffer[5] =='S' )
        {   
          msgindex=3;
        } 
         if(rx_buffer[2]=='+' && rx_buffer[3]=='C' && rx_buffer[4] == 'M' && rx_buffer[5] =='E' )
        {   
          msgindex=3;
        }     
        if(rx_buffer[2]=='+' && rx_buffer[3]=='C' && rx_buffer[4] == 'M' && rx_buffer[5] =='G' && rx_buffer[6]== 'R')
        {   
          msgindex=6;
        }
        
        if(rx_buffer[2]=='E' && rx_buffer[3]=='R' && rx_buffer[4] == 'R' && rx_buffer[5] =='O' && rx_buffer[6] == 'R')
        {   
          msgindex=3;
        } 
        
        if(rx_buffer[2]=='+' && rx_buffer[3]=='C' && rx_buffer[4] == 'S' && rx_buffer[5] =='Q' )
        {
          msgindex=7;
        }
        
        if(rx_buffer[2]=='+' && rx_buffer[3]=='C' && rx_buffer[4] == 'O' && rx_buffer[5] =='L'&& rx_buffer[6] =='P' )
        {
         msgindex=8;
        }
        if(ch == '\r')
          linefeed++;
}

and in ISR

__interrupt void isrVsci2rx(void)
{
      SCI2S1_RDRF = 0;
      rx_buffer[rx_ack++]= SCI2D;
      if(rx_ack>RX_BUFFER_MASK)
        rx_ack=0;
      UART_Buf();
      rx_length++;
  
}

check msgindex and linefeed to know response received.

Kamil
  • 13,363
  • 24
  • 88
  • 183
Harshal Doshi Jain
  • 2,567
  • 1
  • 20
  • 16