diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-09-12 22:58:40 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2020-09-12 22:58:40 -0700 |
commit | e0f15c6a21c188edd61ca78d034aaf1505fb59cb (patch) | |
tree | 9d0936d30efabd5959204e54551fad90c7cffc18 /src/main/java/org/traccar/helper/Checksum.java | |
parent | ab70f326d1ea09a20f2b5835d7de9d7ff6a5b220 (diff) | |
download | trackermap-server-e0f15c6a21c188edd61ca78d034aaf1505fb59cb.tar.gz trackermap-server-e0f15c6a21c188edd61ca78d034aaf1505fb59cb.tar.bz2 trackermap-server-e0f15c6a21c188edd61ca78d034aaf1505fb59cb.zip |
Refactor NMEA checksum
Diffstat (limited to 'src/main/java/org/traccar/helper/Checksum.java')
-rw-r--r-- | src/main/java/org/traccar/helper/Checksum.java | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/main/java/org/traccar/helper/Checksum.java b/src/main/java/org/traccar/helper/Checksum.java index d41dc2992..c1de983d8 100644 --- a/src/main/java/org/traccar/helper/Checksum.java +++ b/src/main/java/org/traccar/helper/Checksum.java @@ -151,13 +151,8 @@ public final class Checksum { return checksum; } - public static String nmea(String msg) { - int checksum = 0; - byte[] bytes = msg.getBytes(StandardCharsets.US_ASCII); - for (int i = 1; i < bytes.length; i++) { - checksum ^= bytes[i]; - } - return String.format("*%02x", checksum).toUpperCase(); + public static String nmea(String string) { + return String.format("*%02X", xor(string)); } public static int sum(ByteBuffer buf) { |