From a946618d649cde478d8750bb6b84cb521b68c87c Mon Sep 17 00:00:00 2001 From: Leandro Silva Ferreira Date: Wed, 15 Aug 2012 08:58:26 -0400 Subject: Corrections of wrong "git fetch upstream" --- .../traccar/protocol/ST210ProtocolDecoderTest.java | 53 ++-------------------- 1 file changed, 3 insertions(+), 50 deletions(-) (limited to 'test/org/traccar') diff --git a/test/org/traccar/protocol/ST210ProtocolDecoderTest.java b/test/org/traccar/protocol/ST210ProtocolDecoderTest.java index 63234efd0..9fc6f9e28 100644 --- a/test/org/traccar/protocol/ST210ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/ST210ProtocolDecoderTest.java @@ -1,58 +1,11 @@ package org.traccar.protocol; -import static org.junit.Assert.*; +import static org.junit.Assert.assertNotNull; -import java.io.IOException; -import java.sql.SQLException; - -import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; -import org.traccar.Server; -import org.traccar.helper.Log; -//import org.traccar.server.SocketCliente; public class ST210ProtocolDecoderTest { - /* - @BeforeClass - public static void UpServer() { - final Server service = new Server(); - String[] args = new String[1]; - args[0] = "setup\\windows\\windows.cfg"; - try { - service.init(args); - - Log.info("starting server..."); - service.start(); - - // Shutdown server properly - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - Log.info("shutting down server..."); - service.stop(); - } - }); - - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Test - public void testClienteMsg() throws Exception { - - SocketCliente cliente = new SocketCliente(); - cliente.SendMSG( - "localhost", - 5010, - "SA200STT;317652;042;20120718;15:37:12;16d41;-15.618755;-056.083241;000.024;000.00;8;1;41548;12.17;100000;2;1979"); - } - -*/ - @Test public void testDecode() throws Exception { @@ -70,7 +23,7 @@ public class ST210ProtocolDecoderTest { assertNotNull(decoder .decode(null, null, - "SA200STT;317652;042;20120722;00:24:23;16d41;-15.618767;-056.083214;000.011;000.00;11;1;41557;12.21;000000;1;3205")); + "SA200STT;317652;042;20120722;00:24:23;4f310;-15.618767;-056.083214;000.011;000.00;11;1;41557;12.21;000000;1;3205")); assertNotNull(decoder .decode(null, null, @@ -78,7 +31,7 @@ public class ST210ProtocolDecoderTest { assertNotNull(decoder .decode(null, null, - "SA200STT;315198;042;20120809;13:43:34;16d41;-15.618709;-056.083223;000.025;000.00;8;1;49;12.10;100000;2;0231")); + "SA200STT;315198;042;20120809;13:43:34;4f310;-15.618709;-056.083223;000.025;000.00;8;1;49;12.10;100000;2;0231")); assertNotNull(decoder .decode(null, null, -- cgit v1.2.3 From ba78f64d458bf03a3ffbac87369def5f79cbc8ae Mon Sep 17 00:00:00 2001 From: Leandro Silva Ferreira Date: Wed, 15 Aug 2012 12:07:46 -0400 Subject: Corrections of reamaing problems of CELL field. --- src/org/traccar/protocol/ST210ProtocolDecoder.java | 2 +- test/org/traccar/protocol/ST210ProtocolDecoderTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'test/org/traccar') diff --git a/src/org/traccar/protocol/ST210ProtocolDecoder.java b/src/org/traccar/protocol/ST210ProtocolDecoder.java index 61dcf8782..983e9c6f4 100644 --- a/src/org/traccar/protocol/ST210ProtocolDecoder.java +++ b/src/org/traccar/protocol/ST210ProtocolDecoder.java @@ -33,7 +33,7 @@ public class ST210ProtocolDecoder extends GenericProtocolDecoder { SW_VER("(\\d{3});", "Software Release Version"), DATE("(\\d+);","GPS date (yyyymmdd) Year + Month + Day"), TIME("(\\d{2}:\\d{2}:\\d{2});","GPS time (hh:mm:ss) Hour : Minute : Second"), - CELL("(\\w{3}\\d{2});","Location Code ID (3 digits hex) + Serving Cell BSIC(2 digits decimal)"), + CELL("(\\w+);","Location Code ID (3 digits hex) + Serving Cell BSIC(2 digits decimal)"), LAT("(-\\d{2}.\\d+);", "Latitude (+/-xx.xxxxxx)"), LON("(-\\d{3}.\\d+);", "Longitude (+/-xxx.xxxxxx)"), SPD("(\\d{3}.\\d{3});","Speed in km/h - This value returns to 0 when it is over than 200,000Km"), diff --git a/test/org/traccar/protocol/ST210ProtocolDecoderTest.java b/test/org/traccar/protocol/ST210ProtocolDecoderTest.java index 9fc6f9e28..bc2e6e21e 100644 --- a/test/org/traccar/protocol/ST210ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/ST210ProtocolDecoderTest.java @@ -27,7 +27,7 @@ public class ST210ProtocolDecoderTest { assertNotNull(decoder .decode(null, null, - "SA200STT;315198;042;20120808;20:37:34;42948;-15.618731;-056.083216;000.007;000.00;12;1;48;0.00;000000;1;0127")); + "SA200STT;315198;042;20120808;20:37:34;3fac25;-15.618731;-056.083216;000.007;000.00;12;1;48;0.00;000000;1;0127")); assertNotNull(decoder .decode(null, null, -- cgit v1.2.3 From 33cc8f56d87556a2233c174a39247048bb2e33fd Mon Sep 17 00:00:00 2001 From: Leandro Silva Ferreira Date: Wed, 15 Aug 2012 22:15:59 -0400 Subject: Improvements on decoder to decode status, emergency and keep alive messages from avl. --- src/org/traccar/protocol/ST210ProtocolDecoder.java | 15 +++++++++++---- test.sh | 3 +++ test/org/traccar/protocol/ST210ProtocolDecoderTest.java | 5 +++++ 3 files changed, 19 insertions(+), 4 deletions(-) (limited to 'test/org/traccar') diff --git a/src/org/traccar/protocol/ST210ProtocolDecoder.java b/src/org/traccar/protocol/ST210ProtocolDecoder.java index 983e9c6f4..2f9bcd863 100644 --- a/src/org/traccar/protocol/ST210ProtocolDecoder.java +++ b/src/org/traccar/protocol/ST210ProtocolDecoder.java @@ -23,8 +23,7 @@ public class ST210ProtocolDecoder extends GenericProtocolDecoder { } private enum ST210FIELDS { - HDR_STATUS("SA200STT;", - "Status Report"), + HDR_STATUS("SA200STT;","Status Report"), HDR_EMERGENCY("SA200EMG;","Emergency Report"), HDR_EVENT("SA200EVT;", "Event Report"), HDR_ALERT("SA200ALT;","Alert Report"), @@ -44,8 +43,8 @@ public class ST210ProtocolDecoder extends GenericProtocolDecoder { PWR_VOLT("(\\d+.\\d{2});","Voltage value of main power"), IO("(\\d+);","Current I/O status of inputs and outputs."), MODE("(\\d);","1 = Idle mode (Parking)\n" + "2 = Active Mode (Driving)"), - MSG_NUM("(\\d{4})","Message number - After 9999 is reported, message number returns to 0000"), - EMG_ID("(\\d)", "Emergency type"), + MSG_NUM("(\\d{4});","Message number - After 9999 is reported, message number returns to 0000"), + EMG_ID("(\\d);", "Emergency type"), EVT_ID("(\\d);", "Event type"), ALERT_ID("(\\d);", "Alert type"); @@ -488,6 +487,10 @@ public class ST210ProtocolDecoder extends GenericProtocolDecoder { patternStr += field.getPattern(); } + if(patternStr.endsWith(";")){ + patternStr = patternStr.substring(0, patternStr.length()-1); + } + return Pattern.compile(patternStr); } @@ -631,6 +634,10 @@ public class ST210ProtocolDecoder extends GenericProtocolDecoder { throw new Exception("Pattern no match: " + protocolPattern.toString()); } + if(report.equals(ST210REPORTS.ALIVE)){ + return null; + } + // Create new position Position position = new Position(); diff --git a/test.sh b/test.sh index 03c1af4fe..66d4535eb 100755 --- a/test.sh +++ b/test.sh @@ -43,3 +43,6 @@ echo "10. st210" echo "11. st210emg" (echo -n -e "SA200EMG;317652;042;20120718;15:35:41;16d41;-15.618740;-056.083252;000.034;000.00;8;1;41548;12.17;110000;1\r";) | nc -v localhost 8801 + +echo "12. st210alv" +(echo -n -e "SA200ALV;317652\r";) | nc -v localhost 8801 diff --git a/test/org/traccar/protocol/ST210ProtocolDecoderTest.java b/test/org/traccar/protocol/ST210ProtocolDecoderTest.java index bc2e6e21e..403b5621a 100644 --- a/test/org/traccar/protocol/ST210ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/ST210ProtocolDecoderTest.java @@ -1,6 +1,7 @@ package org.traccar.protocol; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import org.junit.Test; @@ -36,6 +37,10 @@ public class ST210ProtocolDecoderTest { .decode(null, null, "SA200EMG;317652;042;20120718;15:35:41;16d41;-15.618740;-056.083252;000.034;000.00;8;1;41548;12.17;110000;1")); + assertNull(decoder + .decode(null, + null, + "SA200ALV;317652")); } } -- cgit v1.2.3