Skip to content

Implement GSV and GSA parsing #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 23, 2021
Merged

Implement GSV and GSA parsing #54

merged 6 commits into from
Feb 23, 2021

Conversation

lesamouraipourpre
Copy link
Contributor

This PR aims to get GSA and GSV message parsing operational.
This will hopefully close #51 and #52.

For the talkers #52:
In the update() method the data_type is now split into: talker (first two characters) and sentence_type (remaining three characters)
The talker is the source of the message. For now, I've only listed the GNSS sources, eg. GA (Galileo), GB (BeiDou) etc.
NB: GN as a talker means the information is from more than one source.
The sentence_type is the sentence type of the message. Eg. GLL (Geographic Position - Lat/Long), GSV (Satellites in View) etc.
Separating these out makes it easier to add extra talkers and sentence_types later if needed.

For GSA and GSV #51:
This has been reworked with the aim of handling messages from multiple sources, for example I receive sentences from GPS and GLONASS. Unlike some sentence_types, I've never received GN (multi-source information) messages for GSA and GSV, they are always from a single satellite network.
The satellite information that is stored in the self.sats dictionary has been modified to have a key based on the source of the information, eg. GP17 for GPS satellite 17, GL78 for GLONNASS satellite etc.
The value stored is now a 5-value tuple: (Key/Satellite ID, Elevation, Azimuth, SNR, Timestamp)
The timestamp is the time.monotonic() that the information was received. This will be used to delete any entries which are older than 30 seconds.

Hardware tested:
I have the Adafruit Mini GPS PA1010D - UART and I2C - STEMMA QT

Example Code:
There is an example in examples/gps_satellitefix.py

This is listed as draft because it needs more testing, preferably with different GPS chips. I would appreciate if others are able to run this and see what breaks.
Also, any feedback on whether the changes made are appropriate or need further work are greatly appreciated.

Enable GSV (satellites in view) parsing.

Rewrote the GSA and GSV parsing to handle each satellite system
(talker) separately.
- self.sats now uses keys based upon the talker and satellite
  number, eg. GL67 for GLONASS #67, GP7 for GPS #7
- When the end message of a GSV sequence is received, eg. 3 of 3,
  all previous records in self.sats matching that talker are removed
  before adding the updated ones.
- self.sat_prns stores the last satellite IDs that were used for a
  fix and returned in the most recent GSA sentence. They will be
  from only one Satellite system and should have a record in
  self.sats .
 to when it was received.

The data stored in self.sats dictionary is:
  key is TTNN where
    TT = the talker name, eg. GL for GLONASS
    NN = the number of the satellite, currently a 1 or 2 digit number
  value is a 5 entry list (V0, V1, V2, V3, V4)
    V0 = satellite number TTNN as used for the key
    V1 = satellite elevation in degrees
    V2 = satellite azimuth in degrees
    V3 = satellite signal to noise ratio in dB, or None
    V4 = timestamp, time.monotonic(), of last GSV message
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't test but the code looks good! I like that you split the talker out. I didn't know that was the format. :-) Thanks!

@lesamouraipourpre lesamouraipourpre marked this pull request as ready for review February 22, 2021 09:39
@lesamouraipourpre
Copy link
Contributor Author

I've switched this from Draft as I have a list of further improvements that I intend to work on for GPS.

@tannewt
Copy link
Member

tannewt commented Feb 23, 2021

What device did you test this code on? Was it running Blinka or CircuitPython? I see the example has f-strings and I want to makes sure this was tested on CircuitPython.

@lesamouraipourpre
Copy link
Contributor Author

It as developed on a Raspberry Pi 3, but tested on a PyPortal Pynt and an Unexpected Maker FeatherS2 both running CP 6.2 beta.

@tannewt
Copy link
Member

tannewt commented Feb 23, 2021

Ok, great! Thank you!

@tannewt tannewt merged commit 1b80dea into adafruit:master Feb 23, 2021
@lesamouraipourpre lesamouraipourpre deleted the parse-gsa-and-gsv branch February 23, 2021 20:46
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Feb 26, 2021
Updating https://github.com/adafruit/Adafruit_CircuitPython_DS18X20 to 1.3.4 from 1.3.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_DS18X20#21 from adafruit/dherrada-patch-1

Updating https://github.com/adafruit/Adafruit_CircuitPython_EPD to 2.8.0 from 2.7.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_EPD#45 from makermelissa/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_GPS to 3.7.0 from 3.6.8:
  > Merge pull request adafruit/Adafruit_CircuitPython_GPS#54 from lesamouraipourpre/parse-gsa-and-gsv

Updating https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display to 3.10.6 from 3.10.5:
  > Merge pull request adafruit/Adafruit_CircuitPython_RGB_Display#90 from makermelissa/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_SSD1306 to 2.11.0 from 2.10.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_SSD1306#57 from adamcandy/add-page-addressing-mode

Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Button to 1.5.2 from 1.5.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Button#27 from FoamyGuy/resizeable_button

Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Text to 2.15.0 from 2.14.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#111 from FoamyGuy/wrap_by_pixels

Updating https://github.com/adafruit/Adafruit_CircuitPython_LED_Animation to 2.5.3 from 2.5.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_LED_Animation#75 from adafruit/REUSE
  > Hardcoded Black and REUSE versions
  > Added pre-commit-config file
  > Added pre-commit and SPDX copyright

Updating https://github.com/adafruit/Adafruit_CircuitPython_MiniMQTT to 5.0.3 from 5.0.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_MiniMQTT#65 from brentru/update-cpython-example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

_parse_gpgsa and _parse_gpgsv are unused.
2 participants