Skip to content

Commit

Permalink
Correct handling of navigational status in RMC and GNS (#108)
Browse files Browse the repository at this point in the history
* Correct handling of navigational status in RMC and GNS

There was a misunderstanding on what the "navigation status" field
should include. The enum values were for the "positioning system mode
indicator" which is the preceding field. This changes the enum values to
correspond to actual ones.
  • Loading branch information
calmh authored Jul 2, 2023
1 parent 852d88f commit a60cdb4
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 27 deletions.
11 changes: 4 additions & 7 deletions gns.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,10 @@ func newGNS(s BaseSentence) (Sentence, error) {
m.NavStatus = p.EnumString(
12,
"navigation status",
NavStatusAutonomous,
NavStatusDifferential,
NavStatusEstimated,
NavStatusManualInput,
NavStatusSimulated,
NavStatusDataNotValid,
NavStatusDataValid,
NavStatusSafe,
NavStatusCaution,
NavStatusUnsafe,
NavStatusNotValid,
)
}
return m, p.Err()
Expand Down
11 changes: 4 additions & 7 deletions rmc.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,10 @@ func newRMC(s BaseSentence) (Sentence, error) {
m.NavStatus = p.EnumString(
12,
"navigation status",
NavStatusAutonomous,
NavStatusDifferential,
NavStatusEstimated,
NavStatusManualInput,
NavStatusSimulated,
NavStatusDataNotValid,
NavStatusDataValid,
NavStatusSafe,
NavStatusCaution,
NavStatusUnsafe,
NavStatusNotValid,
)
}
return m, p.Err()
Expand Down
18 changes: 17 additions & 1 deletion rmc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,30 @@ var rmctests = []struct {
Date: Date{Valid: true, DD: 30, MM: 5, YY: 18},
Variation: 0,
FFAMode: FAAModeAutonomous,
NavStatus: NavStatusDataValid,
NavStatus: NavStatusNotValid,
},
},
{
name: "bad validity",
raw: "$GPRMC,220516,D,5133.82,N,00042.24,W,173.8,231.8,130694,004.2,W*75",
err: "nmea: GPRMC invalid validity: D",
},
{
name: "good sentence G with nav status",
raw: "$YDRMC,124014.00,A,5520.2848,N,01321.5108,E,0.0,0.0,230623,4.4,E,A,C*5D",
msg: RMC{
Time: Time{Valid: true, Hour: 12, Minute: 40, Second: 14, Millisecond: 0},
Validity: "A",
Latitude: 55.338080000000005,
Longitude: 13.358513333333333,
Speed: 0,
Course: 0,
Date: Date{Valid: true, DD: 23, MM: 6, YY: 23},
Variation: 4.4,
FFAMode: FAAModeAutonomous,
NavStatus: NavStatusCaution,
},
},
}

func TestRMC(t *testing.T) {
Expand Down
26 changes: 14 additions & 12 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,22 @@ const (

// Navigation Status (NMEA 4.1 and later)
const (
// NavStatusAutonomous is Autonomous mode
NavStatusAutonomous = "A"
// NavStatusDifferential is Differential Mode
NavStatusDifferential = "D"
// NavStatusEstimated is Estimated (dead-reckoning) mode
NavStatusEstimated = "E"
// NavStatusManualInput is Manual Input Mode
NavStatusManualInput = "M"
// NavStatusSimulated is Simulated Mode
// NavStatusSimulated is a deprecated placeholder for backwards
// compatibility. There is no such status in NMEA.
// Deprecated: use NavStatusSafe
NavStatusSimulated = "S"
// NavStatusDataNotValid is Data Not Valid
NavStatusDataNotValid = "N"
// NavStatusDataValid is valid
// NavStatusDataValid is a deprecated placeholder for backwards
// compatibility. There is no such status in NMEA.
// Deprecated: use NavStatusNotValid
NavStatusDataValid = "V"
// NavStatusSafe is Safe (within selected accuracy level)
NavStatusSafe = "S"
// NavStatusCaution is Caution (integrity not available)
NavStatusCaution = "C"
// NavStatusUnsafe is Unsafe (outside selected accuracy level)
NavStatusUnsafe = "U"
// NavStatusNotValid is Not Valid (equipment does not provide navigation status information)
NavStatusNotValid = "V"
)

const (
Expand Down

0 comments on commit a60cdb4

Please sign in to comment.