Class NMEA2000Message
java.lang.Object
org.episteme.natural.device.loaders.nmea.NMEA2000Message
NMEA 2000 (CAN-based marine protocol) message parser and representation.
NMEA 2000 uses PGNs (Parameter Group Numbers) to identify message types. This parser handles the binary CAN frame format used by NMEA 2000.
- Since:
- 1.0
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionNMEA2000Message(int pgn, int priority, int source, int destination, byte[] data) -
Method Summary
Modifier and TypeMethodDescriptionstatic NMEA2000MessagefromCANFrame(int canId, byte[] data) Parses a CAN frame into an NMEA 2000 message.byte[]getData()intintgetInt16(int offset) Gets a signed 16-bit value from the data at the specified byte offset.longgetInt32(int offset) Gets a 32-bit value from the data at the specified byte offset.intgetPGN()intintlongintgetUInt16(int offset) Gets an unsigned 16-bit value from the data at the specified byte offset.doubleParses depth from Water Depth PGN (128267).doubleParses heading from Vessel Heading PGN (127250).doubleParses latitude from GNSS position PGN (129029).doubleParses longitude from GNSS position PGN (129029).doubleParses wind angle from Wind Data PGN (130306).doubleParses wind speed from Wind Data PGN (130306).toString()
-
Constructor Details
-
NMEA2000Message
public NMEA2000Message(int pgn, int priority, int source, int destination, byte[] data)
-
-
Method Details
-
fromCANFrame
Parses a CAN frame into an NMEA 2000 message.- Parameters:
canId- the 29-bit CAN extended identifierdata- the CAN frame data (up to 8 bytes)
-
getPGN
public int getPGN() -
getPGNType
-
getPriority
public int getPriority() -
getSource
public int getSource() -
getDestination
public int getDestination() -
getData
public byte[] getData() -
getTimestamp
public long getTimestamp() -
getInt16
public int getInt16(int offset) Gets a signed 16-bit value from the data at the specified byte offset. -
getUInt16
public int getUInt16(int offset) Gets an unsigned 16-bit value from the data at the specified byte offset. -
getInt32
public long getInt32(int offset) Gets a 32-bit value from the data at the specified byte offset. -
parseLatitude
public double parseLatitude()Parses latitude from GNSS position PGN (129029).- Returns:
- latitude in degrees or NaN if not applicable
-
parseLongitude
public double parseLongitude()Parses longitude from GNSS position PGN (129029).- Returns:
- longitude in degrees or NaN if not applicable
-
parseHeading
public double parseHeading()Parses heading from Vessel Heading PGN (127250).- Returns:
- heading in radians or NaN if not applicable
-
parseDepth
public double parseDepth()Parses depth from Water Depth PGN (128267).- Returns:
- depth in meters or NaN if not applicable
-
parseWindSpeed
public double parseWindSpeed()Parses wind speed from Wind Data PGN (130306).- Returns:
- wind speed in m/s or NaN if not applicable
-
parseWindAngle
public double parseWindAngle()Parses wind angle from Wind Data PGN (130306).- Returns:
- wind angle in radians or NaN if not applicable
-
toString
-