ttlappalainen / NMEA0183

Library for handling NMEA0183 messages
69 stars 44 forks source link

RMC sentence field GPS time missing leading zeros #56

Closed jmattioni closed 6 months ago

jmattioni commented 6 months ago

Traced this to function NMEA0183SetRMC - the AddTimeField call in this function is passing format "%06f", which fails to add leading zeros to the formatted time value. Passing "%06.0f" fixed the problem.

ttlappalainen commented 6 months ago

On that function it uses default value for format and as I see declaration is bool AddTimeField(double GPSTime, const char *Format="%09.2f"); Where do you have "%06f"

jmattioni commented 6 months ago

The reference is in function NMEA0183SetRMC, which I see doesn't use a format override. Sorry, I must have put the format override in the AddTimeField call myself. For GPRMC messages, most examples I've found don't include fractional seconds so the GPS time field length would always be 6 padded with zeros and no decimal. What was in my copy of the code was a format override of "%06f", which failed to pad zeros. I changed it to "%06.0f" and it worked.

ttlappalainen commented 6 months ago

Devices should also handle time given in 2 decimals.

RMC: $--RMC,hhmmss.ss,A,ddmm.mm,a,dddmm.mm,a,x.x,x.x,xxxx,x.x,ahh NMEA 2.3: $--RMC,hhmmss.ss,A,ddmm.mm,a,dddmm.mm,a,x.x,x.x,xxxx,x.x,a,mhh NMEA 4.1: $--RMC,hhmmss.ss,A,ddmm.mm,a,dddmm.mm,a,x.x,x.x,xxxx,x.x,a,m,s*hh

jmattioni commented 6 months ago

You're right. I just confirmed that the Yamaha 6Y80-01 square gauge on my bench works with the library default format.

Thanks.