aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2024-02-19 13:27:02 -0800
committerAnton Tananaev <anton@traccar.org>2024-02-19 13:27:02 -0800
commit8cf3fcd643faebd9cb0937bc1e8454a22ad8b137 (patch)
treeea121ebe1ba65822fe6205965ce476987cb8c04a /src
parentefd9e261791942334dbf4a911883a1b2b791f282 (diff)
downloadtrackermap-server-8cf3fcd643faebd9cb0937bc1e8454a22ad8b137.tar.gz
trackermap-server-8cf3fcd643faebd9cb0937bc1e8454a22ad8b137.tar.bz2
trackermap-server-8cf3fcd643faebd9cb0937bc1e8454a22ad8b137.zip
Support GV355CEU CAN data
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java36
-rw-r--r--src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java5
2 files changed, 35 insertions, 6 deletions
diff --git a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
index 0628a06d4..8fb30e2ad 100644
--- a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
@@ -16,6 +16,7 @@
package org.traccar.protocol;
import io.netty.buffer.Unpooled;
+import org.apache.commons.lang3.StringUtils;
import org.traccar.BaseProtocolDecoder;
import org.traccar.helper.DataConverter;
import org.traccar.session.DeviceSession;
@@ -419,17 +420,17 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, values[index++]);
position.setDeviceId(deviceSession.getDeviceId());
- String deviceName = values[index++];
+ String model = StringUtils.firstNonEmpty(values[index++], getDeviceModel(deviceSession));
index += 1; // report type
- index += 1; // canbus state
+ index += 1; // can bus state
long reportMask = Long.parseLong(values[index++], 16);
long reportMaskExt = 0;
if (BitUtil.check(reportMask, 0)) {
position.set(Position.KEY_VIN, values[index++]);
}
- if (BitUtil.check(reportMask, 1)) {
- position.set(Position.KEY_IGNITION, Integer.parseInt(values[index++]) > 0);
+ if (BitUtil.check(reportMask, 1) && !values[index++].isEmpty()) {
+ position.set(Position.KEY_IGNITION, Integer.parseInt(values[index - 1]) > 0);
}
if (BitUtil.check(reportMask, 2)) {
position.set(Position.KEY_OBD_ODOMETER, values[index++]);
@@ -491,7 +492,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
if (BitUtil.check(reportMask, 21) && !values[index++].isEmpty()) {
position.set("engineOverspeed", Double.parseDouble(values[index - 1]));
}
- if ("GV350M".equals(deviceName)) {
+ if ("GV350M".equals(model)) {
if (BitUtil.check(reportMask, 22)) {
index += 1; // impulse distance
}
@@ -501,6 +502,28 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
if (BitUtil.check(reportMask, 24)) {
index += 1; // catalyst liquid level
}
+ } else if ("GV355CEU".equals(model)) {
+ if (BitUtil.check(reportMask, 22)) {
+ index += 1; // impulse distance
+ }
+ if (BitUtil.check(reportMask, 23)) {
+ index += 1; // engine cold starts
+ }
+ if (BitUtil.check(reportMask, 24)) {
+ index += 1; // engine all starts
+ }
+ if (BitUtil.check(reportMask, 25)) {
+ index += 1; // engine starts by ignition
+ }
+ if (BitUtil.check(reportMask, 26)) {
+ index += 1; // total engine cold running time
+ }
+ if (BitUtil.check(reportMask, 27)) {
+ index += 1; // handbrake applies during ride
+ }
+ if (BitUtil.check(reportMask, 28)) {
+ index += 1; // electric report mask
+ }
}
if (BitUtil.check(reportMask, 29) && !values[index++].isEmpty()) {
reportMaskExt = Long.parseLong(values[index - 1], 16);
@@ -581,7 +604,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
- if (BitUtil.check(reportMask, 30)) {
+ if (!"GV355CEU".equals(model) && BitUtil.check(reportMask, 30)) {
while (values[index].isEmpty()) {
index += 1;
}
@@ -606,6 +629,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
index += 1; // reserved
}
+ index = values.length - 2;
if (ignoreFixTime) {
position.setTime(dateFormat.parse(values[index]));
} else {
diff --git a/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java
index 2c012eb6f..6327f6579 100644
--- a/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java
@@ -478,6 +478,11 @@ public class Gl200TextProtocolDecoderTest extends ProtocolTest {
verifyAttributes(decoder, buffer(
"+ACK:GTGEO,1A0102,135790246811220,,0,0008,20100310172830,11F0"));
+ decoder.setModelOverride("GV355CEU");
+
+ verifyAttributes(decoder, buffer(
+ "+RESP:GTCAN,8020050605,867488060270575,,00,1,FFFFFFFF,8LBETF3W4N0001613,,,22.54,0,,,,,,,7.84,4.61,3.24,3.33,,8080,,,00,0.00,0.00,1,14,14,2371,0,001FFFFF,,,,,,,,,7158,9998,0,7.84,0.00,0.00,558,,,,,,,C0,,,,,0,0.0,346,2848.5,-78.592371,-0.968132,20240202083437,0740,0002,526C,00AE7907,00,20240202083440,3F6D$"));
+
}
}