From 827a781e49c74e6573a407119fd5519050b091e3 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 3 Jul 2021 16:27:59 -0700 Subject: Support iStartek PT60 format --- .../org/traccar/protocol/StartekProtocolDecoder.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/traccar/protocol/StartekProtocolDecoder.java b/src/main/java/org/traccar/protocol/StartekProtocolDecoder.java index 1cc69c6e6..68fc511aa 100644 --- a/src/main/java/org/traccar/protocol/StartekProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/StartekProtocolDecoder.java @@ -64,11 +64,17 @@ public class StartekProtocolDecoder extends BaseProtocolDecoder { .number("(x+),") // inputs .number("(x+),") // outputs .number("(x+)|") // power - .number("(x+)|") // battery - .expression("([^,]+),") // adc + .number("(x+)") // battery + .groupBegin() + .text("|") + .expression("([^,]+)").optional() // adc + .groupBegin() + .text(",") .number("d,") // extended .expression("([^,]+)?,") // fuel .expression("([^,]+)?") // temperature + .groupEnd("?") + .groupEnd("?") .number("xx") // checksum .compile(); @@ -138,9 +144,11 @@ public class StartekProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_POWER, parser.nextHexInt() * 0.01); position.set(Position.KEY_BATTERY, parser.nextHexInt() * 0.01); - String[] adc = parser.next().split("\\|"); - for (int i = 0; i < adc.length; i++) { - position.set(Position.PREFIX_ADC + (i + 1), Integer.parseInt(adc[i], 16) * 0.01); + if (parser.hasNext()) { + String[] adc = parser.next().split("\\|"); + for (int i = 0; i < adc.length; i++) { + position.set(Position.PREFIX_ADC + (i + 1), Integer.parseInt(adc[i], 16) * 0.01); + } } if (parser.hasNext()) { -- cgit v1.2.3