andrethemac / L76GLNSV4

MicroPython library for quectel L76 glnss gps on pycom pytrack
MIT License
18 stars 16 forks source link

Missing NMEA 4.10 Keywords from RMC, GSA, GSV (Was: RMC Messages being skipped) #6

Closed askpatrickw closed 4 years ago

askpatrickw commented 4 years ago

I'm learning the library and I may be making mistakes so please to point me in the right direction if I'm wrong. It seems as though no RMC based functionality is working, but I see RMC messages in the debug output.

See in this log stream that I ask for an RMC message and none is found, but there is one in the log.

>>>> L76.gps_message('RMC',debug=True)
RMC
messagetype RMC
nmea raw 255 22 b',W,070802.000,A,A*52\r\n$GNRMC,070803.000,A,4737.0000,N,12220.0000,W,0.00,87.63,190320,,,A,V*25\r\n$GPVTG,87.63,T,,M,0.00,N,0.00,K,A*07\r\n$GPGGA,070803.000,4737.0000,N,12220.0000,W,1,6,3.47,41.8,M,-17.3,M,,*53\r\n$GNGSA,A,3,26,27,16,10,,,,,,,,,3.61,3.47,0.98,1*\n'
nmea raw fix False 71 $GNRMC,070803.000,A,4737.0000,N,12220.0000,W,0.00,87.63,190320,,,A,V*25
RMC -> ['RMC', '070803.000', 'A', '4737.0000', 'N', '12220.0000', 'W', '0.00', '87.63', '190320', '', '', 'A', 'V']
nmea_message None

I spent a good hour looking at _RMC() in the library and couldn't see anything wrong. When I take the message from the logs: msg = ['RMC', '070803.000', 'A', '4737.0000', 'N', '12220.0000', 'W', '0.00', '87.63', '190320', '', '', 'A', 'V'] and the keywords in the function and run dict(zip(keywords, msg)) as in _mixhash(), I get a perfectly formatted DICT so I'm stumped.

This seems to be breaking the following functionality all of which simply run indefinitely:

If you can point the way, I'm happy to do a PR and test the fix. tx!

askpatrickw commented 4 years ago

Sleep and many print statements can do wondrous things... lengthy exploration and explanation follows:

This is what _mixhash sees for an RMC mesage:

keywords: ['NMEA', 'UTCTime', 'dataValid', 'Latitude', 'NS', 'Longitude',
           'EW', 'Speed', 'COG', 'Date', '', '', 'PositioningMode']
len(keywords): 13
sentence: ['RMC', '181820.000', 'A', '4737.1629', 'N', '12221.2071', 'W', '0.00',
           '118.29', '190320', '', '', 'A', 'V']
len(sentence): 14

In _mixhash() the sentence is padded (+= ['',] ) if it is shorter than the keywords, but the case where the sentence is longer is not handled and so keywords and sentence are never the same length and RMC messages fall through to the final else which returns None.

What appears to be the issue is that the keywords for _RMC() is missing NavigationalStatus. Which is listed on page 9 of Quectel_L76_Series_GNSS_Protocol_Specification_V3.3.pdf. and it also notes this message attribute is "Only supported for NMEA V4.10".

Also in the specification it says:

"Please note that L76NR03A01S version of L76 and L76LNR02A01S version of L76-L use NMEA V4.10. It will change the format of RMC, GSA and GSV sentences."

My Quectel Chip does not have the full model number stamped on it, but I see NMEA 4.10 data so therefore I'm assuming that's the case. It is worth following up with Pycom to see if ALL the Quectel chips on their boards. I cannot post to their forum. I pinged them on Twitter and will update if\when I get a response.

Planned Fix

  1. Add NavigationalStatus to _RMC() keywords list as per page 9 in spec.
  2. Add GNSSSystemId to _GSA() keywords list as per page 13 in spec.
  3. Add SignalId to _GSV() keywords list as per page page 15 in spec.

PR to come...

askpatrickw commented 4 years ago

Attaching the Quectel L76-L GNS Protocol Spec v3.3. This should probably go in the repo or wiki?

Quectel_L76_Series_GNSS_Protocol_Specification_V3.3.pdf

andrethemac commented 4 years ago

Hi Patrick. The gps chip I have on my board is L76LNR01A01SC, way older than yours. The spec I found back then was even v1.5. There was no NavigationalStatus back then. I try to find some time to add wiki with links to the original pdf's. If you have a fix, I will gladly look at it.. Andre

andrethemac commented 4 years ago

Hi Patrick I've changed your fix a bit to make it work on older versions to. Can you test it? it's in the fixfor4.10 branch. best regard André

askpatrickw commented 4 years ago

I’ll look at this and let you know.