diff options
-rw-r--r-- | src/org/traccar/protocol/GalileoProtocolDecoder.java | 89 | ||||
-rw-r--r-- | test/org/traccar/protocol/GalileoProtocolDecoderTest.java | 3 |
2 files changed, 30 insertions, 62 deletions
diff --git a/src/org/traccar/protocol/GalileoProtocolDecoder.java b/src/org/traccar/protocol/GalileoProtocolDecoder.java index e66d8fa53..f9631dbf4 100644 --- a/src/org/traccar/protocol/GalileoProtocolDecoder.java +++ b/src/org/traccar/protocol/GalileoProtocolDecoder.java @@ -105,6 +105,30 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder { } private void decodeTag(Position position, ByteBuf buf, int tag) { + if (tag >= 0x50 && tag <= 0x57) { + position.set(Position.PREFIX_ADC + (tag - 0x50), buf.readUnsignedShortLE()); + } else if (tag >= 0x60 && tag <= 0x62) { + position.set("fuel" + (tag - 0x60), buf.readUnsignedShortLE()); + } else if (tag >= 0xa0 && tag <= 0xaf) { + position.set("can8BitR" + (tag - 0xa0 + 15), buf.readUnsignedByte()); + } else if (tag >= 0xb0 && tag <= 0xb9) { + position.set("can16BitR" + (tag - 0xb0 + 5), buf.readUnsignedShortLE()); + } else if (tag >= 0xc4 && tag <= 0xd2) { + position.set("can8BitR" + (tag - 0xc4), buf.readUnsignedByte()); + } else if (tag >= 0xd6 && tag <= 0xda) { + position.set("can16BitR" + (tag - 0xd6), buf.readUnsignedShortLE()); + } else if (tag >= 0xdb && tag <= 0xdf) { + position.set("can32BitR" + (tag - 0xdb), buf.readUnsignedIntLE()); + } else if (tag >= 0xe2 && tag <= 0xe9) { + position.set("userData" + (tag - 0xe2), buf.readUnsignedIntLE()); + } else if (tag >= 0xf0 && tag <= 0xf9) { + position.set("can32BitR" + (tag - 0xf0 + 5), buf.readUnsignedIntLE()); + } else { + decodeTagOther(position, buf, tag); + } + } + + private void decodeTagOther(Position position, ByteBuf buf, int tag) { switch (tag) { case 0x01: position.set(Position.KEY_VERSION_HW, buf.readUnsignedByte()); @@ -152,22 +176,15 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder { case 0x46: position.set(Position.KEY_INPUT, buf.readUnsignedShortLE()); break; - case 0x50: - case 0x51: - case 0x52: - case 0x53: - case 0x54: - case 0x55: - case 0x56: - case 0x57: - position.set(Position.PREFIX_ADC + (tag - 0x50), buf.readUnsignedShortLE()); - break; case 0x58: position.set("rs2320", buf.readUnsignedShortLE()); break; case 0x59: position.set("rs2321", buf.readUnsignedShortLE()); break; + case 0x90: + position.set(Position.KEY_DRIVER_UNIQUE_ID, String.valueOf(buf.readUnsignedIntLE())); + break; case 0xc0: position.set("fuelTotal", buf.readUnsignedIntLE() * 0.5); break; @@ -182,37 +199,6 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder { case 0xc3: position.set("canB1", buf.readUnsignedIntLE()); break; - case 0xc4: - case 0xc5: - case 0xc6: - case 0xc7: - case 0xc8: - case 0xc9: - case 0xca: - case 0xcb: - case 0xcc: - case 0xcd: - case 0xce: - case 0xcf: - case 0xd0: - case 0xd1: - case 0xd2: - position.set("can8Bit" + (tag - 0xc4), buf.readUnsignedByte()); - break; - case 0xd6: - case 0xd7: - case 0xd8: - case 0xd9: - case 0xda: - position.set("can16Bit" + (tag - 0xd6), buf.readUnsignedShortLE()); - break; - case 0xdb: - case 0xdc: - case 0xdd: - case 0xde: - case 0xdf: - position.set("can32Bit" + (tag - 0xdb), buf.readUnsignedIntLE()); - break; case 0xd4: position.set(Position.KEY_ODOMETER, buf.readUnsignedIntLE()); break; @@ -223,31 +209,10 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_RESULT, buf.readSlice(buf.readUnsignedByte()).toString(StandardCharsets.US_ASCII)); break; - case 0xe2: - case 0xe3: - case 0xe4: - case 0xe5: - case 0xe6: - case 0xe7: - case 0xe8: - case 0xe9: - position.set("userData" + (tag - 0xe2), buf.readUnsignedIntLE()); - break; case 0xea: position.set("userDataArray", ByteBufUtil.hexDump(buf.readSlice(buf.readUnsignedByte()))); position.set("userDataArray", ByteBufUtil.hexDump(buf.readSlice(buf.readUnsignedByte()))); break; - case 0xf0: - case 0xf1: - case 0xf2: - case 0xf3: - case 0xf4: - case 0xf5: - case 0xf6: - case 0xf7: - case 0xf8: - position.set("can32Bit" + (tag - 0xf0 + 5), buf.readUnsignedIntLE()); - break; default: buf.skipBytes(getTagLength(tag)); break; diff --git a/test/org/traccar/protocol/GalileoProtocolDecoderTest.java b/test/org/traccar/protocol/GalileoProtocolDecoderTest.java index 5e86f5a84..be009cf91 100644 --- a/test/org/traccar/protocol/GalileoProtocolDecoderTest.java +++ b/test/org/traccar/protocol/GalileoProtocolDecoderTest.java @@ -11,6 +11,9 @@ public class GalileoProtocolDecoderTest extends ProtocolTest { GalileoProtocolDecoder decoder = new GalileoProtocolDecoder(new GalileoProtocol()); verifyPositions(decoder, binary( + "011801018202130338363833343530333230343234323604640010a406207caa9f5b300c830a7901ca0ec802330000000034b802350540003e41703f422b1043234504004600e09000000000a000a100a200a300a400a500a600a700a800a900aa00ab00ac00ad00ae00af00b00000b10000b20000b30000b40000b50000b60000b70000b80000b90000c000000000c100000000c200000000c300000000c400c500c600c700c800c900ca00cb00cc00cd00ce00cf00d000d100d200d4d3140000d60000d70000d80000d90000da0000db00000000dc00000000dd00000000de00000000df00000000f000000000f100000000f200000000f300000000f400000000f500000000f600000000f700000000f800000000f9000000008960")); + + verifyPositions(decoder, binary( "017583018202120338363833343530333230363635373304520010384520c850975b300cc03a910107cbf9023365000607341300350640012a41236a4215104329450400460020500000510000520000530000540000550000c000000000c100000000c44bc500c6ffc700c800c900ca00cb00d4993b0500d64100d70000d8be02d90000da0000db00000000dc00000000dd00000000de00000000df00000000f000000000f100000000f200000000f300000000018202120338363833343530333230363635373304520010394520c950975b300cab3a91010ecbf902336000be06341300350640012a41266a4216104329450400460020500000510000520000530000540000550000c000000000c100000000c44bc500c6ffc700c800c900ca00cb00d49b3b0500d64100d70000d8bc02d90000da0000db00000000dc00000000dd00000000de00000000df00000000f000000000f100000000f200000000f3000000000182021203383638333435303332303636353733045200103a4520ca50975b300c953a910113cbf9023358008f06341300350640012a41206a4215104329450400460020500000510000520000530000540000550000c000000000c100000000c44bc500c6ffc700c800c900ca00cb00d49e3b0500d64100d70000d8ba02d90000da0000db00000000dc00000000dd00000000de00000000df00000000f000000000f100000000f200000000f3000000000182021203383638333435303332303636353733045200103b45204251975b300c6d3a91011dcbf9023300008a06341300350640013a41726a4216104329450400460020500000510000520000530000540000550000c000000000c100000000c44bc500c6ffc700c800c900ca00cb00d4a33b0500d64800d70000d80003d90000da0000db00000000dc00000000dd00000000de00000000df00000000f000000000f100000000f200000000f3000000000182021203383638333435303332303636353733045200103c4520bb51975b300c6d3a91011dcbf9023300008a06341300350640013a41816a4216104329450400460020500000510000520000530000540000550000c000000000c100000000c44bc500c6ffc700c800c900ca00cb00d4a33b0500d64800d70000d80003d90000da0000db00000000dc00000000dd00000000de00000000df00000000f000000000f100000000f200000000f300000000e007")); verifyNull(decoder, binary( |