aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/helper
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2013-06-02 22:51:54 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2013-06-02 22:51:54 +1200
commitb16593f062d304e000899085b22d1232b055639b (patch)
tree2a25f5162d46aa6261416c4859beca4b691a24e0 /src/org/traccar/helper
parent78585a5d92c3c6ab7aed275ffad5e412a6efd707 (diff)
downloadtraccar-server-b16593f062d304e000899085b22d1232b055639b.tar.gz
traccar-server-b16593f062d304e000899085b22d1232b055639b.tar.bz2
traccar-server-b16593f062d304e000899085b22d1232b055639b.zip
Update Apel decoder
Diffstat (limited to 'src/org/traccar/helper')
-rw-r--r--src/org/traccar/helper/Crc.java9
1 files changed, 9 insertions, 0 deletions
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;