diff options
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/helper/DataConverter.java | 2 | ||||
-rw-r--r-- | src/org/traccar/protocol/LaipacProtocolDecoder.java | 13 |
2 files changed, 5 insertions, 10 deletions
diff --git a/src/org/traccar/helper/DataConverter.java b/src/org/traccar/helper/DataConverter.java index 0df0219ad..7abd4ae93 100644 --- a/src/org/traccar/helper/DataConverter.java +++ b/src/org/traccar/helper/DataConverter.java @@ -26,7 +26,7 @@ public final class DataConverter { public static byte[] parseHex(String string) { try { - return Hex.decodeHex(string.toCharArray()); + return Hex.decodeHex(string); } catch (DecoderException e) { throw new RuntimeException(e); } diff --git a/src/org/traccar/protocol/LaipacProtocolDecoder.java b/src/org/traccar/protocol/LaipacProtocolDecoder.java index f243fc629..0a7df26fa 100644 --- a/src/org/traccar/protocol/LaipacProtocolDecoder.java +++ b/src/org/traccar/protocol/LaipacProtocolDecoder.java @@ -48,7 +48,7 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder { .number("(d+.d+),") // course .number("(dd)(dd)(dd),") // date (ddmmyy) .expression("([abZXTSMHFE86430]),") // event code - .number("(d+)").expression("(\\.?)").number("(d*),") // battery voltage + .number("(d.+),") // battery voltage .number("(d+),") // current mileage .number("(d),") // GPS on/off (1 = on, 0 = off) .number("(d+),") // Analog port 1 @@ -105,14 +105,9 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_ALARM, decodeAlarm(eventCode)); position.set(Position.KEY_EVENT, eventCode); - double batteryVoltage = parser.nextDouble(); - if (parser.next().isEmpty()) { - parser.next(); - batteryVoltage *= 0.001; - } else { - batteryVoltage += parser.nextDouble() * 0.001; - } - position.set(Position.KEY_BATTERY, batteryVoltage); + String batteryVoltage = parser.next(); + batteryVoltage = batteryVoltage.replaceAll("\\.",""); + position.set(Position.KEY_BATTERY, Double.parseDouble(batteryVoltage) * 0.001); position.set(Position.KEY_ODOMETER, parser.nextDouble()); position.set(Position.KEY_GPS, parser.nextInt()); |