From 194263a9dc8040ebcbf62c80733aca5097eb3e36 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 27 Jul 2017 01:32:21 +1200 Subject: Extend VT200 protocol decoder --- test/org/traccar/protocol/Vt200ProtocolDecoderTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/org/traccar/protocol/Vt200ProtocolDecoderTest.java') diff --git a/test/org/traccar/protocol/Vt200ProtocolDecoderTest.java b/test/org/traccar/protocol/Vt200ProtocolDecoderTest.java index e61c5f9f2..d63bf0062 100644 --- a/test/org/traccar/protocol/Vt200ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Vt200ProtocolDecoderTest.java @@ -10,6 +10,21 @@ public class Vt200ProtocolDecoderTest extends ProtocolTest { Vt200ProtocolDecoder decoder = new Vt200ProtocolDecoder(new Vt200Protocol()); + verifyNull(decoder, binary( + "28631037309456008e000801042307171804584229")); + + verifyNull(decoder, binary( + "28631037309456108800002e29")); + + verifyPosition(decoder, binary( + "28631037309456208200210103302307171805444417097301147188170198090f0000073a002000007e00074429")); + + verifyNull(decoder, binary( + "286310373094563089001200032f2107171740144417075001147188872c29")); + + verifyNull(decoder, binary( + "2863103730945630880062032f862631037309456f222014604362936f21071717373221071717401400a100000cd700000004020d3c8e0000000000000000000000000000000000000000000000000000000000000000000a000000040000000e009700000cc9000000000000e929")); + verifyPosition(decoder, binary( "28631037309456208400340102dc0906171616454415760201144494473f920a0c0000030500200100417c1f383a9d1090510000006a00007000000e00180ee129")); -- cgit v1.2.3 From 4d35ef57f3dff21348d9ae9fe269176cd885c127 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 3 Aug 2017 02:17:58 +1200 Subject: Add VT400 test cases --- .../org/traccar/protocol/Vt200ProtocolDecoderTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test/org/traccar/protocol/Vt200ProtocolDecoderTest.java') diff --git a/test/org/traccar/protocol/Vt200ProtocolDecoderTest.java b/test/org/traccar/protocol/Vt200ProtocolDecoderTest.java index d63bf0062..19155af5a 100644 --- a/test/org/traccar/protocol/Vt200ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Vt200ProtocolDecoderTest.java @@ -10,6 +10,24 @@ public class Vt200ProtocolDecoderTest extends ProtocolTest { Vt200ProtocolDecoder decoder = new Vt200ProtocolDecoder(new Vt200Protocol()); + verifyNull(decoder, binary( + "286310373094563082002701033d00010817143327c68a14841e00c27f550e9a000000000c000000084700200120007d01af260b29")); + + verifyNull(decoder, binary( + "286310373094562086002101033d0001081714333d15441790420114817637207d090a00000847002001207f00d6f229")); + + verifyNull(decoder, binary( + "286310373094562086002101033d000108171433354417932101148139772c9d080a00000847002001207f00dc6729")); + + verifyNull(decoder, binary( + "2863103730945600880012180108171433004418103801148375470000dd29")); + + verifyNull(decoder, binary( + "28631037309456108800002e29")); + + verifyNull(decoder, binary( + "2863103730945630880062033c862631037309456f222014604362936f01081713365601081713571904c800001b2c000034f66827f0840000000000000000000000000047000006e7000001b9022a000023ff000007f2018a00000a10000003f300cd00000d8d0300000302002729")); + verifyNull(decoder, binary( "28631037309456008e000801042307171804584229")); -- cgit v1.2.3 From f182ae04a9857e13482421957140e1a70af2302b Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 4 Aug 2017 00:40:48 +1200 Subject: Improve VT400 protocol decoder --- src/org/traccar/protocol/Vt200ProtocolDecoder.java | 2 +- test/org/traccar/protocol/Vt200ProtocolDecoderTest.java | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'test/org/traccar/protocol/Vt200ProtocolDecoderTest.java') diff --git a/src/org/traccar/protocol/Vt200ProtocolDecoder.java b/src/org/traccar/protocol/Vt200ProtocolDecoder.java index f9683f12f..111c29313 100644 --- a/src/org/traccar/protocol/Vt200ProtocolDecoder.java +++ b/src/org/traccar/protocol/Vt200ProtocolDecoder.java @@ -57,7 +57,7 @@ public class Vt200ProtocolDecoder extends BaseProtocolDecoder { int type = buf.readUnsignedShort(); buf.readUnsignedShort(); // length - if (type == 0x2084 || type == 0x2082) { + if (type == 0x2086 || type == 0x2084 || type == 0x2082) { Position position = new Position(); position.setProtocol(getProtocolName()); diff --git a/test/org/traccar/protocol/Vt200ProtocolDecoderTest.java b/test/org/traccar/protocol/Vt200ProtocolDecoderTest.java index 19155af5a..37d9c46d9 100644 --- a/test/org/traccar/protocol/Vt200ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Vt200ProtocolDecoderTest.java @@ -11,13 +11,13 @@ public class Vt200ProtocolDecoderTest extends ProtocolTest { Vt200ProtocolDecoder decoder = new Vt200ProtocolDecoder(new Vt200Protocol()); verifyNull(decoder, binary( - "286310373094563082002701033d00010817143327c68a14841e00c27f550e9a000000000c000000084700200120007d01af260b29")); + "286310373094563082002701033d010817143327c68a14841e00c27f550e9a000000000c000000084700200120007d01af260b29")); - verifyNull(decoder, binary( - "286310373094562086002101033d0001081714333d15441790420114817637207d090a00000847002001207f00d6f229")); + verifyPosition(decoder, binary( + "286310373094562086002101033d010817143328441790420114817637207d090a00000847002001207f00d6f229")); - verifyNull(decoder, binary( - "286310373094562086002101033d000108171433354417932101148139772c9d080a00000847002001207f00dc6729")); + verifyPosition(decoder, binary( + "286310373094562086002101033d0108171433354417932101148139772c9d080a00000847002001207f00dc6729")); verifyNull(decoder, binary( "2863103730945600880012180108171433004418103801148375470000dd29")); -- cgit v1.2.3 From 8012240ac5662d8b0a2ec7907ad3f04e86b17627 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 15 Aug 2017 07:39:46 +1200 Subject: Add VT200 trip message support --- src/org/traccar/protocol/Vt200ProtocolDecoder.java | 58 +++++++++++++++++++--- .../traccar/protocol/Vt200ProtocolDecoderTest.java | 7 ++- 2 files changed, 57 insertions(+), 8 deletions(-) (limited to 'test/org/traccar/protocol/Vt200ProtocolDecoderTest.java') diff --git a/src/org/traccar/protocol/Vt200ProtocolDecoder.java b/src/org/traccar/protocol/Vt200ProtocolDecoder.java index 111c29313..6be70c3c1 100644 --- a/src/org/traccar/protocol/Vt200ProtocolDecoder.java +++ b/src/org/traccar/protocol/Vt200ProtocolDecoder.java @@ -27,6 +27,8 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Position; import java.net.SocketAddress; +import java.util.Arrays; +import java.util.Date; public class Vt200ProtocolDecoder extends BaseProtocolDecoder { @@ -40,6 +42,13 @@ public class Vt200ProtocolDecoder extends BaseProtocolDecoder { return degrees + minutes * 0.0001 / 60; } + protected Date decodeDate(ChannelBuffer buf) { + DateBuilder dateBuilder = new DateBuilder() + .setDateReverse(BcdUtil.readInteger(buf, 2), BcdUtil.readInteger(buf, 2), BcdUtil.readInteger(buf, 2)) + .setTime(BcdUtil.readInteger(buf, 2), BcdUtil.readInteger(buf, 2), BcdUtil.readInteger(buf, 2)); + return dateBuilder.getDate(); + } + @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { @@ -66,12 +75,7 @@ public class Vt200ProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(); // data type buf.readUnsignedShort(); // trip id - DateBuilder dateBuilder = new DateBuilder(); - dateBuilder.setDateReverse( - BcdUtil.readInteger(buf, 2), BcdUtil.readInteger(buf, 2), BcdUtil.readInteger(buf, 2)); - dateBuilder.setTime( - BcdUtil.readInteger(buf, 2), BcdUtil.readInteger(buf, 2), BcdUtil.readInteger(buf, 2)); - position.setTime(dateBuilder.getDate()); + position.setTime(decodeDate(buf)); position.setLatitude(decodeCoordinate(BcdUtil.readInteger(buf, 8))); position.setLongitude(decodeCoordinate(BcdUtil.readInteger(buf, 9))); @@ -97,6 +101,48 @@ public class Vt200ProtocolDecoder extends BaseProtocolDecoder { return position; + } else if (type == 0x3088) { + + Position position = new Position(); + position.setProtocol(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); + + getLastLocation(position, null); + + buf.readUnsignedShort(); // trip id + buf.skipBytes(8); // imei + buf.skipBytes(8); // imsi + + position.set("tripStart", decodeDate(buf).getTime()); + position.set("tripEnd", decodeDate(buf).getTime()); + position.set("drivingTime", buf.readUnsignedShort()); + + position.set(Position.KEY_FUEL_CONSUMPTION, buf.readUnsignedInt()); + position.set(Position.KEY_ODOMETER_TRIP, buf.readUnsignedInt()); + + position.set("maxSpeed", UnitsConverter.knotsFromKph(buf.readUnsignedByte())); + position.set("maxRpm", buf.readUnsignedShort()); + position.set("maxTemp", buf.readUnsignedByte() - 40); + position.set("hardAccelerationCount", buf.readUnsignedByte()); + position.set("hardBreakingCount", buf.readUnsignedByte()); + + for (String speedType : Arrays.asList("over", "high", "normal", "low")) { + position.set(speedType + "SpeedTime", buf.readUnsignedShort()); + position.set(speedType + "SpeedDistance", buf.readUnsignedInt()); + position.set(speedType + "SpeedFuel", buf.readUnsignedInt()); + } + + position.set("idleTime", buf.readUnsignedShort()); + position.set("idleFuel", buf.readUnsignedInt()); + + position.set("hardCorneringCount", buf.readUnsignedByte()); + position.set("overspeedCount", buf.readUnsignedByte()); + position.set("overheatCount", buf.readUnsignedShort()); + position.set("laneChangeCount", buf.readUnsignedByte()); + position.set("emergencyRefueling", buf.readUnsignedByte()); + + return position; + } return null; diff --git a/test/org/traccar/protocol/Vt200ProtocolDecoderTest.java b/test/org/traccar/protocol/Vt200ProtocolDecoderTest.java index 37d9c46d9..42ed4a652 100644 --- a/test/org/traccar/protocol/Vt200ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Vt200ProtocolDecoderTest.java @@ -13,6 +13,9 @@ public class Vt200ProtocolDecoderTest extends ProtocolTest { verifyNull(decoder, binary( "286310373094563082002701033d010817143327c68a14841e00c27f550e9a000000000c000000084700200120007d01af260b29")); + verifyAttributes(decoder, binary( + "2863103730945630880062033d862631037309456f222014604362936f010817140954010817144135076b00002a3800003b7d6127cc91040000000000000000000000005a0000088e000001ce02630000263b000009b401ff00000cb40000069c02af000018190200000102019729")); + verifyPosition(decoder, binary( "286310373094562086002101033d010817143328441790420114817637207d090a00000847002001207f00d6f229")); @@ -25,7 +28,7 @@ public class Vt200ProtocolDecoderTest extends ProtocolTest { verifyNull(decoder, binary( "28631037309456108800002e29")); - verifyNull(decoder, binary( + verifyAttributes(decoder, binary( "2863103730945630880062033c862631037309456f222014604362936f01081713365601081713571904c800001b2c000034f66827f0840000000000000000000000000047000006e7000001b9022a000023ff000007f2018a00000a10000003f300cd00000d8d0300000302002729")); verifyNull(decoder, binary( @@ -40,7 +43,7 @@ public class Vt200ProtocolDecoderTest extends ProtocolTest { verifyNull(decoder, binary( "286310373094563089001200032f2107171740144417075001147188872c29")); - verifyNull(decoder, binary( + verifyAttributes(decoder, binary( "2863103730945630880062032f862631037309456f222014604362936f21071717373221071717401400a100000cd700000004020d3c8e0000000000000000000000000000000000000000000000000000000000000000000a000000040000000e009700000cc9000000000000e929")); verifyPosition(decoder, binary( -- cgit v1.2.3