diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-10-07 05:35:45 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2016-10-07 13:36:51 +1300 |
commit | bf0bf92ddadee86fc92841fe6087e5a7910bc0a2 (patch) | |
tree | bf80c5c3154f536d846100a82665b748f72d5802 /src | |
parent | 453bd2ed647d66725790b35eaab4932bf86b3ad1 (diff) | |
download | traccar-server-bf0bf92ddadee86fc92841fe6087e5a7910bc0a2.tar.gz traccar-server-bf0bf92ddadee86fc92841fe6087e5a7910bc0a2.tar.bz2 traccar-server-bf0bf92ddadee86fc92841fe6087e5a7910bc0a2.zip |
Support short Fifotrack format
Diffstat (limited to 'src')
-rw-r--r-- | src/org/traccar/protocol/FifotrackProtocolDecoder.java | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/org/traccar/protocol/FifotrackProtocolDecoder.java b/src/org/traccar/protocol/FifotrackProtocolDecoder.java index 9e8d01117..9c0f6be5a 100644 --- a/src/org/traccar/protocol/FifotrackProtocolDecoder.java +++ b/src/org/traccar/protocol/FifotrackProtocolDecoder.java @@ -51,15 +51,15 @@ public class FifotrackProtocolDecoder extends BaseProtocolDecoder { .number("(d+),") // odometer .number("d+,") // runtime .number("(xxxx),") // status - .number("(x+),") // input - .number("(x+),") // output + .number("(x+)?,") // input + .number("(x+)?,") // output .number("(d+)|") // mcc .number("(d+)|") // mnc .number("(x+)|") // lac .number("(x+),") // cid - .number("([x|]+),") // adc - .expression("([^,]+),") // rfid - .expression("([^*]+)") // sensors + .number("([x|]+)") // adc + .expression(",([^,]+)") // rfid + .expression(",([^*]+)").optional(2) // sensors .any() .compile(); @@ -97,8 +97,12 @@ public class FifotrackProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_ODOMETER, parser.nextLong()); position.set(Position.KEY_STATUS, parser.nextInt(16)); - position.set(Position.KEY_INPUT, parser.nextInt(16)); - position.set(Position.KEY_OUTPUT, parser.nextInt(16)); + if (parser.hasNext()) { + position.set(Position.KEY_INPUT, parser.nextInt(16)); + } + if (parser.hasNext()) { + position.set(Position.KEY_OUTPUT, parser.nextInt(16)); + } position.set(Position.KEY_MCC, parser.nextInt()); position.set(Position.KEY_MNC, parser.nextInt()); @@ -112,9 +116,11 @@ public class FifotrackProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_RFID, parser.next()); - String[] sensors = parser.next().split("\\|"); - for (int i = 0; i < sensors.length; i++) { - position.set(Position.PREFIX_IO + (i + 1), sensors[i]); + if (parser.hasNext()) { + String[] sensors = parser.next().split("\\|"); + for (int i = 0; i < sensors.length; i++) { + position.set(Position.PREFIX_IO + (i + 1), sensors[i]); + } } return position; |