Closed aldas closed 2 years ago
About errors. When parsing fails currently only first error is stored and all subsequent errors are discarded. I propose if p.EnumString
and other parsing method errors would be distinquishable from each other and parsers would store all errors. it would allow you to introspect what went wrong and some circumstances ignore some error types.
maybe just wrapping them (or storing into slice or multierror)
func (p *Parser) SetErr(context, value string) {
if p.err == nil {
p.err = fmt.Errorf("nmea: %s invalid %s: %s", p.Prefix(), context, value)
} else {
p.err = fmt.Errorf("nmea: %s invalid %s: %s, err: %w", p.Prefix(), context, value, p.err)
}
}
This is awesome! Create a separate issue for the error discussion though.
added #89
Added a lot of sentences
AAM - Waypoint Arrival Alarm
ALA - System Faults and alarms
APB - Autopilot Sentence "B"
BEC - Bearing and distance to waypoint (dead reckoning)
BOD - Bearing waypoint to waypoint (origin to destination).
BWC - Bearing and distance to waypoint, great circle
BWR - Bearing and distance to waypoint (Rhumb Line)
BWW - bearing (from destination) destination waypoint to origin waypoint
DBK - Depth Below Keel (obsolete, use DPT instead)
DOR - Door Status Detection
DSC - Digital Selective Calling Information
DSE - Expanded digital selective calling
EVE - General Event Message
FIR - Fire Detection event with time and location
HSC - Heading steering command
MTA - Air Temperature (obsolete, use XDR instead)
RMB - Recommended Minimum Navigation Information
RPM - Engine or Shaft revolutions and pitch
RSA - Rudder Sensor Angle
VDR - Set and Drift
VLW - Distance Traveled through Water
VPW - Speed Measured Parallel to Wind
VWR - Relative Wind Speed and Angle
VWT - True Wind Speed and Angle
XDR - Transducer Measurement
XTE - Cross-track error, measured
Added parsing of unit related fields to DBS. Although these 'C' fields should be constants just be paranoid and check if type/unit is what we expect and error if not. Maybe
p.EnumString(
could set special error type alaEnumValueError
when it sees value that is not in list + instead of returning empty value we return that invalid value. In that case you could check forEnumValueError
and ignore it if you want to and that invalid value would be still set to that sentence type so it is usable in that case.