Issues with NMEA logging

Inquiry and support for Freematics products
Post Reply
nawaz
Posts: 11
Joined: Thu Apr 23, 2015 11:21 pm

Issues with NMEA logging

Post by nawaz »

I am using latest v3 of datalogger from Github and having problems with NMEA messages. I have enabled NMEA logging with the following in config.h

Code: Select all

// enable(1)/disable(0) GPS module
#define USE_GPS 1
#define LOG_GPS_NMEA_DATA 1
#define LOG_GPS_PARSED_DATA 0


However, in the log file, I see partial NMEA messages that appear to be overrun by other PIDs.

$GPRMC,080650.25123,10D,0
$GPGGA,080650.65114,111,14
$GPRMC,080650.757,V123,133,102
$GPRMC,080650.957,V124,10C,0
$GPGGA,080651.15112,10D,0
$GPRMC,080651.123,104,0


For example, the first line appears to be a partial GPRMC sentence overrun like,
$GPRMC,080650.25123,10D,0


So if you look at the GPRMC sentences, these are not complete. Has anyone experienced this? Any solutions or recommendations? Also is there a stable and well tested version of software available somewhere? I have tried pre-compiled hex file but with this, I get a zero byte sized file with no logged data.
FastZyx
Posts: 12
Joined: Thu Apr 16, 2015 8:12 pm

Re: Issues with NMEA logging

Post by FastZyx »

Me too, I have resolved loading the nmea string in a char array and then writing it instead of writing each char to sd.
I have also added "dataTime = millis();" on top because if you set LOG_GPS_PARSED_DATA to 0 the varialble is not correctly initialized.
nawaz
Posts: 11
Joined: Thu Apr 23, 2015 11:21 pm

Re: Issues with NMEA logging

Post by nawaz »

Thanks I will try it.
stanley
Site Admin
Posts: 1039
Joined: Sat Mar 01, 2014 3:15 am

Re: Issues with NMEA logging

Post by stanley »

Please tell us the result. If it is good, I will update the sketch.
nawaz
Posts: 11
Joined: Thu Apr 23, 2015 11:21 pm

Re: Issues with NMEA logging

Post by nawaz »

Okay I have given it a go now but have run into new problems. With the above mentioned fix applied, I only receive NMEA messages when the vehicle is switched off and no PID data is being received from the protocol processor. As soon as the vehicle is switched on, PID data keeps streaming but I don't receive NMEA messages any more.

Is the serial port fast enough for the protocol processor to stream both PIDs and NMEA messages? To sum up, I cannot get GPS to work properly. When I use parsed gps logging, I don't get reasonable coordinates. I suspect it is the bug that is mentioned in one of the other threads on this forum. When I try to use NMEA messages, I run into these problems. Are there any updates or bug fixes available for protocol processor?
FastZyx
Posts: 12
Joined: Thu Apr 16, 2015 8:12 pm

Re: Issues with NMEA logging

Post by FastZyx »

For me, it works correctly.
This is an example from a log file (MIN_LOOP_TIME = 250ms and PMTK_SET_NMEA_UPDATE_5HZ):

