You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be convenient to have default constructors for the NMEA types. When using pynmea2 for encoding NMEA messages we now have to provide constructor parameters which are already known to the NMEA types itself.
An example of how the default constructor would look like for the HDG type;
class HDG(TalkerSentence):
""" NOTE! This is a GUESS as I cannot find an actual spec
telling me the fields. Updates are welcome!
"""
fields = (
("Heading", "heading", Decimal),
("Deviation", "deviation", Decimal),
("Deviation Direction", "dev_dir"),
("Variation", "variation", Decimal),
("Variation Direction", "var_dir")
)
def __init__(self, talker=None, sentence_type=None, data=None):
if talker == None:
talker = 'HC'
if sentence_type == None:
sentence_type = 'HDG'
if data == None:
data = [''] * len(self.fields)
super(HDG, self).__init__(talker, sentence_type, data)
having defaults for sentence_type (and manufacturer for proprietary sentences) so that they don't have to be given in the constructor is a good idea. Those fields should possibly be class attributes and not instance attributes anyway.
It would be convenient to have default constructors for the NMEA types. When using pynmea2 for encoding NMEA messages we now have to provide constructor parameters which are already known to the NMEA types itself.
An example of how the default constructor would look like for the HDG type;
The usage would be as followed;
The text was updated successfully, but these errors were encountered: