aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-12-07 15:35:20 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2017-12-07 15:35:20 +1300
commit5abaff0e1a37184b67b02864b3527d7334965de8 (patch)
tree3505394687e298ee18bfa6e3c2b5b76d0b53e3a4 /src/org/traccar/protocol
parent6e826a6105b8d2146b40db2367221657d0940cf8 (diff)
downloadtraccar-server-5abaff0e1a37184b67b02864b3527d7334965de8.tar.gz
traccar-server-5abaff0e1a37184b67b02864b3527d7334965de8.tar.bz2
traccar-server-5abaff0e1a37184b67b02864b3527d7334965de8.zip
Support TMG inputs and outputs
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/TmgProtocolDecoder.java15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/TmgProtocolDecoder.java b/src/org/traccar/protocol/TmgProtocolDecoder.java
index 5e852aff2..4a3055932 100644
--- a/src/org/traccar/protocol/TmgProtocolDecoder.java
+++ b/src/org/traccar/protocol/TmgProtocolDecoder.java
@@ -72,9 +72,9 @@ public class TmgProtocolDecoder extends BaseProtocolDecoder {
.number("(d+),") // satellites
.number("[^,]*,") // battery level
.expression("([01]),") // ignition
- .expression("[LH]{4},") // input
+ .expression("([LH]{4}),") // input
.expression("[NT]{4},") // tamper status
- .expression("[LH]{2},") // output
+ .expression("([LH]{2}),") // output
.number("(d+.d+),") // adc1
.number("(d+.d+),") // adc1
.number("[^,]*,") // device id
@@ -171,6 +171,17 @@ public class TmgProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_RSSI, parser.nextInt());
position.set(Position.KEY_SATELLITES, parser.nextInt());
position.set(Position.KEY_IGNITION, parser.nextInt() == 1);
+
+ char[] input = parser.next().toCharArray();
+ for (int i = 0; i < input.length; i++) {
+ position.set(Position.PREFIX_IN + (i + 1), input[i] == 'H');
+ }
+
+ char[] output = parser.next().toCharArray();
+ for (int i = 0; i < output.length; i++) {
+ position.set(Position.PREFIX_OUT + (i + 1), output[i] == 'H');
+ }
+
position.set(Position.PREFIX_ADC + 1, parser.nextDouble());
position.set(Position.PREFIX_ADC + 2, parser.nextDouble());
position.set(Position.KEY_ODOMETER, parser.nextInt());