aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/traccar/protocol/StartekProtocolDecoder.java18
1 files changed, 13 insertions, 5 deletions
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()) {