.....................................
41,10C,1705
28,10D,60
31,104,25
30,111,87
41,20,-95,-156,-1257
0,21,-13,-17,9
0,22,-4,-12,-24
82,$GPRMC,085417.000,A,4412.3768,N,01000.5607,E,31.96,257.67,020515,,,A*52
48,10C,1722
28,10D,61
30,104,24
31,111,87
41,20,-80,-86,-1114
0,21,7,-9,6
0,22,-4,-12,-24
75,$GPVTG,257.67,T,,M,31.96,N,59.23,K,A*3C
34,10C,1712
30,10D,61
30,104,25
29,111,87
42,20,-87,10,-790
0,21,-22,1,-2
0,22,-4,-13,-24
74,$GPGGA,085418.000,4412.3748,N,01000.5486,E,1,9,0.98,90.3,M,48.0,M,,*67
45,10C,1724
31,10D,61
29,104,24
30,111,87
41,20,-124,-72,-1024
0,21,4,-2,2
0,22,-4,-12,-24
76,$GPRMC,085418.000,A,4412.3748,N,01000.5486,E,32.67,257.91,020515,,,A*50
53,10C,1720
30,10D,61
30,104,24
40,111,87
30,105,70
30,10F,18
30,146,17
29,12F,67
31,133,100
31,131,-23922
30,11F,564
42,20,-122,-74,-1185
0,21,14,-26,6
0,22,-4,-13,-24
77,$GPVTG,257.91,T,,M,32.67,N,60.54,K,A*32
30,10C,1724
30,10D,61
29,104,23
30,111,87
42,20,-109,66,-921
0,21,11,44,7
0,22,-4,-13,-24
74,$GPGGA,085419.000,4412.3730,N,01000.5359,E,1,9,0.95,90.5,M,48.0,M,,*67
45,10C,1737
30,10D,61
29,104,16
31,111,87
41,20,-117,-40,-933
0,21,3,21,-1
0,22,-4,-12,-24
76,$GPRMC,085419.000,A,4412.3730,N,01000.5359,E,33.40,259.23,020515,,,A*58
44,10C,1733
28,10D,61
31,104,9
30,111,87
41,20,-150,0,-906
0,21,-8,-24,-6
0,22,-4,-12,-24
76,$GPVTG,259.23,T,,M,33.40,N,61.89,K,A*30
45,10C,1716
27,10D,61
31,104,8
30,111,87
41,20,-199,-88,-879
0,21,2,29,-3
0,22,-4,-12,-24
119,10C,1718
30,10D,61
30,104,1
30,111,87
29,105,70
31,10F,18
30,146,17
29,12F,67
31,133,100
31,131,-23922
30,11F,566
42,20,-197,-48,-734
0,21,14,27,0
0,22,-4,-13,-24
75,$GPGGA,085420.000,4412.3712,N,01000.5232,E,1,9,0.95,90.7,M,48.0,M,,*63
42,10C,1711
30,10D,61
30,104,0
29,111,87
42,20,-122,-115,-1340
0,21,-11,-39,-7
0,22,-4,-12,-24
80,$GPRMC,085420.000,A,4412.3712,N,01000.5232,E,32.71,259.30,020515,,,A*5F
49,10C,1709
30,10D,61
30,104,0
29,111,87
42,20,-133,-76,-896
0,21,10,-3,0
0,22,-4,-13,-24
75,$GPVTG,259.30,T,,M,32.71,N,60.62,K,A*35
.....................................
nawaz
Posts: 11
Joined: Thu Apr 23, 2015 11:21 pm

Re: Issues with NMEA logging

Post by nawaz »

This does not appear to work for me. This is what my settings look like,

In config.h I have,

Code: Select all

...
// minimum loop time
#define MIN_LOOP_TIME 250 /* ms */

...
#define USE_GPS 1
#define LOG_GPS_NMEA_DATA 1
#define LOG_GPS_PARSED_DATA 0


In initGPS function, I have uncommented this,

Code: Select all

write("ATSGC ");
write(PMTK_SET_NMEA_UPDATE_5HZ);
receive();


and LOG_NMEA_GPS_DATA conditional define part of logGPS function looks like this,

Code: Select all

write("ATGRR\r");
dataTime = millis();
for (;;) {
     if (available()) {
           char c = read();
           if (c == '>') {
               // prompt char received
               break;
            } else {
#if VERBOSE
                    SerialInfo.write(c);
#endif
                    logData(c);

            }
       } else if (millis() - dataTime > 100) {
             // timeout
             break;
       }
}


