diff options
-rw-r--r-- | src/org/traccar/protocol/Xexun2ProtocolDecoder.java | 19 | ||||
-rw-r--r-- | test/org/traccar/protocol/Xexun2ProtocolDecoderTest.java | 10 |
2 files changed, 22 insertions, 7 deletions
diff --git a/src/org/traccar/protocol/Xexun2ProtocolDecoder.java b/src/org/traccar/protocol/Xexun2ProtocolDecoder.java index 900315d20..098647499 100644 --- a/src/org/traccar/protocol/Xexun2ProtocolDecoder.java +++ b/src/org/traccar/protocol/Xexun2ProtocolDecoder.java @@ -38,22 +38,22 @@ public class Xexun2ProtocolDecoder extends BaseProtocolDecoder { "(\\d+)," + // Serial "(\\+?\\d+)," + // Number "GPRMC," + - "(\\d{2})(\\d{2})(\\d{2})\\.(\\d{3})," + // Time (HHMMSS.SSS) + "(\\d{2})(\\d{2})(\\d{2})\\.(\\d+)," + // Time (HHMMSS.SSS) "([AV])," + // Validity - "(\\d{2})(\\d{2}\\.\\d{4})," + // Latitude (DDMM.MMMM) + "(\\d{2})(\\d{2}\\.\\d+)," + // Latitude (DDMM.MMMM) "([NS])," + - "(\\d{3})(\\d{2}\\.\\d{4})," + // Longitude (DDDMM.MMMM) + "(\\d{3})(\\d{2}\\.\\d+)," + // Longitude (DDDMM.MMMM) "([EW])," + "(\\d+\\.\\d+)," + // Speed "(\\d+\\.\\d+)?," + // Course "(\\d{2})(\\d{2})(\\d{2})," + // Date (DDMMYY) - ",,.\\*..," + // Checksum + "[^,]*,[^,]*,.\\*..," + // Checksum "([FL])," + // Signal - "(.*)," + // Alarm + "(?:([^,]*),)?" + // Alarm ".*imei:" + "(\\d+)," + // IMEI "(\\d+)," + // Satellites - "(-?\\d+\\.\\d+)," + // Altitude + "(-?\\d+\\.\\d+)?," + // Altitude "[FL]:(\\d+\\.\\d+)V," + // Power ".*" + "[\r\n]*"); @@ -141,7 +141,12 @@ public class Xexun2ProtocolDecoder extends BaseProtocolDecoder { extendedInfo.set("satellites", parser.group(index++).replaceFirst ("^0*(?![\\.$])", "")); // Altitude - position.setAltitude(Double.valueOf(parser.group(index++))); + String altitude = parser.group(index++); + if (altitude != null) { + position.setAltitude(Double.valueOf(altitude)); + } else { + position.setAltitude(0.0); + } // Power position.setPower(Double.valueOf(parser.group(index++))); diff --git a/test/org/traccar/protocol/Xexun2ProtocolDecoderTest.java b/test/org/traccar/protocol/Xexun2ProtocolDecoderTest.java index c9b97684c..f6c967039 100644 --- a/test/org/traccar/protocol/Xexun2ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Xexun2ProtocolDecoderTest.java @@ -25,6 +25,16 @@ public class Xexun2ProtocolDecoderTest { assertNotNull(decoder.decode(null, null, "111111120009,436763737552,GPRMC,120600.000,A,6000.0000,N,13000.0000,E,0.00,0.00,010112,,,A*68,F,help me!, imei:123456789012345,04,481.2,L:3.5V,0,139,2689,232,03,2725,0576")); + + assertNotNull(decoder.decode(null, null, + "111111120009,+1234,GPRMC,204530.4,A,6000.0000,N,13000.0000,E,0.0,,010112,0.0,E,A*68,F,imei:123456789012345,04,123.5,F:3.55V,0,139,,232,03,272CE1,0576")); + + assertNotNull(decoder.decode(null, null, + "111111120009,+1234,GPRMC,204530.4,A,6000.000,N,01000.6288,E,0.0,0.00,230713,0.0,E,A*3C,F,imei:123456789012345,00,,F:3.88V,0,125,,262,01,224CE1,379B")); + + assertNotNull(decoder.decode(null, null, + "111111120009,+1234,GPRMC,215840.7,A,6000.000,N,01000.6253,E,0.0,0.00,230713,0.0,E,A*34,F,imei:123456789012345,00,,F:3.9V,0,124,,262,01,224CE1,379B")); + } } |