AK-Homberger/NMEA0183-WiFi-Multiplexer

all nmea data is sent twice

maxnae opened this issue · 9 comments

Regardless of whether I switch off a softserial or not. all nmea data is sent twice. Can this be prevented?

Try to commet out the second send code and check if its now sent only once.

/*
if (GetNMEA0183Message2() == true) { // Get NMEA sentences from serial#2
SendNMEA0183Message(buf2); // Send to clients
}
*/

And check that there is no shortcut between both serial RX lines.

Thanks.
I tried but unfortunately the result is the same. There is also no connection at D6 and D7.

$GPGSV,1,1,0079
$GPGSV,1,1,00
79
$GLGSV,1,1,0065
$GLGSV,1,1,00
65
$GNGLL,,,,,,V,N7A
$GNGLL,,,,,,V,N
7A
$GNRMC,,V,,,,,,,,,,N4D
$GNRMC,,V,,,,,,,,,,N
4D
$GNVTG,,,,,,,,,N2E
$GNVTG,,,,,,,,,N
2E
$GNGGA,,,,,,0,00,99.99,,,,,,56
$GNGGA,,,,,,0,00,99.99,,,,,,56
$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99
2E
$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99
2E
$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.992E
$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99
2E
$GPGSV,1,1,0079
$GPGSV,1,1,00
79
$GLGSV,1,1,0065
$GLGSV,1,1,00
65
$GNGLL,,,,,,V,N7A
$GNGLL,,,,,,V,N
7A
is it maybe necessary to have a delay when reading softserial?

$GPGSV,1,1,0079
$GLGSV,1,1,00
65
$GNGLL,,,,,,V,N7A
$GNRMC,,V,,,,,,,,,,N
4D
$GNVTG,,,,,,,,,N2E
$GNGGA,,,,,,0,00,99.99,,,,,,56
$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99
2E
$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99
2E
$GPGSV,1,1,0079
$GLGSV,1,1,00
65
$GNGLL,,,,,,V,N7A
$GNRMC,,V,,,,,,,,,,N
4D
$GNVTG,,,,,,,,,N*2E
$GNGGA,,,,,,0,00,99.99,,,,,,*56
so it comes directly from the gps

best regards max

Can you please add a Serial output command in the receive function:

while (swSer1.available()) {
Char = swSer1.read();

Serial.println(Char);

if ( (Char == '\n') || (Char == '\r') ) {
ReceivedChars = 0;
return true;
}

Just to check if the strange behaviour is comming from the receive or send code part.

Here is the output
here everything has been disabled by swSerial2
68
13
$GNRMC,,V,,,,,,,,,,N4D
10
$GNRMC,,V,,,,,,,,,,N
4D
36
71
78
86
84
71
44
44
44
44
44
44
44
44
44
78
42
50
69
13
$GNVTG,,,,,,,,,N2E
10
$GNVTG,,,,,,,,,N
2E
36
71
78
71
71
65
44
44
44
44
44
44
48
44
48
48
44
57
57
46
57
57
44
44
44
44
44
44
42
53
54
13
$GNGGA,,,,,,0,00,99.99,,,,,,56
10
$GNGGA,,,,,,0,00,99.99,,,,,,56
36
71
78
71
83
65
44
65
44
49
44
44
44
44
44
44
44
44
44
44
44
44
44
57
57
46
57
57
44
57
57
46
57
57
44
57
57
46
57
57
42
50
69
13
$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99
2E
10
$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99
2E
36
71
78
71
83
65
44
65
and here swSerial 1 and 2 is active
46
57
57
44
57
57
46
57
57
42
50
69
13
$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.992E
10
$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99
2E
36
71
80
71
83
86
44
49
44
49
44
48
48
42
55
57
13
$GPGSV,1,1,0079
10
$GPGSV,1,1,00
79
36
71
76
71
83
86
44
49
44
49
44
48
48
42
54
53
13
$GLGSV,1,1,0065
10
$GLGSV,1,1,00
65
36
71
78
71
76
76
44
44
44
44
44
44
86
44
78
42
55
65
13
$GNGLL,,,,,,V,N7A
10
$GNGLL,,,,,,V,N
7A
36
71
78

best regards max

Each character is received only once. That's OK so far. But then the buffer is sent twice. One time after CR (\n) and another time after receiving LF (\r). But that should not happen.

Please add these both lines in both receive functions:

if(ReceivedChars == 0 && (Char == '\r')) return false;
if(ReceivedChars == 0 && (Char == '\n')) return false;

before this code:

if ( (Char == '\n') || (Char == '\r') ) {
ReceivedChars = 0;
return true;
}

Then it should work. It looks like my test system only sent one of the line end codes.

wonderful thanks worked.

one more question, how can I filter different gps sets so that they are not sent further or specify which ones to go through?

$GNVTG
$GPGSV
$GLGSV

Unfortunately, switching off the gps data sets in the gps itself is not an option.

best regards max

You have to parse the NME0183 messages. You can try to use this library https://github.com/ttlappalainen/NMEA0183). But I think it's not directly working with SoftwareSerial.

Hi Max,
I added a sofware version that is able to parse the messages with the NME0183 library. But I can't test it at the moment du to missing hardware to test. Please feel free to use the software as a staring point.
Regards,
Andreas

Thank you very much, it looks like this is working perfectly.
I modified that a bit. looks awesome

` if (NMEA0183_1.GetMessage(NMEA0183Msg)) { // Get NMEA sentences from serial#1

if (!((strcmp(NMEA0183Msg.Sender(), "GP") == 0) && NMEA0183Msg.IsMessageCode("GSV") ||
      (strcmp(NMEA0183Msg.Sender(), "GN") == 0) && NMEA0183Msg.IsMessageCode("VTG") ||
      (strcmp(NMEA0183Msg.Sender(), "GN") == 0) && NMEA0183Msg.IsMessageCode("GLL") ||
      (strcmp(NMEA0183Msg.Sender(), "GL") == 0) && NMEA0183Msg.IsMessageCode("GSV"))) { 

  if (NMEA0183Msg.GetMessage(buf, MAX_NMEA0183_MESSAGE_SIZE - 1)) {
     SendNMEA0183Message(buf);    // Send to clients` 

best regards max