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 CCS Technical Support

Problem with RS-232 input data format using fgets()

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







Problem with RS-232 input data format using fgets()
PostPosted: Sun Oct 28, 2007 2:00 pm     Reply with quote

Hi guys,

I am trying to get data to a PIC sent from another device. I know that the data is sent out as "\n(Data)\r\n". I realize that CCS-C "stops" taking data once it sees the return "\r", but what happens to the extra "\n" ? I tried testing the data that the CCS-C actually received something along the lines of "\n\n(Data)" or "\n(Data)\n". Is something due to the extra "\n" at the end messing something up here? Anybody have an idea?

Thanks,

g159
g159
Guest







PostPosted: Sun Oct 28, 2007 2:02 pm     Reply with quote

Sorry for any confusion, i meant to say "I tried testing, and CCS-C actually received something along the lines of..."
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Oct 28, 2007 2:41 pm     Reply with quote

The fgets() function will stop getting characters from the UART when
it gets the \r character. If there is a \n character that comes after it,
that \n character will sit in the UART receive buffer until the next call is
made to fgets(). Then the \n will be the first char in the new string.
This is what you are seeing.
g159
Guest







PostPosted: Sun Oct 28, 2007 4:26 pm     Reply with quote

That makes sense. Thanks man.
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