Skip to content

Extending NMEA-Types #146

Answered by Knio
chrissli asked this question in Q&A
Jul 22, 2022 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

You were very close.

  • you need to inherit from ProprietarySentence
  • your class name must be XBO, this is what matches on the PXBO string
  • you need an extra unused field at the beginning - this is because some proprietary sentences have an extra comma and some don't
  • no need to assign pynmea2.XBO (unless you want to), just defining the class is enough
  • vars() will not show the fields, since they're dynamically accessed, but repr() will
import pynmea2

class XBO(pynmea2.nmea.ProprietarySentence):
    fields = (
        ("Blank", "_blank"),
        ('Temperature(outside)','temperature'),
        ('Pressure','pressure'),
        ('Humidity','humidity')
    )

line = 'PXBO,23.3,992.2,56'
nmeaObj = 

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@chrissli
Comment options

@chrissli
Comment options

Answer selected by chrissli
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants