Skip to content
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

Add heave and Furuno types #166

Merged
merged 3 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pynmea2/types/proprietary/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from . import ash
from . import fec
from . import grm
from . import kwd
from . import mgn
Expand Down
55 changes: 55 additions & 0 deletions pynmea2/types/proprietary/fec.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
'''
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]
cls = _cls.sentence_types.get(name, _cls)
return super(FEC, cls).__new__(cls)

class FECGPatt(FEC):
"""
Furuno GPatt Message

$PFEC,GPatt,aaa.a,bb.b,cc.c,*hh<CR><LF>
$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<CR><LF>
$PFEC: Talker identifier
GPhve: Datagram identifier
xx.xxx: Heave (Metres)
A: Status
*hh: Checksum
"""

fields = (
("R", "_r"),
("Subtype", "subtype"),
("Heave", "heave", float),
)
8 changes: 8 additions & 0 deletions pynmea2/types/talker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),)
21 changes: 21 additions & 0 deletions test/test_fec.py
Original file line number Diff line number Diff line change
@@ -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
12 changes: 11 additions & 1 deletion test/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
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
Loading