From b16593f062d304e000899085b22d1232b055639b Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 2 Jun 2013 22:51:54 +1200 Subject: Update Apel decoder --- src/org/traccar/helper/Crc.java | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/org/traccar/helper') diff --git a/src/org/traccar/helper/Crc.java b/src/org/traccar/helper/Crc.java index a7adca874..84224a781 100644 --- a/src/org/traccar/helper/Crc.java +++ b/src/org/traccar/helper/Crc.java @@ -17,6 +17,7 @@ package org.traccar.helper; import java.nio.ByteBuffer; import java.nio.charset.Charset; +import java.util.zip.CRC32; /** * CRC functions @@ -127,6 +128,14 @@ public class Crc { public static int crc16CcittSeed(ByteBuffer buf, int seed) { return crc16Reflected(buf, seed, crc16CcittTableReverse) ^ crc16CcittXorout; } + + public static int crc32(ByteBuffer buf) { + CRC32 checksum = new CRC32(); + for (int i = 0; i < buf.remaining(); i++) { + checksum.update(buf.get(i)); + } + return (int) checksum.getValue(); + } public static String nmeaChecksum(String msg) { int checksum = 0; -- cgit v1.2.3