aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-07-03 16:27:59 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2021-07-03 16:27:59 -0700
commit827a781e49c74e6573a407119fd5519050b091e3 (patch)
tree4766e470972a836b51fdca0606216df4938422f5 /src/main/java
parent841612ab1112dddfb1f3cb23e879381cce32de61 (diff)
downloadtraccar-server-827a781e49c74e6573a407119fd5519050b091e3.tar.gz
traccar-server-827a781e49c74e6573a407119fd5519050b091e3.tar.bz2
traccar-server-827a781e49c74e6573a407119fd5519050b091e3.zip
Support iStartek PT60 format
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()) {