aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar')
-rw-r--r--src/main/java/org/traccar/protocol/StartekProtocolDecoder.java38
1 files changed, 22 insertions, 16 deletions
diff --git a/src/main/java/org/traccar/protocol/StartekProtocolDecoder.java b/src/main/java/org/traccar/protocol/StartekProtocolDecoder.java
index 53c02f28c..b2fcd5452 100644
--- a/src/main/java/org/traccar/protocol/StartekProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/StartekProtocolDecoder.java
@@ -42,6 +42,7 @@ public class StartekProtocolDecoder extends BaseProtocolDecoder {
.number("d+,") // length
.number("(d+),") // imei
.expression("(.+)") // content
+ .number("xx") // checksum
.compile();
private static final Pattern PATTERN_POSITION = new PatternBuilder()
@@ -73,22 +74,26 @@ public class StartekProtocolDecoder extends BaseProtocolDecoder {
.groupBegin()
.text(",")
.number("d,") // extended
- .expression("([^,]+)?,") // fuel
+ .expression("([^,]+)?") // fuel
+ .groupBegin()
+ .text(",")
.expression("([^,]+)?") // temperature
.groupBegin()
.text(",")
- .number("(d+)|") // rpm
- .number("(d+)|") // engine load
- .number("d+|") // maf flow
- .number("d+|") // intake pressure
- .number("d+|") // intake temperature
- .number("(d+)|") // throttle
- .number("(d+)|") // coolant temperature
- .number("(d+)|") // instant fuel
- .number("(d+)") // fuel level
+ .groupBegin()
+ .number("(d+)?|") // rpm
+ .number("(d+)?|") // engine load
+ .number("d*|") // maf flow
+ .number("d*|") // intake pressure
+ .number("d*|") // intake temperature
+ .number("(d+)?|") // throttle
+ .number("(d+)?|") // coolant temperature
+ .number("(d+)?|") // instant fuel
+ .number("(d+)[%L]").optional() // fuel level
+ .groupEnd("?")
+ .groupEnd("?")
.groupEnd("?")
.groupEnd("?")
- .any()
.compile();
private String decodeAlarm(int value) {
@@ -122,9 +127,6 @@ public class StartekProtocolDecoder extends BaseProtocolDecoder {
}
String content = parser.next();
- if (content.charAt(content.length() - 2 - 1) != '|') {
- content = content.substring(0, content.length() - 2);
- }
if (content.length() < 100) {
Position position = new Position(getProtocolName());
@@ -223,8 +225,12 @@ public class StartekProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_RPM, parser.nextInt());
position.set(Position.KEY_ENGINE_LOAD, parser.nextInt());
position.set(Position.KEY_THROTTLE, parser.nextInt());
- position.set(Position.KEY_COOLANT_TEMP, parser.nextInt() - 40);
- position.set(Position.KEY_FUEL_CONSUMPTION, parser.nextInt() * 0.1);
+ if (parser.hasNext()) {
+ position.set(Position.KEY_COOLANT_TEMP, parser.nextInt() - 40);
+ }
+ if (parser.hasNext()) {
+ position.set(Position.KEY_FUEL_CONSUMPTION, parser.nextInt() * 0.1);
+ }
position.set(Position.KEY_FUEL_LEVEL, parser.nextInt());
}