CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

UART message capture

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








UART message capture
PostPosted: Tue Dec 14, 2004 7:59 pm     Reply with quote

Hi all,

I am using the PIC18LF452 in a project, and it's UART to talk to a 433Mhz transceiver. It needs an "AT" command, and sends back a "\r\nOK\r\n".
From what i've read in the manual, it uses a much stripped down version of the AT Hayes command set, that is used in modems.

What i want to do is read in the response, and process it to get any data other than the OK. I think i should use the interrupt RDA, and i have seen code to do that in the examples.

Sometimes a response has more than 2 pairs of "\r\n". A pair for the data, and a pair for the OK.

I need to know:

>Should i use a circular buffer, or linear? and why?
>How do i get the whole response? given that i can't rely on the "\r\n" to indicate the response, without losing the data OR "OK" to validate.

Thanks
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Tue Dec 14, 2004 9:29 pm     Reply with quote

Take a look at these

http://www.ccsinfo.com/forum/viewtopic.php?t=19083&highlight=ring+buffer

http://www.ccsinfo.com/forum/viewtopic.php?t=6446&highlight=ring+buffer

http://www.ccsinfo.com/wwwboard/messages/1486.html
Guest








PostPosted: Tue Dec 14, 2004 10:07 pm     Reply with quote

Hi Mark,
Thanks for the reply, i think a linear buffer should do the trick for now, i'll just make it long enough for big data bursts.

Should i wait for the 1st "\r\n" and disable the interrupt, and use fetc() until no more chars are read in? because i'll get something like "\r\nddddddddddddddd\r\nddddddddddddd\r\nOK\r\n". I don't have a particular 'start' or 'end' character to reference to.

What i mean is something like:
Code:

#int_RDA
RDA_isr()
{
 buffer[next_in] = getc() //read the uarts 1st buffer char
 
 increment next_in

 buffer[next_in]= getc(); // read the uarts 2nd buffer char

 if (buffer[next_in-1]==13)&(buffer[next_in]==10))
 {
  found start (possibly)
  disable_interrupt(int_RDA);
  do
  { // do this quickly enough to avoid RS232 errors (OERR, FERR)
   buffer[next_in] = getc()   
   increment next_in

  }while (kbhit() )
  enable_interrupt(int_RDA);
  //when kbhit fails= no data in RCREG, return to normal operation
  //should have a buffer with data to parse
 }

 
}


I am only using the interrupt to gather the data so i can process it later in the program.

After it is processed, i then flush the buffer elements to theNull char '0' ready to be used again.


Q's
==
>Would this be adequate? or do i have other things to check?
>After gathering the input data, should i turn off the interrupt so that the buffer isn't corrupted during processing, and re-enable for non process activities so that i can response to incomming radio messages?


Thanks so far.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group