Skip to content

Commit e6fa0a7

Browse files
authored
Merge pull request #88 from aldas/sentences
Add a lot of new sentences. * [AAM](./aam.go) - Waypoint Arrival Alarm * [ALA](./ala.go) - System Faults and alarms * [APB](./apb.go) - Autopilot Sentence "B" * [BEC](./bec.go) - Bearing and distance to waypoint (dead reckoning) * [BOD](./bod.go) - Bearing waypoint to waypoint (origin to destination). * [BWC](./bwc.go) - Bearing and distance to waypoint, great circle * [BWR](./bwr.go) - Bearing and distance to waypoint (Rhumb Line) * [BWW](./bww.go) - bearing (from destination) destination waypoint to origin waypoint * [DBK](./dbk.go) - Depth Below Keel (obsolete, use DPT instead) * [DOR](./dor.go) - Door Status Detection * [DSC](./dsc.go) - Digital Selective Calling Information * [DSE](./dse.go) - Expanded digital selective calling * [EVE](./eve.go) - General Event Message * [FIR](./fir.go) - Fire Detection event with time and location * [HSC](./hsc.go) - Heading steering command * [MTA](./mta.go) - Air Temperature (obsolete, use XDR instead) * [RMB](./rmb.go) - Recommended Minimum Navigation Information * [RPM](./rpm.go) - Engine or Shaft revolutions and pitch * [RSA](./rsa.go) - Rudder Sensor Angle * [VDR](./vdr.go) - Set and Drift * [VLW](./vlw.go) - Distance Traveled through Water * [VPW](./vpw.go) - Speed Measured Parallel to Wind * [VWR](./vwr.go) - Relative Wind Speed and Angle * [VWT](./vwt.go) - True Wind Speed and Angle * [XDR](./xdr.go) - Transducer Measurement * [XTE](./xte.go) - Cross-track error, measured
2 parents 7315e63 + f4d3e51 commit e6fa0a7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+3783
-92
lines changed

README.md

