From 969ba1f91e5d3da4831a0628580785ba0cb7cafb Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 6 Jul 2013 15:23:21 +1200 Subject: Fix Meiligao decoder (fix #324) --- src/org/traccar/protocol/MeiligaoProtocolDecoder.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/org/traccar') diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java index 42d7ca350..9202498e4 100644 --- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java +++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java @@ -39,11 +39,11 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { } static private Pattern pattern = Pattern.compile( - "(\\d{2})(\\d{2})(\\d{2})\\.(\\d+)," + // Time (HHMMSS.SSS) + "(\\d{2})(\\d{2})(\\d{2})\\.?(\\d+)?," + // Time (HHMMSS.SSS) "([AV])," + // Validity - "(\\d{2})(\\d{2}\\.\\d+)," + // Latitude (DDMM.MMMM) + "(\\d+)(\\d{2}\\.\\d+)," + // Latitude (DDMM.MMMM) "([NS])," + - "(\\d{3})(\\d{2}\\.\\d+)," + // Longitude (DDDMM.MMMM) + "(\\d+)(\\d{2}\\.\\d+)," + // Longitude (DDDMM.MMMM) "([EW])," + "(\\d+.\\d+)," + // Speed "(\\d+\\.?\\d*)?," + // Course @@ -158,7 +158,10 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { time.set(Calendar.HOUR, Integer.valueOf(parser.group(index++))); time.set(Calendar.MINUTE, Integer.valueOf(parser.group(index++))); time.set(Calendar.SECOND, Integer.valueOf(parser.group(index++))); - time.set(Calendar.MILLISECOND, Integer.valueOf(parser.group(index++))); + String mseconds = parser.group(index++); + if (mseconds != null) { + time.set(Calendar.MILLISECOND, Integer.valueOf(mseconds)); + } // Validity position.setValid(parser.group(index++).compareTo("A") == 0 ? true : false); -- cgit v1.2.3