diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2013-03-16 19:00:32 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2013-03-16 19:00:32 +1300 |
commit | 8db1cf2bc97f5f616bd5722656db2d69edd46d45 (patch) | |
tree | 011979a862c1ead66d1e8200da5c9d0d08afdf13 | |
parent | 7c8a732d577d6748b9223f720d2dde70f5ebfc41 (diff) | |
download | traccar-server-8db1cf2bc97f5f616bd5722656db2d69edd46d45.tar.gz traccar-server-8db1cf2bc97f5f616bd5722656db2d69edd46d45.tar.bz2 traccar-server-8db1cf2bc97f5f616bd5722656db2d69edd46d45.zip |
Fix xexun protocol decoder (fix #170)
-rw-r--r-- | src/org/traccar/protocol/XexunProtocolDecoder.java | 27 | ||||
-rw-r--r-- | test/org/traccar/protocol/XexunProtocolDecoderTest.java | 3 |
2 files changed, 13 insertions, 17 deletions
diff --git a/src/org/traccar/protocol/XexunProtocolDecoder.java b/src/org/traccar/protocol/XexunProtocolDecoder.java index 1fd572896..53b34d2b1 100644 --- a/src/org/traccar/protocol/XexunProtocolDecoder.java +++ b/src/org/traccar/protocol/XexunProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2012 - 2013 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,14 +27,8 @@ import org.traccar.ServerManager; import org.traccar.helper.Log; import org.traccar.model.Position; -/** - * Xexun tracker protocol decoder - */ public class XexunProtocolDecoder extends BaseProtocolDecoder { - /** - * Initialize - */ public XexunProtocolDecoder(ServerManager serverManager) { super(serverManager); } @@ -42,23 +36,22 @@ public class XexunProtocolDecoder extends BaseProtocolDecoder { /** * Regular expressions pattern */ + //GPRMC,043435.000,A,811.299200,S,11339.9500,E,0.93,29.52,160313,00,0000.0,A*65,F,,imei:359585014597923, static private Pattern pattern = Pattern.compile( "GPRMC," + - "([\\d]{2})([\\d]{2})([\\d]{2}).([\\d]{3})," + // Time (HHMMSS.SSS) + "(\\d{2})(\\d{2})(\\d{2}).(\\d{3})," + // Time (HHMMSS.SSS) "([AV])," + // Validity - "([\\d]{2})([\\d]{2}.[\\d]{4})," + // Latitude (DDMM.MMMM) + "(\\d+)(\\d{2}\\.\\d+)," + // Latitude (DDMM.MMMM) "([NS])," + - "([\\d]{2,3})([\\d]{2}.[\\d]{4})," + // Longitude (DDDMM.MMMM) + "(\\d+)(\\d{2}\\.\\d+)," + // Longitude (DDDMM.MMMM) "([EW])," + - "([\\d]+.[\\d]+)," + // Speed - "([\\d]+.[\\d]+)?," + // Course - "([\\d]{2})([\\d]{2})([\\d]{2})," + // Date (DDMMYY) + "(\\d+\\.\\d+)," + // Speed + "(\\d+\\.\\d+)?," + // Course + "(\\d{2})(\\d{2})(\\d{2})," + // Date (DDMMYY) ".*imei:" + - "([\\d]+),"); // IMEI + "(\\d+),"); // IMEI - /** - * Decode message - */ + @Override protected Object decode( ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception { diff --git a/test/org/traccar/protocol/XexunProtocolDecoderTest.java b/test/org/traccar/protocol/XexunProtocolDecoderTest.java index fa32ed966..8a829c35b 100644 --- a/test/org/traccar/protocol/XexunProtocolDecoderTest.java +++ b/test/org/traccar/protocol/XexunProtocolDecoderTest.java @@ -10,6 +10,9 @@ public class XexunProtocolDecoderTest { XexunProtocolDecoder decoder = new XexunProtocolDecoder(null); decoder.setDataManager(new TestDataManager()); + + assertNotNull(decoder.decode(null, null, + "GPRMC,043435.000,A,811.299200,S,11339.9500,E,0.93,29.52,160313,00,0000.0,A*65,F,,imei:359585014597923,")); assertNotNull(decoder.decode(null, null, "GPRMC,150120.000,A,3346.4463,S,15057.3083,E,0.0,117.4,010911,,,A*76,F,imei:351525010943661,")); |