aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-06-23 11:50:12 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-06-23 11:50:12 +1200
commit7dec68dabcb5690f7c4092a0d0df17d787c9176c (patch)
tree10a1893923f95291f82dc61a47c1caa51161736d /src/org
parent102c142c5868ab572c23eb3a3f65979c68180fc1 (diff)
downloadtraccar-server-7dec68dabcb5690f7c4092a0d0df17d787c9176c.tar.gz
traccar-server-7dec68dabcb5690f7c4092a0d0df17d787c9176c.tar.bz2
traccar-server-7dec68dabcb5690f7c4092a0d0df17d787c9176c.zip
Extend PT502 decoder (fix #1263)
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/protocol/Pt502ProtocolDecoder.java39
1 files changed, 37 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/Pt502ProtocolDecoder.java b/src/org/traccar/protocol/Pt502ProtocolDecoder.java
index 3db463cf6..fe22b0fdc 100644
--- a/src/org/traccar/protocol/Pt502ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Pt502ProtocolDecoder.java
@@ -35,7 +35,8 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder {
}
private static final Pattern pattern = Pattern.compile(
- ".*\\$POS," + // Data Frame start
+ ".*" +
+ "\\$[A-Z]{3}\\d?," + // Type
"(\\d+)," + // Id
"(\\d{2})(\\d{2})(\\d{2})\\.(\\d{3})," + // Time (HHMMSS.SSS)
"([AV])," + // Validity
@@ -45,7 +46,14 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder {
"([EW])," +
"(\\d+\\.\\d+)?," + // Speed
"(\\d+\\.\\d+)?," + // Course
- "(\\d{2})(\\d{2})(\\d{2})," + // Date
+ "(\\d{2})(\\d{2})(\\d{2}),,," + // Date
+ "./" +
+ "([01])+," + // Input
+ "([01])+/" + // Output
+ "([^/]+)/" + // ADC
+ "(\\d+)" + // Odometer
+ "(?:/([^/]+)?/" + // RFID
+ "(\\p{XDigit}{3}))?" + // State
".*");
@Override
@@ -118,6 +126,33 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder {
time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++)));
position.setTime(time.getTime());
+ // IO
+ position.set(Event.KEY_INPUT, parser.group(index++));
+ position.set(Event.KEY_OUTPUT, parser.group(index++));
+
+ // ADC
+ String adc = parser.group(index++);
+ if (adc != null) {
+ String[] values = adc.split(",");
+ for (int i = 0; i < values.length; i++) {
+ position.set(Event.PREFIX_ADC + (i + 1), Integer.parseInt(values[i], 16));
+ }
+ }
+
+ position.set(Event.KEY_ODOMETER, parser.group(index++));
+
+ // Driver
+ position.set(Event.KEY_RFID, parser.group(index++));
+
+ // Other
+ String status = parser.group(index++);
+ if (status != null) {
+ int value = Integer.parseInt(status, 16);
+ position.set(Event.KEY_BATTERY, value >> 8);
+ position.set(Event.KEY_GSM, (value >> 4) & 0xf);
+ position.set(Event.KEY_SATELLITES, value & 0xf);
+ }
+
return position;
}
}