diff options
3 files changed, 11 insertions, 8 deletions
diff --git a/src/main/java/org/traccar/helper/ObdDecoder.java b/src/main/java/org/traccar/helper/ObdDecoder.java index 1bdcce352..b22065f4e 100644 --- a/src/main/java/org/traccar/helper/ObdDecoder.java +++ b/src/main/java/org/traccar/helper/ObdDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2020 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ public final class ObdDecoder { case MODE_FREEZE_FRAME: return decodeData( Integer.parseInt(value.substring(0, 2), 16), - Integer.parseInt(value.substring(2), 16), true); + Long.parseLong(value.substring(2), 16), true); case MODE_CODES: return decodeCodes(value); default: @@ -75,7 +75,7 @@ public final class ObdDecoder { } } - public static Map.Entry<String, Object> decodeData(int pid, int value, boolean convert) { + public static Map.Entry<String, Object> decodeData(int pid, long value, boolean convert) { switch (pid) { case 0x04: return createEntry(Position.KEY_ENGINE_LOAD, convert ? value * 100 / 255 : value); diff --git a/src/test/java/org/traccar/helper/ObdDecoderTest.java b/src/test/java/org/traccar/helper/ObdDecoderTest.java index 1ffe68c8b..d5071bd51 100644 --- a/src/test/java/org/traccar/helper/ObdDecoderTest.java +++ b/src/test/java/org/traccar/helper/ObdDecoderTest.java @@ -9,11 +9,11 @@ public class ObdDecoderTest { @Test public void testDecode() { - assertEquals(83, ObdDecoder.decode(0x01, "057b").getValue()); - assertEquals(1225, ObdDecoder.decode(0x01, "0C1324").getValue()); - assertEquals(20, ObdDecoder.decode(0x01, "0D14").getValue()); - assertEquals(64050, ObdDecoder.decode(0x01, "31fa32").getValue()); - assertEquals(25, ObdDecoder.decode(0x01, "2F41").getValue()); + assertEquals(83L, ObdDecoder.decode(0x01, "057b").getValue()); + assertEquals(1225L, ObdDecoder.decode(0x01, "0C1324").getValue()); + assertEquals(20L, ObdDecoder.decode(0x01, "0D14").getValue()); + assertEquals(64050L, ObdDecoder.decode(0x01, "31fa32").getValue()); + assertEquals(25L, ObdDecoder.decode(0x01, "2F41").getValue()); } diff --git a/src/test/java/org/traccar/protocol/UlbotechProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/UlbotechProtocolDecoderTest.java index 8c820183b..a2bc1b46e 100644 --- a/src/test/java/org/traccar/protocol/UlbotechProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/UlbotechProtocolDecoderTest.java @@ -10,6 +10,9 @@ public class UlbotechProtocolDecoderTest extends ProtocolTest { UlbotechProtocolDecoder decoder = new UlbotechProtocolDecoder(null); + verifyPosition(decoder, binary( + "f801010353323083177450a703f6f0010efe55a31a0923d01400050070007003040a42000004040070cca00506039b1876220f060800000000000000000725310553410c0c9e310d05310f4641100440311119411f00476101810f8000310487411f00480804203a14c009033320159310f8")); + verifyNull(decoder, buffer( "*TS01,353323081464660#")); |