diff options
Diffstat (limited to 'src/org/traccar')
-rw-r--r-- | src/org/traccar/protocol/TytanProtocolDecoder.java | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/TytanProtocolDecoder.java b/src/org/traccar/protocol/TytanProtocolDecoder.java index 558664e2d..f7c9b8e4d 100644 --- a/src/org/traccar/protocol/TytanProtocolDecoder.java +++ b/src/org/traccar/protocol/TytanProtocolDecoder.java @@ -16,6 +16,7 @@ package org.traccar.protocol; import java.net.SocketAddress; +import java.nio.ByteOrder; import java.nio.charset.Charset; import java.util.Date; import java.util.LinkedHashSet; @@ -37,6 +38,12 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder { super(protocol); } + private static float readSwappedFloat(ChannelBuffer buf) { + byte[] bytes = new byte[4]; + buf.readBytes(bytes); + return ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, bytes).readFloat(); + } + @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) @@ -114,9 +121,9 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder { { int n = buf.readUnsignedByte() >> 4; if (n < 2) { - position.set(Event.PREFIX_ADC + n, buf.readFloat()); + position.set(Event.PREFIX_ADC + n, readSwappedFloat(buf)); } else { - position.set("di" + (n - 2), buf.readFloat()); + position.set("di" + (n - 2), readSwappedFloat(buf)); } } break; @@ -186,7 +193,7 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedInt(); // diagnostic break; case 90: - position.set(Event.KEY_POWER, buf.readFloat()); + position.set(Event.KEY_POWER, readSwappedFloat(buf)); break; case 99: buf.readUnsignedInt(); // tachograph |