Skip to content

Commit

Permalink
Add hbt and alr (#161)
Browse files Browse the repository at this point in the history
* Add ALR and HBT sentences

* Add ALR and HBT sentences
  • Loading branch information
nalia3486 authored Oct 17, 2023
1 parent 36cca57 commit b546a71
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
28 changes: 28 additions & 0 deletions pynmea2/types/talker.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ class ALM(TalkerSentence):
)


class ALR(TalkerSentence):
""" Set alarm state
$--ALR,hhmmss.ss,xxx,A,A,c--c*hh<CR><LF>
"""
fields = (
('Time of alarm condition change, UTC', 'timestamp', timestamp),
('Unique alarm number (identifier) at alarm source', 'alarm_num'),
('Alarm condition (A=threshold exceeded, V=not exceeded)', 'alarm_con'),
('Alarm\'s acknowledge state (A=acknowledged, V=unacknowledged)', 'alarm_state'),
('Alarm\'s description text', 'description'),
)


class APA(TalkerSentence):
""" Autopilot Sentence "A"
"""
Expand Down Expand Up @@ -283,6 +296,21 @@ class GSV(TalkerSentence):
) # 00-99 dB


class HBT(TalkerSentence):
""" Heartbeat supervision sentence
Format: $--HBT,<1>,<2>,<3>*hh<CR><LF>
e.g. $AIHBT,30,A,5*0D
<1> Configured repeat interval
<2> Equipment status
<3> Sequential sentence identifier
"""
fields = (
("Configured repeat interval", "interval", float),
("Equipment status", "eq_status"),
("Sequential sentence identifier", "seq_sent_iden", int),
)


class HDG(TalkerSentence):
""" NMEA 0183 standard Heading, Deviation and Variation
Format: $HCHDG,<1>,<2>,<3>,<4>,<5>*hh<CR><LF>
Expand Down
25 changes: 25 additions & 0 deletions test/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,3 +306,28 @@ def test_GRS():
assert msg.sv_res_05 == -0.1
assert msg.sv_res_06 == 0.5
assert msg.sv_res_07 == None


def test_HBT():
data = "$AIHBT,30,A,1*09"
msg = pynmea2.parse(data)
assert msg.render() == data
assert isinstance(msg, pynmea2.HBT)
assert msg.talker == 'AI'
assert msg.sentence_type == 'HBT'
assert msg.interval == 30
assert msg.eq_status == 'A'
assert msg.seq_sent_iden == 1


def test_ALR():
data = "$AIALR,,006,V,V,AIS:general failure*1A"
msg = pynmea2.parse(data)
assert msg.render() == data
assert isinstance(msg, pynmea2.ALR)
assert msg.talker == 'AI'
assert msg.sentence_type == 'ALR'
assert msg.alarm_num == '006'
assert msg.alarm_con == 'V'
assert msg.alarm_state == 'V'
assert msg.description == 'AIS:general failure'

0 comments on commit b546a71

Please sign in to comment.