类 Checksum

java.lang.Object
net.sf.marineapi.nmea.sentence.Checksum

public final class Checksum extends Object
Provides Sentence checksum calculation and utilities.
作者:
Kimmo Tuukkanen
  • 方法详细资料

    • add

      public static String add(String nmea)
      Append or replace existing checksum in specified NMEA sentence.
      参数:
      nmea - Sentence in String representation
      返回:
      The specified String with checksum added.
    • calculate

      public static String calculate(String nmea)
      Calculates checksum for given NMEA sentence, i.e. XOR of each character between '$' and '*' characters (exclusive).
      参数:
      nmea - Sentence String with or without checksum.
      返回:
      Hexadecimal checksum
    • xor

      public static String xor(String str)
      Calculates XOR checksum of given String. Resulting hex value is returned as a String in two digit format, padded with a leading zero if necessary.
      参数:
      str - String to calculate checksum for.
      返回:
      Hexadecimal checksum
    • index

      public static int index(String nmea)
      Returns the index of checksum separator char in specified NMEA sentence. If separator is not found, returns the String length.
      参数:
      nmea - Sentence String
      返回:
      Index of checksum separator or String length.