From 16a56d7285e05a5c18e02847d97722a42f14d8fc Mon Sep 17 00:00:00 2001 From: Joep de Jong Date: Thu, 18 Apr 2024 11:27:10 +0000 Subject: [PATCH 1/3] Add heave type Signed-off-by: Joep de Jong Signed-off-by: GitHub --- pynmea2/types/talker.py | 8 ++++++++ test/test_types.py | 12 +++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/pynmea2/types/talker.py b/pynmea2/types/talker.py index 6b56687..55e9cb6 100644 --- a/pynmea2/types/talker.py +++ b/pynmea2/types/talker.py @@ -1098,3 +1098,11 @@ class LAA(TalkerSentence): ("ClimbRate","ClimbRate"), ("Type","Type"), ) + +# Implemented by Joep de Jong +# GPHEV: Heave +class HEV(TalkerSentence): + """ + Heave + """ + fields = (("Heave", "heave", float),) \ No newline at end of file diff --git a/test/test_types.py b/test/test_types.py index 22f4123..b37e2f9 100644 --- a/test/test_types.py +++ b/test/test_types.py @@ -330,4 +330,14 @@ def test_ALR(): assert msg.alarm_num == '006' assert msg.alarm_con == 'V' assert msg.alarm_state == 'V' - assert msg.description == 'AIS:general failure' \ No newline at end of file + assert msg.description == 'AIS:general failure' + + +def test_HEV(): + data = "$GPHEV,-0.01*52" + msg = pynmea2.parse(data) + assert msg.render() == data + assert isinstance(msg, pynmea2.HEV) + assert msg.talker == "GP" + assert msg.sentence_type == "HEV" + assert msg.heave == -0.01 \ No newline at end of file From 7b9bfb36512ae325555bf893c3bedc23f5153a5d Mon Sep 17 00:00:00 2001 From: Joep de Jong Date: Thu, 18 Apr 2024 11:29:09 +0000 Subject: [PATCH 2/3] Add Furuno proprietary types Signed-off-by: Joep de Jong Signed-off-by: GitHub --- pynmea2/types/proprietary/__init__.py | 1 + pynmea2/types/proprietary/fec.py | 61 +++++++++++++++++++++++++++ test/test_fec.py | 21 +++++++++ 3 files changed, 83 insertions(+) create mode 100644 pynmea2/types/proprietary/fec.py create mode 100644 test/test_fec.py diff --git a/pynmea2/types/proprietary/__init__.py b/pynmea2/types/proprietary/__init__.py index e9be193..83aff16 100644 --- a/pynmea2/types/proprietary/__init__.py +++ b/pynmea2/types/proprietary/__init__.py @@ -1,4 +1,5 @@ from . import ash +from . import fec from . import grm from . import kwd from . import mgn diff --git a/pynmea2/types/proprietary/fec.py b/pynmea2/types/proprietary/fec.py new file mode 100644 index 0000000..86f5e76 --- /dev/null +++ b/pynmea2/types/proprietary/fec.py @@ -0,0 +1,61 @@ +''' +Support for proprietary messages from Furuno receivers. +''' +# Implemented by Joep de Jong +# pylint: disable=wildcard-import,unused-wildcard-import + +from ... import nmea +from ...nmea_utils import * + + +class FEC(nmea.ProprietarySentence): + sentence_types = {} + + def __new__(_cls, manufacturer, data): + name = manufacturer + data[1] + print(data) + cls = _cls.sentence_types.get(name, _cls) + return super(FEC, cls).__new__(cls) + + # def __init__(self, manufacturer, data): + # self.sentence_type = manufacturer + data[0] + # super(FEC, self).__init__(manufacturer, data) + +class FECGPatt(FEC): + """ + Furuno GPatt Message + + $PFEC,GPatt,aaa.a,bb.b,cc.c,*hh + $PFEC: Talker identifier + sentence formatter* + GPatt: Global positioning attitude, sentence formatter + aaa.a: Yaw (degrees)* + bb.b: Pitch (degrees)* + cc.c: Roll (degrees)* + *hh: Checksum* + """ + fields = ( + ('R', '_r'), + ('Subtype', 'subtype'), + ('Yaw', 'yaw', float), + ('Pitch', 'pitch', float), + ('Roll', 'roll', float), + ) + + +class FECGPhve(FEC): + """ + Furuno GPatt Message + + $PFEC,GPhve,xx.xxx,A*hh + $PFEC: Talker identifier + GPhve: Datagram identifier + xx.xxx: Heave (Metres) + A: Status + *hh: Checksum + """ + + fields = ( + ("R", "_r"), + ("Subtype", "subtype"), + ("Heave", "heave", float), + ) diff --git a/test/test_fec.py b/test/test_fec.py new file mode 100644 index 0000000..c66d77b --- /dev/null +++ b/test/test_fec.py @@ -0,0 +1,21 @@ +import pynmea2 + + +def test_fecgpatt(): + data = "$PFEC,GPatt,294.7,-02.5,+00.4*45" + msg = pynmea2.parse(data) + assert type(msg) == pynmea2.fec.FECGPatt + assert msg.manufacturer == 'FEC' + assert msg.yaw == 294.7 + assert msg.pitch == -2.5 + assert msg.roll == 0.4 + assert msg.render() == data + + +def test_fecgphve(): + data = "$PFEC,GPhve,00.007,A*08" + msg = pynmea2.parse(data) + assert type(msg) == pynmea2.fec.FECGPhve + assert msg.manufacturer == "FEC" + assert msg.heave == 0.007 + assert msg.render() == data From a32602c79eae6682181d8326cd8869453a9bfe89 Mon Sep 17 00:00:00 2001 From: Joep de Jong Date: Thu, 18 Apr 2024 11:48:35 +0000 Subject: [PATCH 3/3] Cleanup Furuno --- pynmea2/types/proprietary/fec.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pynmea2/types/proprietary/fec.py b/pynmea2/types/proprietary/fec.py index 86f5e76..201c1ae 100644 --- a/pynmea2/types/proprietary/fec.py +++ b/pynmea2/types/proprietary/fec.py @@ -7,20 +7,14 @@ from ... import nmea from ...nmea_utils import * - class FEC(nmea.ProprietarySentence): sentence_types = {} def __new__(_cls, manufacturer, data): name = manufacturer + data[1] - print(data) cls = _cls.sentence_types.get(name, _cls) return super(FEC, cls).__new__(cls) - # def __init__(self, manufacturer, data): - # self.sentence_type = manufacturer + data[0] - # super(FEC, self).__init__(manufacturer, data) - class FECGPatt(FEC): """ Furuno GPatt Message