From 8cf3fcd643faebd9cb0937bc1e8454a22ad8b137 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 19 Feb 2024 13:27:02 -0800 Subject: Support GV355CEU CAN data --- .../traccar/protocol/Gl200TextProtocolDecoder.java | 36 ++++++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'src/main') 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 { -- cgit v1.2.3