View previous topic :: View next topic |
Author |
Message |
g159 Guest
|
Problem with RS-232 input data format using fgets() |
Posted: Sun Oct 28, 2007 2:00 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
g159 Guest
|
|
Posted: Sun Oct 28, 2007 2:02 pm |
|
|
Sorry for any confusion, i meant to say "I tried testing, and CCS-C actually received something along the lines of..." |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Oct 28, 2007 2:41 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
g159 Guest
|
|
Posted: Sun Oct 28, 2007 4:26 pm |
|
|
That makes sense. Thanks man. |
|
![](templates/subSilver/images/spacer.gif) |
|