and this is what I get in my log files. Occasionally I see one or two PIDs but not something that I would normally expect.
$GPRMC,095119.200,A,5213.0515,N,00006.2419,E,0.05,308.50,070515,,,A*68202,10D,0
50,20,-768,-15412,-6080
0,21,-9,-84,410
0,22,448,-74,-214
$GPVTG,308.50,T,,M,0.06,N,0.11,K,A*35200,104,16
46,20,-460,-15428,-5876
0,21,-197,-2,297
0,22,440,-72,-214
$GPRMC,095119.700,A,5213.0515,N,00006.2419,E,0.05,308.50,070515,,,A*6D204,111,11
46,20,-612,-15476,-6088
0,21,-216,-9,274
0,22,451,-75,-215
$GPVTG,308.50,T,,M,0.06,N,0.11,K,A*35204,133,101
47,20,-668,-15428,-5932
0,21,-119,-60,366
0,22,442,-74,-214
$GPRMC,095120.200,A,5213.0515,N,00006.2419,E,0.06,308.50,070515,,,A*61204,10C,688
47,20,-548,-15304,-6028
0,21,-22,-30,379
0,22,448,-72,-208
$GPVTG,308.50,T,,M,0.05,N,0.10,K,A*37202,10D,0
47,20,-444,-15192,-6080
0,21,-110,6,374
0,22,447,-71,-211
$GPRMC,095120.700,A,5213.0515,N,00006.2418,E,0.03,308.50,070515,,,A*60202,104,16
48,20,-564,-15380,-6284
0,21,-123,-6,295
0,22,443,-67,-211
$GPVTG,308.50,T,,M,0.05,N,0.09,K,A*3F203,111,11
46,20,-552,-15488,-5912
0,21,-156,-38,352
0,22,442,-66,-206
$GPRMC,095121.200,A,5213.0515,N,00006.2418,E,0.05,308.50,070515,,,A*62204,131,9654
47,20,-604,-15252,-5892
0,21,-84,-47,360
0,22,452,-74,-218
$GPVTG,308.50,T,,M,0.06,N,0.11,K,A*35203,10C,687
50,20,-524,-15380,-6072
0,21,-23,-111,422
0,22,444,-74,-216
$GPRMC,095121.700,A,5213.0515,N,00006.2418,E,0.05,308.50,070515,,,A*67200,10D,0
47,20,-648,-15068,-5972
0,21,-103,-18,274
0,22,447,-69,-213
$GPVTG,308.50,T,,M,0.06,N,0.12,K,A*36203,104,16
47,20,-576,-15244,-5964
0,21,-160,-27,312
0,22,447,-71,-217
$GPRMC,095122.200,A,5213.0516,N,00006.2418,E,0.05,308.50,070515,,,A*62203,111,11
50,20,-664,-15500,-5928
0,21,-74,-45,376
0,22,445,-71,-211
$GPVTG,308.50,T,,M,0.05,N,0.09,K,A*3F200,11F,1060
48,20,-532,-15464,-5884
0,21,-111,-31,355
0,22,445,-71,-215
$GPRMC,095122.700,A,5213.0516,N,00006.2418,E,0.06,308.50,070515,,,A*64202,10C,692
47,20,-476,-15324,-6232
0,21,-185,-27,260
0,22,451,-67,-217
$GPVTG,308.50,T,,M,0.07,N,0.13,K,A*36203,10D,0
46,20,-740,-15476,-6008
0,21,-139,-34,366
0,22,444,-68,-214
$GPRMC,095123.200,A,5213.0516,N,00006.2418,E,0.06,308.50,070515,,,A*60204,104,16
47,20,-648,-15416,-5832
0,21,-84,-67,409
0,22,447,-71,-209
$GPVTG,308.50,T,,M,0.05,N,0.10,K,A*37203,111,11
47,20,-508,-15428,-6036
0,21,-13,-72,391
0,22,439,-73,-205
$GPRMC,095123.700,A,5213.0516,N,00006.2417,E,0.04,308.50,070515,,,A*68203,105,101
50,20,-556,-15396,-5992
0,21,5,-70,373
0,22,447,-69,-211
$GPVTG,308.50,T,,M,0.04,N,0.07,K,A*30203,10C,702
47,20,-552,-15200,-6184
0,21,-16,-75,360
0,22,447,-73,-215
$GPRMC,095124.200,A,5213.0516,N,00006.2417,E,0.04,308.50,070515,,,A*6A199,10D,0
48,20,-444,-15404,-6176
0,21,-162,-18,340
0,22,450,-76,-210
$GPVTG,308.50,T,,M,0.04,N,0.07,K,A*30203,104,16
46,20,-528,-15396,-5928
0,21,-245,-8,233
0,22,448,-70,-212
$GPRMC,095124.700,A,5213.0516,N,00006.2417,E,0.04,308.50,070515,,,A*6F204,111,11
46,20,-464,-15452,-5908
0,21,-194,-64,214
0,22,444,-72,-214


The only thing left to try is to buffer entire NMEA message before writing it to SD card. Any thoughts? Would you mind sharing part of your logGPS function?
FastZyx
Posts: 12
Joined: Thu Apr 16, 2015 8:12 pm

Re: Issues with NMEA logging

Post by FastZyx »

nawaz wrote:The only thing left to try is to buffer entire NMEA message before writing it to SD card. Any thoughts? Would you mind sharing part of your logGPS function?


This is what I wrote:
FastZyx wrote:Me too, I have resolved loading the nmea string in a char array and then writing it instead of writing each char to sd.
I have also added "dataTime = millis();" on top because if you set LOG_GPS_PARSED_DATA to 0 the varialble is not correctly initialized.
nawaz
Posts: 11
Joined: Thu Apr 23, 2015 11:21 pm

Re: Issues with NMEA logging

Post by nawaz »

I have now implemented this where incoming NMEA sentence characters are stored in char array and then written to SD card. It works fine for a few minutes but then goes off and I seem to get partial NMEA sentences in my file like this,

95,$GPVTG,326.52,T,,M,1.75,N,3.25,K,N*35

110,104,29
47,20,-484,-14224,-8212
0,21,-85,24,269
0,22,427,-53,-241
94,$GPRMC,115531.000,V,,,,,1.41,326.53,080515,,,N*43