+55-30
Original file line numberDiff line numberDiff line change
@@ -29,41 +29,66 @@ To update go-nmea to the latest version, use `go get -u github.com/adrianmo/go-n
2929

3030
At this moment, this library supports the following sentence types:
3131

32-
| Sentence type | Description |
33-
|-------------------------------------------------------------------------------|-----------------------------------------------------------|
34-
| [RMC](http://aprs.gids.nl/nmea/#rmc) | Recommended Minimum Specific GPS/Transit data |
35-
| [GGA](http://aprs.gids.nl/nmea/#gga) | GPS Positioning System Fix Data |
36-
| [GSA](http://aprs.gids.nl/nmea/#gsa) | GPS DOP and active satellites |
37-
| [GSV](http://aprs.gids.nl/nmea/#gsv) | GPS Satellites in view |
38-
| [GLL](http://aprs.gids.nl/nmea/#gll) | Geographic Position, Latitude / Longitude and time |
39-
| [VTG](http://aprs.gids.nl/nmea/#vtg) | Track Made Good and Ground Speed |
40-
| [ZDA](http://aprs.gids.nl/nmea/#zda) | Date & time data |
41-
| [HDT](http://aprs.gids.nl/nmea/#hdt) | Actual vessel heading in degrees True |
42-
| [HDG](https://gpsd.gitlab.io/gpsd/NMEA.html#_hdg_heading_deviation_variation) | Heading, Deviation & Variation |
43-
| [HDM](https://gpsd.gitlab.io/gpsd/NMEA.html#_hdm_heading_magnetic) | Heading - Magnetic |
44-
| [GNS](https://gpsd.gitlab.io/gpsd/NMEA.html#_gns_fix_data) | Combined GPS fix for GPS, Glonass, Galileo, and BeiDou |
45-
| [VDM/VDO](https://gpsd.gitlab.io/gpsd/AIVDM.html) | Encapsulated binary payload (commonly used with AIS data) |
46-
| [WPL](http://aprs.gids.nl/nmea/#wpl) | Waypoint location |
47-
| [RTE](http://aprs.gids.nl/nmea/#rte) | Route |
48-
| [ROT](https://gpsd.gitlab.io/gpsd/NMEA.html#_rot_rate_of_turn) | Rate of turn |
49-
| [VHW](https://www.tronico.fi/OH6NT/docs/NMEA0183.pdf) | Water Speed and Heading |
50-
| [DPT](https://gpsd.gitlab.io/gpsd/NMEA.html#_dpt_depth_of_water) | Depth of Water |
51-
| [DBS](https://gpsd.gitlab.io/gpsd/NMEA.html#_dbs_depth_below_surface) | Depth Below Surface |
52-
| [DBT](https://gpsd.gitlab.io/gpsd/NMEA.html#_dbt_depth_below_transducer) | Depth below transducer |
53-
| [MDA](https://gpsd.gitlab.io/gpsd/NMEA.html#_mda_meteorological_composite) | Meteorological Composite |
54-
| [MWD](https://www.tronico.fi/OH6NT/docs/NMEA0183.pdf) | Wind Direction and Speed |
55-
| [MWV](https://gpsd.gitlab.io/gpsd/NMEA.html#_mwv_wind_speed_and_angle) | Wind Speed and Angle |
56-
| [MTW](https://gpsd.gitlab.io/gpsd/NMEA.html#_mtw_mean_temperature_of_water) | Mean Temperature of Water |
57-
| [THS](http://www.nuovamarea.net/pytheas_9.html) | Actual vessel heading in degrees True and status |
58-
| [TXT](https://www.nmea.org/Assets/20160520%20txt%20amendment.pdf) | Sentence is for the transmission of text messages |
32+
| Sentence type | Description |
33+
|-----------------------------------------------------------------------------------------------|-----------------------------------------------------------|
34+
| [AAM](https://gpsd.gitlab.io/gpsd/NMEA.html#_aam_waypoint_arrival_alarm) | Waypoint Arrival Alarm |
35+
| [ALA](./ala.go) | System Faults and Alarms |
36+
| [APB](https://gpsd.gitlab.io/gpsd/NMEA.html#_apb_autopilot_sentence_b) | Autopilot Sentence "B" |
37+
| [BEC](http://www.nmea.de/nmea0183datensaetze.html#bec) | Bearing and distance to waypoint (dead reckoning) |
38+
| [BOD](https://gpsd.gitlab.io/gpsd/NMEA.html#_bod_bearing_waypoint_to_waypoint) | Bearing waypoint to waypoint (origin to destination) |
39+
| [BWC](https://gpsd.gitlab.io/gpsd/NMEA.html#_bwc_bearing_distance_to_waypoint_great_circle) | Bearing and distance to waypoint (great circle) |
40+
| [BWR](https://gpsd.gitlab.io/gpsd/NMEA.html#_bwr_bearing_and_distance_to_waypoint_rhumb_line) | Bearing and distance to waypoint (Rhumb Line) |
41+
| [BWW](https://gpsd.gitlab.io/gpsd/NMEA.html#_bww_bearing_waypoint_to_waypoint) | Bearing from destination waypoint to origin waypoint |
42+
| [DBK](https://gpsd.gitlab.io/gpsd/NMEA.html#_dbk_depth_below_keel) | Depth Below Keel (obsolete, use DPT instead) |
43+
| [DBS](https://gpsd.gitlab.io/gpsd/NMEA.html#_dbs_depth_below_surface) | Depth Below Surface (obsolete, use DPT instead) |
44+
| [DBT](https://gpsd.gitlab.io/gpsd/NMEA.html#_dbt_depth_below_transducer) | Depth below transducer |
45+
| [DOR](./dor.go) | Door Status Detection |
46+
| [DPT](https://gpsd.gitlab.io/gpsd/NMEA.html#_dpt_depth_of_water) | Depth of Water |
47+
| [DSC](./dsc.go) | Digital Selective Calling Information |
48+
| [DSE](./dse.go) | Expanded digital selective calling |
49+
| [EVE](./eve.go) | General Event Message |
50+
| [FIR](./fir.go) | Fire Detection event with time and location |
51+
| [GGA](http://aprs.gids.nl/nmea/#gga) | GPS Positioning System Fix Data |
52+
| [GLL](http://aprs.gids.nl/nmea/#gll) | Geographic Position, Latitude / Longitude and time |
53+
| [GNS](https://gpsd.gitlab.io/gpsd/NMEA.html#_gns_fix_data) | Combined GPS fix for GPS, Glonass, Galileo, and BeiDou |
54+
| [GSA](http://aprs.gids.nl/nmea/#gsa) | GPS DOP and active satellites |
55+
| [GSV](http://aprs.gids.nl/nmea/#gsv) | GPS Satellites in view |
56+
| [HDG](https://gpsd.gitlab.io/gpsd/NMEA.html#_hdg_heading_deviation_variation) | Heading, Deviation & Variation |
57+
| [HDM](https://gpsd.gitlab.io/gpsd/NMEA.html#_hdm_heading_magnetic) | Heading - Magnetic |
58+
| [HDT](http://aprs.gids.nl/nmea/#hdt) | Actual vessel heading in degrees True |
59+
| [HSC](https://gpsd.gitlab.io/gpsd/NMEA.html#_hsc_heading_steering_command) | Heading steering command |
60+
| [MDA](https://gpsd.gitlab.io/gpsd/NMEA.html#_mda_meteorological_composite) | Meteorological Composite |
61+
| [MTA](./mta.go) | Air Temperature (obsolete, use XDR instead) |
62+
| [MTW](https://gpsd.gitlab.io/gpsd/NMEA.html#_mtw_mean_temperature_of_water) | Mean Temperature of Water |
63+
| [MWD](https://www.tronico.fi/OH6NT/docs/NMEA0183.pdf) | Wind Direction and Speed |
64+
| [MWV](https://gpsd.gitlab.io/gpsd/NMEA.html#_mwv_wind_speed_and_angle) | Wind Speed and Angle |
65+
| [RMB](https://gpsd.gitlab.io/gpsd/NMEA.html#_rmb_recommended_minimum_navigation_information) | Recommended Minimum Navigation Information |
66+
| [RMC](http://aprs.gids.nl/nmea/#rmc) | Recommended Minimum Specific GPS/Transit data |
67+
| [ROT](https://gpsd.gitlab.io/gpsd/NMEA.html#_rot_rate_of_turn) | Rate of turn |
68+
| [RPM](https://gpsd.gitlab.io/gpsd/NMEA.html#_rpm_revolutions) | Engine or Shaft revolutions and pitch |
69+
| [RSA](https://gpsd.gitlab.io/gpsd/NMEA.html#_rsa_rudder_sensor_angle) | Rudder Sensor Angle |
70+
| [RTE](http://aprs.gids.nl/nmea/#rte) | Route |
71+
| [THS](http://www.nuovamarea.net/pytheas_9.html) | Actual vessel heading in degrees True and status |
72+
| [TXT](https://www.nmea.org/Assets/20160520%20txt%20amendment.pdf) | Sentence is for the transmission of text messages |
73+
| [VDM/VDO](https://gpsd.gitlab.io/gpsd/AIVDM.html) | Encapsulated binary payload (commonly used with AIS data) |
74+
| [VDR](https://gpsd.gitlab.io/gpsd/NMEA.html#_vdr_set_and_drift) | Set and Drift |
75+
| [VHW](https://www.tronico.fi/OH6NT/docs/NMEA0183.pdf) | Water Speed and Heading |
76+
| [VLW](https://gpsd.gitlab.io/gpsd/NMEA.html#_vlw_distance_traveled_through_water) | Distance Traveled through Water |
77+
| [VPW](https://gpsd.gitlab.io/gpsd/NMEA.html#_vpw_speed_measured_parallel_to_wind) | Speed Measured Parallel to Wind |
78+
| [VTG](http://aprs.gids.nl/nmea/#vtg) | Track Made Good and Ground Speed |
79+
| [VWR](https://gpsd.gitlab.io/gpsd/NMEA.html#_vwr_relative_wind_speed_and_angle) | Relative Wind Speed and Angle |
80+
| [VWT](./vwt.go) | True Wind Speed and Angle |
81+
| [WPL](http://aprs.gids.nl/nmea/#wpl) | Waypoint location |
82+
| [XDR](https://gpsd.gitlab.io/gpsd/NMEA.html#_xdr_transducer_measurement) | Transducer Measurement |
83+
| [ZDA](http://aprs.gids.nl/nmea/#zda) | Date & time data |
5984

6085
| Proprietary sentence type | Description |
6186
|-------------------------------------------------------------|-------------------------------------------------------------------------------------------------|
62-
| [PMTK](https://www.rhydolabz.com/documents/25/PMTK_A11.pdf) | Messages for setting and reading commands for MediaTek gps modules. |
6387
| [PGRME](http://aprs.gids.nl/nmea/#rme) | Estimated Position Error (Garmin proprietary sentence) |
64-
| [PSONCMS](#) | Quaternion, acceleration, rate of turn, magnetic field, sensor temperature (Xsens IMU/VRU/AHRS) |
65-
| [PRDID](#) | Vessel pitch, roll and heading (Xsens IMU/VRU/AHRS) |
6688
| [PHTRO](#) | Vessel pitch and roll (Xsens IMU/VRU/AHRS) |
89+
| [PMTK](https://www.rhydolabz.com/documents/25/PMTK_A11.pdf) | Messages for setting and reading commands for MediaTek gps modules. |
90+
| [PRDID](#) | Vessel pitch, roll and heading (Xsens IMU/VRU/AHRS) |
91+
| [PSONCMS](#) | Quaternion, acceleration, rate of turn, magnetic field, sensor temperature (Xsens IMU/VRU/AHRS) |
6792

6893
If you need to parse a message that contains an unsupported sentence type you can implement and register your own
6994
message parser and get yourself unblocked immediately. Check the example below to know how

aam.go

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package nmea
2+
3+
const (
4+
// TypeAAM type of AAM sentence for Waypoint Arrival Alarm
5+
TypeAAM = "AAM"
6+
)
7+
8+
// AAM - Waypoint Arrival Alarm
9+
// This sentence is generated by some units to indicate the status of arrival (entering the arrival circle, or passing
10+
// the perpendicular of the course line) at the destination waypoint (source: GPSD).
11+
// https://gpsd.gitlab.io/gpsd/NMEA.html#_aam_waypoint_arrival_alarm
12+
//
13+
// Format: $--AAM,A,A,x.x,N,c--c*hh<CR><LF>
14+
// Example: $GPAAM,A,A,0.10,N,WPTNME*43
15+
type AAM struct {
16+
BaseSentence
17+
// StatusArrivalCircleEntered is warning of arrival to waypoint circle
18+
// * A = Arrival Circle Entered
19+
// * V = not entered
20+
StatusArrivalCircleEntered string
21+
22+
// StatusPerpendicularPassed is warning for perpendicular passing of waypoint
23+
// * A = Perpendicular passed at waypoint
24+
// * V = not passed
25+
StatusPerpendicularPassed string
26+
27+
// ArrivalCircleRadius is radius for arrival circle
28+
ArrivalCircleRadius float64
29+
30+
// ArrivalCircleRadiusUnit is unit for arrival circle radius
31+
ArrivalCircleRadiusUnit string
32+
33+
// DestinationWaypointID is destination waypoint ID
34+
DestinationWaypointID string
35+
}
36+
37+
// newAAM constructor
38+
func newAAM(s BaseSentence) (AAM, error) {
39+
p := NewParser(s)
40+
p.AssertType(TypeAAM)
41+
return AAM{
42+
BaseSentence: s,
43+
StatusArrivalCircleEntered: p.EnumString(0, "arrival circle entered status", WPStatusArrivalCircleEnteredA, WPStatusArrivalCircleEnteredV),
44+
StatusPerpendicularPassed: p.EnumString(1, "perpendicularly passed status", WPStatusPerpendicularPassedA, WPStatusPerpendicularPassedV),
45+
ArrivalCircleRadius: p.Float64(2, "arrival circle radius"),
46+
ArrivalCircleRadiusUnit: p.EnumString(3, "arrival circle radius units", DistanceUnitKilometre, DistanceUnitNauticalMile, DistanceUnitStatuteMile, DistanceUnitMetre),
47+
DestinationWaypointID: p.String(4, "destination waypoint ID"),
48+
}, p.Err()
49+
}

aam_test.go

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package nmea
2+
3+
import (
4+
"github.com/stretchr/testify/assert"
5+
"testing"
6+
)
7+
8+
func TestAAM(t *testing.T) {
9+
var tests = []struct {
10+
name string
11+
raw string
12+
err string
13+
msg AAM
14+
}{
15+
{
16+
name: "good sentence",
17+
raw: "$GPAAM,A,A,0.10,N,WPTNME*32",
18+
msg: AAM{
19+
StatusArrivalCircleEntered: WPStatusArrivalCircleEnteredA,
20+
StatusPerpendicularPassed: WPStatusPerpendicularPassedA,
21+
ArrivalCircleRadius: 0.1,
22+
ArrivalCircleRadiusUnit: DistanceUnitNauticalMile,
23+
DestinationWaypointID: "WPTNME",
24+
},
25+
},
26+
{
27+
name: "invalid nmea: StatusArrivalCircleEntered",
28+
raw: "$GPAAM,x,A,0.10,N,WPTNME*0B",
29+
err: "nmea: GPAAM invalid arrival circle entered status: x",
30+
},
31+
{
32+
name: "invalid nmea: StatusPerpendicularPassed",
33+
raw: "$GPAAM,A,x,0.10,N,WPTNME*0B",
34+
err: "nmea: GPAAM invalid perpendicularly passed status: x",
35+
},
36+
{
37+
name: "invalid nmea: DistanceUnitNauticalMile",
38+
raw: "$GPAAM,A,A,0.10,x,WPTNME*04",
39+
err: "nmea: GPAAM invalid arrival circle radius units: x",
40+
},
41+
}
42+
for _, tt := range tests {
43+
t.Run(tt.name, func(t *testing.T) {
44+
m, err := Parse(tt.raw)
45+
if tt.err != "" {
46+
assert.Error(t, err)
47+
assert.EqualError(t, err, tt.err)
48+
} else {
49+
assert.NoError(t, err)
50+
aam := m.(AAM)
51+
aam.BaseSentence = BaseSentence{}
52+
assert.Equal(t, tt.msg, aam)
53+
}
54+
})
55+
}
56+
}

ala.go

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package nmea
2+
3+
const (
4+
// TypeALA type of ALA sentence for System Faults and alarms
5+
TypeALA = "ALA"
6+
)
7+
8+
// ALA - System Faults and alarms
9+
// Source: "Interfacing Voyage Data Recorder Systems, AutroSafe Interactive Fire-Alarm System, 116-P-BSL336/EE, RevA 2007-01-25,
10+
// Autronica Fire and Security AS " (page 31 | p.8.1.3)
11+
// https://product.autronicafire.com/fileshare/fileupload/14251/bsl336_ee.pdf
12+
//
13+
// Format: $FRALA,hhmmss,aa,aa,xx,xxx,a,a,c-cc*hh<CR><LF>
14+
// Example: $FRALA,143955,FR,OT,00,901,N,V,Syst Fault : AutroSafe comm. OK*4F
15+
type ALA struct {
16+
BaseSentence
17+
18+
// Time is Event Time
19+
Time Time
20+
21+
// SystemIndicator is system indicator of original alarm source. Detector system type with 2 char identifier.
22+
// Values not known
23+
// https://www.nmea.org/Assets/20190303%20nmea%200183%20talker%20identifier%20mnemonics.pdf
24+
SystemIndicator string
25+
26+
// SubSystemIndicator is sub system equipment indicator of original alarm source
27+
SubSystemIndicator string
28+
29+
// InstanceNumber is instance number of equipment/unit/item (00-99)
30+
InstanceNumber int64
31+
32+
// Type is alarm type (000-999)
33+
Type int64
34+
35+
// Condition describes the condition triggering current message
36+
// * N – Normal state (OK)
37+
// * H - Alarm state (fault);
38+
// could be more
39+
Condition string
40+
41+
// AlarmAckState is Alarm's acknowledge state
42+
// * A – Acknowledged
43+
// * H - Harbour mode
44+
// * V – Not acknowledged
45+
// * O - Override
46+
// could be more
47+
AlarmAckState string
48+
49+
// Message's description text (could be cut to fit max packet length)
50+
Message string
51+
}
52+
53+
// newALA constructor
54+
func newALA(s BaseSentence) (ALA, error) {
55+
p := NewParser(s)
56+
p.AssertType(TypeALA)
57+
return ALA{
58+
BaseSentence: s,
59+
Time: p.Time(0, "time"),
60+
SystemIndicator: p.String(1, "system indicator"),
61+
SubSystemIndicator: p.String(2, "subsystem indicator"),
62+
InstanceNumber: p.Int64(3, "instance number"),
63+
Type: p.Int64(4, "type"),
64+
Condition: p.String(5, "condition"), // string as there could be more
65+
AlarmAckState: p.String(6, "alarm acknowledgement state"), // string as there could be more
66+
Message: p.String(7, "message"),
67+
}, p.Err()
68+
}

0 commit comments

Comments
 (0)