diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-12-09 01:58:36 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2016-12-09 01:58:36 +1300 |
commit | 627069db35c2ef3a433847a546aa7a2c0e0f4d3b (patch) | |
tree | a0b997b6b46f85a4463a2b972ec8742115610cf2 | |
parent | 50503c7108e580e5bc00d6c67055de273f476911 (diff) | |
download | trackermap-server-627069db35c2ef3a433847a546aa7a2c0e0f4d3b.tar.gz trackermap-server-627069db35c2ef3a433847a546aa7a2c0e0f4d3b.tar.bz2 trackermap-server-627069db35c2ef3a433847a546aa7a2c0e0f4d3b.zip |
Fix endianness for AT2000 (fix #2662)
-rw-r--r-- | src/org/traccar/protocol/At2000Protocol.java | 7 | ||||
-rw-r--r-- | src/org/traccar/protocol/At2000ProtocolDecoder.java | 2 | ||||
-rw-r--r-- | test/org/traccar/protocol/At2000ProtocolDecoderTest.java | 11 |
3 files changed, 14 insertions, 6 deletions
diff --git a/src/org/traccar/protocol/At2000Protocol.java b/src/org/traccar/protocol/At2000Protocol.java index 418619cb4..35aa0b469 100644 --- a/src/org/traccar/protocol/At2000Protocol.java +++ b/src/org/traccar/protocol/At2000Protocol.java @@ -20,6 +20,7 @@ import org.jboss.netty.channel.ChannelPipeline; import org.traccar.BaseProtocol; import org.traccar.TrackerServer; +import java.nio.ByteOrder; import java.util.List; public class At2000Protocol extends BaseProtocol { @@ -30,13 +31,15 @@ public class At2000Protocol extends BaseProtocol { @Override public void initTrackerServers(List<TrackerServer> serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { + TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new At2000FrameDecoder()); pipeline.addLast("objectDecoder", new At2000ProtocolDecoder(At2000Protocol.this)); } - }); + }; + server.setEndianness(ByteOrder.LITTLE_ENDIAN); + serverList.add(server); } } diff --git a/src/org/traccar/protocol/At2000ProtocolDecoder.java b/src/org/traccar/protocol/At2000ProtocolDecoder.java index 17da0eef7..f1399b731 100644 --- a/src/org/traccar/protocol/At2000ProtocolDecoder.java +++ b/src/org/traccar/protocol/At2000ProtocolDecoder.java @@ -50,7 +50,7 @@ public class At2000ProtocolDecoder extends BaseProtocolDecoder { private static void sendResponse(Channel channel) { if (channel != null) { - ChannelBuffer response = ChannelBuffers.directBuffer(BLOCK_LENGTH); + ChannelBuffer response = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, BLOCK_LENGTH); response.writeByte(MSG_ACKNOWLEDGEMENT); response.writeMedium(1); response.writeByte(0x00); // success diff --git a/test/org/traccar/protocol/At2000ProtocolDecoderTest.java b/test/org/traccar/protocol/At2000ProtocolDecoderTest.java index e2b848b45..837d4c3b6 100644 --- a/test/org/traccar/protocol/At2000ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/At2000ProtocolDecoderTest.java @@ -3,6 +3,8 @@ package org.traccar.protocol; import org.junit.Test; import org.traccar.ProtocolTest; +import java.nio.ByteOrder; + import static org.junit.Assume.assumeTrue; public class At2000ProtocolDecoderTest extends ProtocolTest { @@ -14,13 +16,16 @@ public class At2000ProtocolDecoderTest extends ProtocolTest { At2000ProtocolDecoder decoder = new At2000ProtocolDecoder(new At2000Protocol()); - verifyNothing(decoder, binary( + verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, + "01012f0000000000000000000000000000333537343534303731363237353938d74dcd195c521a246fb00f16346c7f001919957babc40f84152b60ddeb7ab47a")); + + verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, "01012f00000000000000000000000000003335363137333036343430373439320fad981997ae8e031fe10c0ea7641903ca32c0331df467233d2a9cd886fbeef8")); - verifyPosition(decoder, binary( + verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN, "893f0000000000000000000000000000e048b1a31deba3f5dbe8877f574877e6ed4d022b6611a10d80dfc4c0c11fa8aacf4a9de61528327e2b66843dd9c5d3a7cc9ee1d9c71a34bb482145d88b4fda3e")); - verifyNothing(decoder, binary( + verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, "01012f00000000000000000000000000003335373435343037313632363831345612da3748bede02ea4faf04ac02f420c0ff37719eccf2864fa2b8191abf8242")); } |