aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-06-07 11:28:37 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-06-07 11:28:37 +1200
commit1680d3d0234d9d1e2152e644882a9c1fb39a8a47 (patch)
treef86818ef84575744f98e27b470a0225150abde2c
parenteaa0044002aeaff0b5df11f8463a068a6ff2284d (diff)
downloadtrackermap-server-1680d3d0234d9d1e2152e644882a9c1fb39a8a47.tar.gz
trackermap-server-1680d3d0234d9d1e2152e644882a9c1fb39a8a47.tar.bz2
trackermap-server-1680d3d0234d9d1e2152e644882a9c1fb39a8a47.zip
Fix Castel frame decoder
-rw-r--r--src/org/traccar/ServerManager.java2
-rw-r--r--src/org/traccar/protocol/CastelProtocolDecoder.java2
-rw-r--r--test/org/traccar/protocol/CastelProtocolDecoderTest.java3
3 files changed, 5 insertions, 2 deletions
diff --git a/src/org/traccar/ServerManager.java b/src/org/traccar/ServerManager.java
index ae0f4a57e..44adfadbc 100644
--- a/src/org/traccar/ServerManager.java
+++ b/src/org/traccar/ServerManager.java
@@ -1435,7 +1435,7 @@ public class ServerManager {
TrackerServer server = new TrackerServer(new ServerBootstrap(), protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 2, -2, 0));
+ pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 2, -4, 0));
pipeline.addLast("objectDecoder", new CastelProtocolDecoder(protocol));
}
};
diff --git a/src/org/traccar/protocol/CastelProtocolDecoder.java b/src/org/traccar/protocol/CastelProtocolDecoder.java
index fbba960a5..c919ec936 100644
--- a/src/org/traccar/protocol/CastelProtocolDecoder.java
+++ b/src/org/traccar/protocol/CastelProtocolDecoder.java
@@ -126,7 +126,7 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
double lat = buf.readUnsignedInt() / 3600000.0;
double lon = buf.readUnsignedInt() / 3600000.0;
position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShort()));
- position.setCourse(buf.readUnsignedShort());
+ position.setCourse(buf.readUnsignedShort() % 360);
int flags = buf.readUnsignedByte();
position.setLatitude((flags & 0x01) == 0 ? -lat : lat);
diff --git a/test/org/traccar/protocol/CastelProtocolDecoderTest.java b/test/org/traccar/protocol/CastelProtocolDecoderTest.java
index e74707185..1671e4d12 100644
--- a/test/org/traccar/protocol/CastelProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/CastelProtocolDecoderTest.java
@@ -22,6 +22,9 @@ public class CastelProtocolDecoderTest extends ProtocolDecoderTest {
verify(decoder.decode(null, null, null, ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, ChannelBufferTools.convertHexString(
"40405900043130303131313235323939383700000000000000400101C1F06952E7F069529C9111000000000069830000070000000400036401014C00030001190A0D0412041480D60488C57218000000009F01E803ED9A0D0A"))));
+
+ verify(decoder.decode(null, null, null, ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, ChannelBufferTools.convertHexString(
+ "40405900043335343034333035303834343134330000000000400100f61a7355c11b7355710000000b00000000000000000000000400000000240e0200020106060f100b2d5a78a7076ec0fb1d00008c065f010000ac220d0a"))));
}