Hi,
Im using a software Serial Port to receive messages from a ublox GPS module. I want to read the whole Message, then print it on the Serial Port.
Here is my code:
void loop(void) {
if (portOne.available()) {
char c = portOne.read(); //gets one byte from serial buffer
if (c == '\r') { //looks for end of data packet marker
portOne.read(); //gets rid of following \n
//do something with rx string
Serial.println(rxString);
rxString = ""; //clear variable for new input
}
else {
rxString += c; //add the char to rxString
}
}
}
Somehow, it looks like I didnt remove the \r\n from the String. This is what I get on the Arduino Serial monitor
$GPGSV,4,2,13,11,53,163,22,12,00,009,,14,19,042,18,17,35,304,09*79
$GPGSV,4,3,13,19,06,171,10,23,25,190,16,28,05,260,,31,17,093,19*70
$GPGSV,4,4,13,32,68,074,28*4D
$GPGLL,5306.22336,N,00852.31212,E,185130.00,A,A*6D
$GPRMC,185131.00,A,5306.22328,N,00852.31226,E,0.521,,160815,,,A*70
When I only use print (without ln) it should write everything into one line, but it is just:
$GPRMC,185431.00,A,5306.22500,N,00852.31208,E,0.271,,160815,,,A*77
$GPVTG,,T,,M,0.271,N,0.502,K,A*20
$GPGGA,185431.00,5306.22500,N,00852.31208,E,1,07,1.52,-4.0,M,45.6,M,,*7B
$GPGSA,A,3,14,11,01,04,32,03,17,,,,,,2.87,1.52,2.44*0F
$GPGSV,4,1,13,01,74,142,34,03,68,254,29,04,44,130,32,08,05,177,*72
$GPGSV,4,2,13,11,52,163,33,12,01,008,,14,17,041,20,17,36,302,24*74
$GPGSV,4,3,13,19,05,171,,23,26,190,,28,04,260,,31,18,092,15*75
$GPGSV,4,4,13,32,67,074,21*4B
Any ideas?
EDIT: Solved, I had to change \r to \n