hello, im facing the following problem:
I want to get data from 2 GPSs. Use 2 same devices , garmin17, same configuration uploaded and checked thru garmin's program. Output is NMEA sentenses RMC, GLL, GGA. Both devices work fine when connected (one by one) to mentioned program.
Now, output of devices is connected to Serial1rx and the other to Serial2rx on mega2560.
I have the following code
String txtmsg = "";
char inchar = ' ';
int a = 0;
int b = 0;
byte valid = 0;
void setup() {
Serial.begin(115200);
Serial1.begin(9600);
Serial2.begin(9600);
}
void loop() {
txtmsg = "";
CheckLeft();
txtmsg = "";
CheckRight();
}
void CheckLeft(void) {
while (Serial1.available()) {
if (Serial1.available()) {
inchar = Serial1.read();
Serial.write(inchar);
}
if (Serial1.available()) {}
else delay(5);
if (Serial1.available()) {}
else Serial.println();
}
}
void CheckRight(void) {
while (Serial2.available()) {
if (Serial2.available()) {
inchar = Serial2.read();
Serial.write(inchar);
}
if (Serial2.available()) {}
else delay(5);
if (Serial2.available()) {}
else Serial.println();
}
}
what i get on serialmonitor is strange (well, as i see it). (I ll use code tags for easier scrolling)
$GPRMC,155115,A,1234.2531,N,1234.3938,E,000.0,000.0,070899,003.2,E*75
$GPGGA,155115,1234.2531,N,1234.3938,E,2,09,0.9,78.4,M,35.4,M,,*75
$GPGLL,1234.2531,N,1234.3938,E,155115,A*27
$GPRMC,155115,A,1234.2534,N,1234.3926,E,000.0,000.0,070899,003
$GPRMC,155116,A,1234.2534,N,1234.3926,E,000.1,000.0,070899,003.2,E*7D
$GPGGA,155116,1234.2534,N,1234.3926,E,2,08,1.0,79.6,M,35.4,M,,*76
$GPGLL,1234.2534,N,1234.3926,E,155116,A*2E
$GPRMC,155116,A,1234.2530,N,1234.3936,E,000.0,000.0,070899,003116,A*2B
remove cable on Serial1, Serial2 works fine when alone
$GPRMC,155123,A,1234.2534,N,1234.3926,E,000.1,000.0,070899,003.2,E*7B
$GPGGA,155123,1234.2534,N,1234.3926,E,2,08,1.0,79.6,M,35.4,M,,*70
$GPGLL,1234.2534,N,1234.3926,E,155123,A*28
$GPRMC,155124,A,1234.2534,N,1234.3926,E,000.0,000.0,070899,003.2,E*7D
$GPGGA,155124,1234.2534,N,1234.3926,E,2,08,1.0,79.6,M,35.4,M,,*77
$GPGLL,1234.2534,N,1234.3926,E,155124,A*2F
$GPRMC,155125,A,1234.2534,N,1234.3926,E,000.1,000.0,070899,003.2,E*7D
$GPGGA,155125,1234.2534,N,1234.3926,E,2,08,1.0,79.6,M,35.4,M,,*76
$GPGLL,1234.2534,N,1234.3926,E,155125,A*2E
put cable Serial1 in place
remove cable Serial2, Serial1 works fine when alone
$GPRMC,155131,A,1234.2530,N,1234.3936,E,000.0,000.0,070899,003.2,E*7C
$GPGGA,155131,1234.2530,N,1234.3936,E,2,08,1.0,79.0,M,35.4,M,,*70
$GPGLL,1234.2530,N,1234.3936,E,155131,A*2E
$GPRMC,155132,A,1234.2530,N,1234.3936,E,000.0,000.0,070899,003.2,E*7F
$GPGGA,155132,1234.2530,N,1234.3936,E,2,08,1.0,79.0,M,35.4,M,,*73
$GPGLL,1234.2530,N,1234.3936,E,155132,A*2D
$GPRMC,155133,A,1234.2530,N,1234.3936,E,000.0,000.0,070899,003.2,E*7E
$GPGGA,155133,1234.2530,N,1234.3936,E,2,08,1.0,79.0,M,35.4,M,,*72
$GPGLL,1234.2530,N,1234.3936,E,155133,A*2C
exchange cables Serial1-Serial2, same problem
$GPRMC,155136,A,1234.2534,N,1234.3926,E,000.1,000.0,070899,003.2,E*7F
$GPGGA,155136,1234.2534,N,1234.3926,E,2,08,1.0,79.6,M,35.4,M,,*74
$GPGLL,1234.2534,N,1234.3926,E,155136,A*2C
$GPRMC,155136,A,1234.2530,N,1234.3936,E,000.0,000.0,070899,0039
$GPRMC,155137,A,1234.2534,N,1234.3926,E,000.1,000.0,070899,003.2,E*7E
$GPGGA,155137,1234.2534,N,1234.3926,E,2,08,1.0,79.6,M,35.4,M,,*75
$GPGLL,1234.2534,N,1234.3926,E,155137,A*2D
$GPRMC,155137,A,1234.2530,N,1234.3936,E,000.0,000.0,070899,003,155137,A*28
$GPRMC,155138,A,1234.2530,N,1234.3936,E,000.1,000.0,070899,003.2,E*74
$GPGGA,155138,1234.2530,N,1234.3936,E,2,08,1.0,79.0,M,35.4,M,,*79
$GPGLL,1234.2530,N,1234.3936,E,155138,A*27
$GPRMC,155138,A,1234.2534,N,1234.3926,E,000.1,000.0,070899,003,E,155138,A*22
$GPRMC,155139,A,1234.2530,N,1234.3936,E,000.0,000.0,070899,003.2,E*74
$GPGGA,155139,1234.2530,N,1234.3936,E,2,08,1.0,79.0,M,35.4,M,,*78
$GPGLL,1234.2530,N,1234.3936,E,155139,A*26
(integer part of LON, LAT is ok, but has been changed to 1234, for safety reasons. )
problem1 : why not all sentenses (3 + 3) appear , when both inputs are connected?
problem2 : why the faulty - alone RMC "stops" sometimes around byte 64 and other times is "mixed" with following messages?
any ideas?