From 5abaff0e1a37184b67b02864b3527d7334965de8 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 7 Dec 2017 15:35:20 +1300 Subject: Support TMG inputs and outputs --- src/org/traccar/protocol/TmgProtocolDecoder.java | 15 +++++++++++++-- 1 file 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()); -- cgit v1.2.3