diff options
-rw-r--r-- | src/org/traccar/Server.java | 2 | ||||
-rw-r--r-- | src/org/traccar/protocol/avl08/Avl08ProtocolDecoder.java | 3 | ||||
-rw-r--r-- | test/org/traccar/protocol/avl08/Avl08ProtocolDecoderTest.java | 14 |
3 files changed, 10 insertions, 9 deletions
diff --git a/src/org/traccar/Server.java b/src/org/traccar/Server.java index 9f6d326c9..16c26b6d6 100644 --- a/src/org/traccar/Server.java +++ b/src/org/traccar/Server.java @@ -624,7 +624,7 @@ public class Server implements DataManager { if (serverCreator.isLoggerEnabled()) { pipeline.addLast("logger", new LoggingHandler("logger")); } - byte delimiter[] = { (byte) '$', (byte) '$' }; // probably use \r\n + byte delimiter[] = { (byte) '\r', (byte) '\n' }; pipeline.addLast("frameDecoder", new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter))); pipeline.addLast("stringDecoder", new StringDecoder()); diff --git a/src/org/traccar/protocol/avl08/Avl08ProtocolDecoder.java b/src/org/traccar/protocol/avl08/Avl08ProtocolDecoder.java index cc8a2efb7..382c9e998 100644 --- a/src/org/traccar/protocol/avl08/Avl08ProtocolDecoder.java +++ b/src/org/traccar/protocol/avl08/Avl08ProtocolDecoder.java @@ -24,6 +24,7 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.Position; import org.traccar.DataManager; +import org.traccar.Device; // DELME import org.traccar.GenericProtocolDecoder; /** @@ -42,7 +43,7 @@ public class Avl08ProtocolDecoder extends GenericProtocolDecoder { * Regular expressions pattern */ static private Pattern pattern = Pattern.compile( - ".{2}" + // Length + "\\$\\$.{2}" + // Length "(\\d{15})\\|" + // IMEI ".{2}" + // Alarm Type "\\$GPRMC," + diff --git a/test/org/traccar/protocol/avl08/Avl08ProtocolDecoderTest.java b/test/org/traccar/protocol/avl08/Avl08ProtocolDecoderTest.java index 90ab1e78b..8c8a612bc 100644 --- a/test/org/traccar/protocol/avl08/Avl08ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/avl08/Avl08ProtocolDecoderTest.java @@ -36,25 +36,25 @@ public class Avl08ProtocolDecoderTest { //Bytes) + | +RFID(10Bytes)+|+ Checksum (4 Byte) + \r\n(2 Bytes) assertNull(decoder.decode(null, null, - "AE359772033395899|AA000000000000000000000000000000000000000000000000000000000000|00.0|00.0|00.0|000000000000|20090215000153|13601435|00000000|00000000|0000|0.0000|0007|2DAA")); + "$$AE359772033395899|AA000000000000000000000000000000000000000000000000000000000000|00.0|00.0|00.0|000000000000|20090215000153|13601435|00000000|00000000|0000|0.0000|0007|2DAA")); assertNull(decoder.decode(null, null, - "AE359772033395899|AA000000000000000000000000000000000000000000000000000000000000|00.0|00.0|00.0|00000000|20090215001204|14182037|00000000|0012D888|0000|0.0000|0016|5B51")); + "$$AE359772033395899|AA000000000000000000000000000000000000000000000000000000000000|00.0|00.0|00.0|00000000|20090215001204|14182037|00000000|0012D888|0000|0.0000|0016|5B51")); assertNull(decoder.decode(null, null, - "AE359772033395899|AA00000000000000000000000000000000000000000000000000000000000|00.0|00.0|00.0|00000000000|20090215001337|14182013|00000000|0012D888|0000|0.0000|0017|346E")); + "$$AE359772033395899|AA00000000000000000000000000000000000000000000000000000000000|00.0|00.0|00.0|00000000000|20090215001337|14182013|00000000|0012D888|0000|0.0000|0017|346E")); assertNotNull(decoder.decode(null, null, - "B3359772032399074|60$GPRMC,094859.000,A,3648.2229,N,01008.0976,E,0.00,,221211,,,A*79|02.3|01.3|02.0|000000000000|20111222094858|13360808|00000000|00000000|0000|0.0000|0001||A977")); + "$$B3359772032399074|60$GPRMC,094859.000,A,3648.2229,N,01008.0976,E,0.00,,221211,,,A*79|02.3|01.3|02.0|000000000000|20111222094858|13360808|00000000|00000000|0000|0.0000|0001||A977")); assertNotNull(decoder.decode(null, null, - "B3359772032399074|09$GPRMC,094905.000,A,3648.2229,N,01008.0976,E,0.00,,221211,,,A*71|02.1|01.3|01.7|000000000000|20111222094905|03210533|00000000|00000000|0000|0.0000|0002||FA58")); + "$$B3359772032399074|09$GPRMC,094905.000,A,3648.2229,N,01008.0976,E,0.00,,221211,,,A*71|02.1|01.3|01.7|000000000000|20111222094905|03210533|00000000|00000000|0000|0.0000|0002||FA58")); assertNotNull(decoder.decode(null, null, - "B3359772032399074|AA$GPRMC,093911.000,A,3648.2146,N,01008.0977,E,0.00,,140312,,,A*7E|02.1|01.1|01.8|000000000000|20120314093910|04100057|00000000|0012D887|0000|0.0000|1128||C50E")); + "$$B3359772032399074|AA$GPRMC,093911.000,A,3648.2146,N,01008.0977,E,0.00,,140312,,,A*7E|02.1|01.1|01.8|000000000000|20120314093910|04100057|00000000|0012D887|0000|0.0000|1128||C50E")); assertNotNull(decoder.decode(null, null, - "B3359772032399074|AA$GPRMC,094258.000,A,3648.2146,N,01008.0977,E,0.00,,140312,,,A*7F|02.1|01.1|01.8|000000000000|20120314094257|04120057|00000000|0012D887|0000|0.0000|1136||CA32")); + "$$B3359772032399074|AA$GPRMC,094258.000,A,3648.2146,N,01008.0977,E,0.00,,140312,,,A*7F|02.1|01.1|01.8|000000000000|20120314094257|04120057|00000000|0012D887|0000|0.0000|1136||CA32")); } } |