diff options
-rw-r--r-- | src/org/traccar/protocol/TotemFrameDecoder.java | 2 | ||||
-rw-r--r-- | test/org/traccar/protocol/TotemProtocolDecoderTest.java | 6 | ||||
-rwxr-xr-x | tools/hex.sh | 2 |
3 files changed, 8 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/TotemFrameDecoder.java b/src/org/traccar/protocol/TotemFrameDecoder.java index ad7e160c2..4889fbe0f 100644 --- a/src/org/traccar/protocol/TotemFrameDecoder.java +++ b/src/org/traccar/protocol/TotemFrameDecoder.java @@ -41,7 +41,7 @@ public class TotemFrameDecoder extends FrameDecoder { // Read message int length = Integer.parseInt(buf.toString(2, 2, Charset.defaultCharset()), 16); - if (length >= buf.readableBytes()) { + if (length <= buf.readableBytes()) { return buf.readBytes(length); } diff --git a/test/org/traccar/protocol/TotemProtocolDecoderTest.java b/test/org/traccar/protocol/TotemProtocolDecoderTest.java index fc78f3915..2260fc13a 100644 --- a/test/org/traccar/protocol/TotemProtocolDecoderTest.java +++ b/test/org/traccar/protocol/TotemProtocolDecoderTest.java @@ -57,6 +57,12 @@ public class TotemProtocolDecoderTest { verify(decoder.decode(null, null, "$$B3359772032399074|AA$GPRMC,234603.000,A,3648.2179,N,01008.0962,E,0.00,,030412,,,A*74|01.8|01.0|01.5|000000000000|20120403234603|14251914|00000000|0012D888|0000|0.0000|3674|940B")); + + verify(decoder.decode(null, null, + "$$B2356895037578518|AA$GPRMC,173829.000,A,3740.4107,N,02129.9815,E,0.00,,111113,,,A*7B|02.6|01.6|02.1|000000000000|20131111173829|14041251|00000000|002E0DD7|0000|0.0240|6010|8128")); + + verify(decoder.decode(null, null, + "$$B2356895037578518|AA$GPRMC,203823.000,A,3740.3285,N,02129.9295,E,0.00,,111113,,,A*79|01.5|01.0|01.1|000000000000|20131111203823|14041251|00000000|002E0DD7|0000|0.0000|6371|3824")); } diff --git a/tools/hex.sh b/tools/hex.sh index 8045d405b..762af00d1 100755 --- a/tools/hex.sh +++ b/tools/hex.sh @@ -1,2 +1,2 @@ -echo fe0200014104d8f1968201df40501e58003301e000014104d8f19682525ecd5d525ee344525ee35effc88815026ab4d70000020000104403de01000b0000000007d007d000 | perl -ne 's/([0-9a-f]{2})/print chr hex $1/gie' | nc -v -w 10 localhost 5044 +echo 242442323335363839353033373537383531387c4141244750524d432c3230333832332e3030302c412c333734302e333238352c4e2c30323132392e393239352c452c302e30302c2c3131313131332c2c2c412a37397c30312e357c30312e307c30312e317c3030303030303030303030307c32303133313131313230333832337c31343034313235317c30303030303030307c30303245304444377c303030307c302e303030307c363337317c333832340d0a | perl -ne 's/([0-9a-f]{2})/print chr hex $1/gie' | nc -v -w 10 localhost 5007 |