108,111,14
46,20,-776,-14616,-8468
0,21,-199,-28,357
0,22,421,-57,-241
98,$GPVTG,326.52,T,,M,1.55,N,2.87,K,N*3E

117,146,16
46,20,-740,-14332,-8248
0,21,47,-41,370
0,22,414,-62,-224
95,$GPRMC,115531.500,V,,,,,1.55,326.53,080515,,,N*43

99,10C,1662
46,20,-996,-14156,-8336
0,21,-141,-37,370
0,22,406,-56,-234
95,$GPVTG,326.53,T,,M,1.79,N,3.31,K,N*3D

107,10D,0
51,20,-588,-14244,-8396
0,21,-38,-21,341
0,22,427,-63,-245
94,$GPRMC,115532.000,V,,,,,1.30,326.53,080515,,,N*46

105,104,14
47,20,-472,-14268,-8620
0,21,-65,-23,299
0,22,425,-59,-241
98,$GPVTG,326.53,T,,M,0.36,N,0.67,K,A*38

105,111,11
47,20,-360,-14368,-8528
0,21,-149,3,319
0,22,431,-67,-243
94,$GPRMC,115532.500,A,5217.0935,N,00007.4722,E,0.55,326.53,080515,,,A*68

0,24,146
0,80,88265
110,12F,40
46,20,-628,-14476,-8504
0,21,-107,-30,316
0,22,426,-58,-242
95,$GPRMC,115532.700,A,5217.0942,N,00007.4699,E,0.48,326.53,080515,,,A*67

109,10C,898
47,20,-580,-14420,-8424
0,21,-108,-25,353
0,22,423,-59,-247
95,$GPRMC,115533.000,A,5217.0951,N,00007.4682,E,0.25,326.53,080515,,,A*62

108,10D,0
50,20,-852,-14100,-8352
0,21,-104,-5,284
0,22,425,-55,-243
94,$GPRMC,115533.200,A,5217.0959,N,00007.4674,E,0.20,326.53,080515,,,A*64

116,104,22
46,20,-664,-14184,-8544
0,21,-168,15,288
0,22,422,-60,-244
95,0007.4673,E,0.12,326.53,080515,,,A*6F

109,111,12
46,20,-596,-14084,-8416
0,21,8,-47,350
0,22,427,-65,-243
95,A*33

108,133,101
51,20,-640,-14228,-8560
0,21,-62,-23,333
0,22,427,-61,-243
94,0007.4681,E,0.08,326.53,080515,,,A*60

106,10C,667
47,20,-608,-14332,-8244
0,21,14,-72,364
0,22,426,-60,-246
95,A*3F

107,10D,0
47,20,-752,-14316,-8124
0,21,1,-34,342
0,22,420,-62,-246
94,0007.4680,E,0.09,326.53,080515,,,A*64

100,104,29
46,20,-692,-14200,-8240
0,21,-117,-27,311
0,22,426,-60,-248
95,0007.4678,E,0.08,326.53,080515,,,A*60

109,111,12
46,20,-640,-14220,-8568
0,21,-129,-21,303
0,22,430,-62,-238
95,0007.4679,E,0.11,326.53,080515,,,A*65

120,131,9671
47,20,-736,-14420,-8448
0,21,-192,-19,351
0,22,424,-64,-242
94,A*38

100,10C,714
47,20,-728,-14368,-8576
0,21,-127,-12,326
0,22,429,-57,-247
95,0007.4680,E,0.18,326.53,080515,,,A*6F

115,10D,0
48,20,-596,-14400,-8388
0,21,-97,-26,307
0,22,430,-60,-248
94,A*31

108,104,45
47,20,-952,-14320,-8352
0,21,-212,6,271
0,22,424,-60,-248


This is what my NMEA logging code looks like,

Code: Select all

#if LOG_GPS_NMEA_DATA
        char buf[90];
        byte i=0;
        write("ATGRR\r");
        dataTime = millis();
        for (;;) {
            if (available()) {
                char c = read();
                if (c == '>') {
                    // prompt char received
                    break;
                } else {
#if VERBOSE
                    SerialInfo.write(c);
#endif
                    //logData(c);
                   
                    if (i<89) {                     
                      buf[i] = c;
                      i = i+1;
                    }

                }
            } else if (millis() - dataTime > 100) {
                // timeout
                break;
            }
        }
       
        buf[i] = '\0';
        recordData(buf);
#endif


Any suggestions what I might be going wrong here?
stanley
Site Admin
Posts: 1039
Joined: Sat Mar 01, 2014 3:15 am

Re: Issues with NMEA logging

Post by stanley »

The latest sketch has improved NMEA logging. Please try it out.
Post Reply