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

a lot of new sentences #88

Merged
merged 3 commits into from
Jan 3, 2022
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
85 changes: 55 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,41 +29,66 @@ To update go-nmea to the latest version, use `go get -u github.com/adrianmo/go-n

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

| Sentence type | Description |
|-------------------------------------------------------------------------------|-----------------------------------------------------------|
| [RMC](http://aprs.gids.nl/nmea/#rmc) | Recommended Minimum Specific GPS/Transit data |
| [GGA](http://aprs.gids.nl/nmea/#gga) | GPS Positioning System Fix Data |
| [GSA](http://aprs.gids.nl/nmea/#gsa) | GPS DOP and active satellites |
| [GSV](http://aprs.gids.nl/nmea/#gsv) | GPS Satellites in view |
| [GLL](http://aprs.gids.nl/nmea/#gll) | Geographic Position, Latitude / Longitude and time |
| [VTG](http://aprs.gids.nl/nmea/#vtg) | Track Made Good and Ground Speed |
| [ZDA](http://aprs.gids.nl/nmea/#zda) | Date & time data |
| [HDT](http://aprs.gids.nl/nmea/#hdt) | Actual vessel heading in degrees True |
| [HDG](https://gpsd.gitlab.io/gpsd/NMEA.html#_hdg_heading_deviation_variation) | Heading, Deviation & Variation |
| [HDM](https://gpsd.gitlab.io/gpsd/NMEA.html#_hdm_heading_magnetic) | Heading - Magnetic |
| [GNS](https://gpsd.gitlab.io/gpsd/NMEA.html#_gns_fix_data) | Combined GPS fix for GPS, Glonass, Galileo, and BeiDou |
| [VDM/VDO](https://gpsd.gitlab.io/gpsd/AIVDM.html) | Encapsulated binary payload (commonly used with AIS data) |
| [WPL](http://aprs.gids.nl/nmea/#wpl) | Waypoint location |
| [RTE](http://aprs.gids.nl/nmea/#rte) | Route |
| [ROT](https://gpsd.gitlab.io/gpsd/NMEA.html#_rot_rate_of_turn) | Rate of turn |
| [VHW](https://www.tronico.fi/OH6NT/docs/NMEA0183.pdf) | Water Speed and Heading |
| [DPT](https://gpsd.gitlab.io/gpsd/NMEA.html#_dpt_depth_of_water) | Depth of Water |
| [DBS](https://gpsd.gitlab.io/gpsd/NMEA.html#_dbs_depth_below_surface) | Depth Below Surface |
| [DBT](https://gpsd.gitlab.io/gpsd/NMEA.html#_dbt_depth_below_transducer) | Depth below transducer |
| [MDA](https://gpsd.gitlab.io/gpsd/NMEA.html#_mda_meteorological_composite) | Meteorological Composite |
| [MWD](https://www.tronico.fi/OH6NT/docs/NMEA0183.pdf) | Wind Direction and Speed |
| [MWV](https://gpsd.gitlab.io/gpsd/NMEA.html#_mwv_wind_speed_and_angle) | Wind Speed and Angle |
| [MTW](https://gpsd.gitlab.io/gpsd/NMEA.html#_mtw_mean_temperature_of_water) | Mean Temperature of Water |
| [THS](http://www.nuovamarea.net/pytheas_9.html) | Actual vessel heading in degrees True and status |
| [TXT](https://www.nmea.org/Assets/20160520%20txt%20amendment.pdf) | Sentence is for the transmission of text messages |
| Sentence type | Description |
|-----------------------------------------------------------------------------------------------|-----------------------------------------------------------|
| [AAM](https://gpsd.gitlab.io/gpsd/NMEA.html#_aam_waypoint_arrival_alarm) | Waypoint Arrival Alarm |
| [ALA](./ala.go) | System Faults and Alarms |
| [APB](https://gpsd.gitlab.io/gpsd/NMEA.html#_apb_autopilot_sentence_b) | Autopilot Sentence "B" |
| [BEC](http://www.nmea.de/nmea0183datensaetze.html#bec) | Bearing and distance to waypoint (dead reckoning) |
| [BOD](https://gpsd.gitlab.io/gpsd/NMEA.html#_bod_bearing_waypoint_to_waypoint) | Bearing waypoint to waypoint (origin to destination) |
| [BWC](https://gpsd.gitlab.io/gpsd/NMEA.html#_bwc_bearing_distance_to_waypoint_great_circle) | Bearing and distance to waypoint (great circle) |
| [BWR](https://gpsd.gitlab.io/gpsd/NMEA.html#_bwr_bearing_and_distance_to_waypoint_rhumb_line) | Bearing and distance to waypoint (Rhumb Line) |
| [BWW](https://gpsd.gitlab.io/gpsd/NMEA.html#_bww_bearing_waypoint_to_waypoint) | Bearing from destination waypoint to origin waypoint |
| [DBK](https://gpsd.gitlab.io/gpsd/NMEA.html#_dbk_depth_below_keel) | Depth Below Keel (obsolete, use DPT instead) |
| [DBS](https://gpsd.gitlab.io/gpsd/NMEA.html#_dbs_depth_below_surface) | Depth Below Surface (obsolete, use DPT instead) |
| [DBT](https://gpsd.gitlab.io/gpsd/NMEA.html#_dbt_depth_below_transducer) | Depth below transducer |
| [DOR](./dor.go) | Door Status Detection |
| [DPT](https://gpsd.gitlab.io/gpsd/NMEA.html#_dpt_depth_of_water) | Depth of Water |
| [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 |
| [GGA](http://aprs.gids.nl/nmea/#gga) | GPS Positioning System Fix Data |
| [GLL](http://aprs.gids.nl/nmea/#gll) | Geographic Position, Latitude / Longitude and time |
| [GNS](https://gpsd.gitlab.io/gpsd/NMEA.html#_gns_fix_data) | Combined GPS fix for GPS, Glonass, Galileo, and BeiDou |
| [GSA](http://aprs.gids.nl/nmea/#gsa) | GPS DOP and active satellites |
| [GSV](http://aprs.gids.nl/nmea/#gsv) | GPS Satellites in view |
| [HDG](https://gpsd.gitlab.io/gpsd/NMEA.html#_hdg_heading_deviation_variation) | Heading, Deviation & Variation |
| [HDM](https://gpsd.gitlab.io/gpsd/NMEA.html#_hdm_heading_magnetic) | Heading - Magnetic |
| [HDT](http://aprs.gids.nl/nmea/#hdt) | Actual vessel heading in degrees True |
| [HSC](https://gpsd.gitlab.io/gpsd/NMEA.html#_hsc_heading_steering_command) | Heading steering command |
| [MDA](https://gpsd.gitlab.io/gpsd/NMEA.html#_mda_meteorological_composite) | Meteorological Composite |
| [MTA](./mta.go) | Air Temperature (obsolete, use XDR instead) |
| [MTW](https://gpsd.gitlab.io/gpsd/NMEA.html#_mtw_mean_temperature_of_water) | Mean Temperature of Water |
| [MWD](https://www.tronico.fi/OH6NT/docs/NMEA0183.pdf) | Wind Direction and Speed |
| [MWV](https://gpsd.gitlab.io/gpsd/NMEA.html#_mwv_wind_speed_and_angle) | Wind Speed and Angle |
| [RMB](https://gpsd.gitlab.io/gpsd/NMEA.html#_rmb_recommended_minimum_navigation_information) | Recommended Minimum Navigation Information |
| [RMC](http://aprs.gids.nl/nmea/#rmc) | Recommended Minimum Specific GPS/Transit data |
| [ROT](https://gpsd.gitlab.io/gpsd/NMEA.html#_rot_rate_of_turn) | Rate of turn |
| [RPM](https://gpsd.gitlab.io/gpsd/NMEA.html#_rpm_revolutions) | Engine or Shaft revolutions and pitch |
| [RSA](https://gpsd.gitlab.io/gpsd/NMEA.html#_rsa_rudder_sensor_angle) | Rudder Sensor Angle |
| [RTE](http://aprs.gids.nl/nmea/#rte) | Route |
| [THS](http://www.nuovamarea.net/pytheas_9.html) | Actual vessel heading in degrees True and status |
| [TXT](https://www.nmea.org/Assets/20160520%20txt%20amendment.pdf) | Sentence is for the transmission of text messages |
| [VDM/VDO](https://gpsd.gitlab.io/gpsd/AIVDM.html) | Encapsulated binary payload (commonly used with AIS data) |
| [VDR](https://gpsd.gitlab.io/gpsd/NMEA.html#_vdr_set_and_drift) | Set and Drift |
| [VHW](https://www.tronico.fi/OH6NT/docs/NMEA0183.pdf) | Water Speed and Heading |
| [VLW](https://gpsd.gitlab.io/gpsd/NMEA.html#_vlw_distance_traveled_through_water) | Distance Traveled through Water |
| [VPW](https://gpsd.gitlab.io/gpsd/NMEA.html#_vpw_speed_measured_parallel_to_wind) | Speed Measured Parallel to Wind |
| [VTG](http://aprs.gids.nl/nmea/#vtg) | Track Made Good and Ground Speed |
| [VWR](https://gpsd.gitlab.io/gpsd/NMEA.html#_vwr_relative_wind_speed_and_angle) | Relative Wind Speed and Angle |
| [VWT](./vwt.go) | True Wind Speed and Angle |
| [WPL](http://aprs.gids.nl/nmea/#wpl) | Waypoint location |
| [XDR](https://gpsd.gitlab.io/gpsd/NMEA.html#_xdr_transducer_measurement) | Transducer Measurement |
| [ZDA](http://aprs.gids.nl/nmea/#zda) | Date & time data |

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

If you need to parse a message that contains an unsupported sentence type you can implement and register your own
message parser and get yourself unblocked immediately. Check the example below to know how
Expand Down
49 changes: 49 additions & 0 deletions aam.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package nmea

const (
// TypeAAM type of AAM sentence for Waypoint Arrival Alarm
TypeAAM = "AAM"
)

// AAM - Waypoint Arrival Alarm
// This sentence is generated by some units to indicate the status of arrival (entering the arrival circle, or passing
// the perpendicular of the course line) at the destination waypoint (source: GPSD).
// https://gpsd.gitlab.io/gpsd/NMEA.html#_aam_waypoint_arrival_alarm
//
// Format: $--AAM,A,A,x.x,N,c--c*hh<CR><LF>
// Example: $GPAAM,A,A,0.10,N,WPTNME*43
type AAM struct {
BaseSentence
// StatusArrivalCircleEntered is warning of arrival to waypoint circle
// * A = Arrival Circle Entered
// * V = not entered
StatusArrivalCircleEntered string

// StatusPerpendicularPassed is warning for perpendicular passing of waypoint
// * A = Perpendicular passed at waypoint
// * V = not passed
StatusPerpendicularPassed string

// ArrivalCircleRadius is radius for arrival circle
ArrivalCircleRadius float64

// ArrivalCircleRadiusUnit is unit for arrival circle radius
ArrivalCircleRadiusUnit string

// DestinationWaypointID is destination waypoint ID
DestinationWaypointID string
}

// newAAM constructor
func newAAM(s BaseSentence) (AAM, error) {
p := NewParser(s)
p.AssertType(TypeAAM)
return AAM{
BaseSentence: s,
StatusArrivalCircleEntered: p.EnumString(0, "arrival circle entered status", WPStatusArrivalCircleEnteredA, WPStatusArrivalCircleEnteredV),
StatusPerpendicularPassed: p.EnumString(1, "perpendicularly passed status", WPStatusPerpendicularPassedA, WPStatusPerpendicularPassedV),
ArrivalCircleRadius: p.Float64(2, "arrival circle radius"),
ArrivalCircleRadiusUnit: p.EnumString(3, "arrival circle radius units", DistanceUnitKilometre, DistanceUnitNauticalMile, DistanceUnitStatuteMile, DistanceUnitMetre),
DestinationWaypointID: p.String(4, "destination waypoint ID"),
}, p.Err()
}
56 changes: 56 additions & 0 deletions aam_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package nmea

import (
"github.com/stretchr/testify/assert"
"testing"
)

func TestAAM(t *testing.T) {
var tests = []struct {
name string
raw string
err string
msg AAM
}{
{
name: "good sentence",
raw: "$GPAAM,A,A,0.10,N,WPTNME*32",
msg: AAM{
StatusArrivalCircleEntered: WPStatusArrivalCircleEnteredA,
StatusPerpendicularPassed: WPStatusPerpendicularPassedA,
ArrivalCircleRadius: 0.1,
ArrivalCircleRadiusUnit: DistanceUnitNauticalMile,
DestinationWaypointID: "WPTNME",
},
},
{
name: "invalid nmea: StatusArrivalCircleEntered",
raw: "$GPAAM,x,A,0.10,N,WPTNME*0B",
err: "nmea: GPAAM invalid arrival circle entered status: x",
},
{
name: "invalid nmea: StatusPerpendicularPassed",
raw: "$GPAAM,A,x,0.10,N,WPTNME*0B",
err: "nmea: GPAAM invalid perpendicularly passed status: x",
},
{
name: "invalid nmea: DistanceUnitNauticalMile",
raw: "$GPAAM,A,A,0.10,x,WPTNME*04",
err: "nmea: GPAAM invalid arrival circle radius units: x",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
m, err := Parse(tt.raw)
if tt.err != "" {
assert.Error(t, err)
assert.EqualError(t, err, tt.err)
} else {
assert.NoError(t, err)
aam := m.(AAM)
aam.BaseSentence = BaseSentence{}
assert.Equal(t, tt.msg, aam)
}
})
}
}
68 changes: 68 additions & 0 deletions ala.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package nmea

const (
// TypeALA type of ALA sentence for System Faults and alarms
TypeALA = "ALA"
)

// ALA - System Faults and alarms
// Source: "Interfacing Voyage Data Recorder Systems, AutroSafe Interactive Fire-Alarm System, 116-P-BSL336/EE, RevA 2007-01-25,
// Autronica Fire and Security AS " (page 31 | p.8.1.3)
// https://product.autronicafire.com/fileshare/fileupload/14251/bsl336_ee.pdf
//
// Format: $FRALA,hhmmss,aa,aa,xx,xxx,a,a,c-cc*hh<CR><LF>
// Example: $FRALA,143955,FR,OT,00,901,N,V,Syst Fault : AutroSafe comm. OK*4F
type ALA struct {
BaseSentence

// Time is Event Time
Time Time

// SystemIndicator is system indicator of original alarm source. Detector system type with 2 char identifier.
// Values not known
// https://www.nmea.org/Assets/20190303%20nmea%200183%20talker%20identifier%20mnemonics.pdf
SystemIndicator string

// SubSystemIndicator is sub system equipment indicator of original alarm source
SubSystemIndicator string

// InstanceNumber is instance number of equipment/unit/item (00-99)
InstanceNumber int64

// Type is alarm type (000-999)
Type int64

// Condition describes the condition triggering current message
// * N – Normal state (OK)
// * H - Alarm state (fault);
// could be more
Condition string

// AlarmAckState is Alarm's acknowledge state
// * A – Acknowledged
// * H - Harbour mode
// * V – Not acknowledged
// * O - Override
// could be more
AlarmAckState string

// Message's description text (could be cut to fit max packet length)
Message string
}

// newALA constructor
func newALA(s BaseSentence) (ALA, error) {
p := NewParser(s)
p.AssertType(TypeALA)
return ALA{
BaseSentence: s,
Time: p.Time(0, "time"),
SystemIndicator: p.String(1, "system indicator"),
SubSystemIndicator: p.String(2, "subsystem indicator"),
InstanceNumber: p.Int64(3, "instance number"),
Type: p.Int64(4, "type"),
Condition: p.String(5, "condition"), // string as there could be more
AlarmAckState: p.String(6, "alarm acknowledgement state"), // string as there could be more
Message: p.String(7, "message"),
}, p.Err()
}
Loading