From: Kevron Rees Date: Tue, 1 Apr 2014 00:36:52 +0000 (-0700) Subject: fixed up gpsnmea to work with devices with very fragmented nmea messages X-Git-Tag: 0.11.809~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2e5ccc5b02acfad792503ec06849a9a1bb5093da;p=profile%2Fivi%2Fautomotive-message-broker.git fixed up gpsnmea to work with devices with very fragmented nmea messages --- diff --git a/build/plugins/cansimplugin/CMakeFiles/cansimplugin.dir/flags.make b/build/plugins/cansimplugin/CMakeFiles/cansimplugin.dir/flags.make index 18b275b..8586e6c 100644 --- a/build/plugins/cansimplugin/CMakeFiles/cansimplugin.dir/flags.make +++ b/build/plugins/cansimplugin/CMakeFiles/cansimplugin.dir/flags.make @@ -2,7 +2,7 @@ # Generated by "Unix Makefiles" Generator, CMake Version 2.8 # compile CXX with /usr/lib/icecc/bin/g++ -CXX_FLAGS = -g -fPIC -I/home/tripzero/src/automotive-message-broker/lib -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/json-c -I/usr/include/gio-unix-2.0 -I/home/tripzero/src/automotive-message-broker/plugins/common -std=c++11 +CXX_FLAGS = -std=c++11 -g -fPIC -I/home/tripzero/src/automotive-message-broker/lib -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/json-c -I/usr/include/gio-unix-2.0 -I/home/tripzero/src/automotive-message-broker/plugins/common CXX_DEFINES = -DDBusServiceName=\"org.automotive.message.broker\" -DPROJECT_CODENAME=\"veyron\" -DPROJECT_NAME=\"automotive-message-broker\" -DPROJECT_QUALITY=\"alpha\" -DPROJECT_VERSION=\"0.11.808\" -Dcansimplugin_EXPORTS diff --git a/build/plugins/cansimplugin/CMakeFiles/cansimplugin.dir/link.txt b/build/plugins/cansimplugin/CMakeFiles/cansimplugin.dir/link.txt index c4db0c1..75f0d42 100644 --- a/build/plugins/cansimplugin/CMakeFiles/cansimplugin.dir/link.txt +++ b/build/plugins/cansimplugin/CMakeFiles/cansimplugin.dir/link.txt @@ -1 +1 @@ -/usr/lib/icecc/bin/g++ -fPIC -g -shared -Wl,-soname,cansimplugin.so -o cansimplugin.so CMakeFiles/cansimplugin.dir/cansimplugin.cpp.o ../../lib/libamb.so.0.11.808 ../common/libamb-plugins-common.so -L/home/tripzero/src/automotive-message-broker/build/plugins/cansimplugin/plugins/common -lamb -lltdl -lgobject-2.0 -lglib-2.0 -ljson-c -L/home/tripzero/src/automotive-message-broker/build/lib -lrt -luuid -lgio-2.0 -lgobject-2.0 -lglib-2.0 -ljson-c -Wl,-rpath,/home/tripzero/src/automotive-message-broker/build/lib:/home/tripzero/src/automotive-message-broker/build/plugins/common: +/usr/lib/icecc/bin/g++ -fPIC -std=c++11 -g -shared -Wl,-soname,cansimplugin.so -o cansimplugin.so CMakeFiles/cansimplugin.dir/cansimplugin.cpp.o ../../lib/libamb.so.0.11.808 ../common/libamb-plugins-common.so -L/home/tripzero/src/automotive-message-broker/build/plugins/cansimplugin/plugins/common -lamb -lltdl -lgobject-2.0 -lglib-2.0 -ljson-c -L/home/tripzero/src/automotive-message-broker/build/lib -lrt -luuid -lgio-2.0 -lgobject-2.0 -lglib-2.0 -ljson-c -Wl,-rpath,/home/tripzero/src/automotive-message-broker/build/lib:/home/tripzero/src/automotive-message-broker/build/plugins/common: diff --git a/plugins/gpsnmea/gpsnmea.cpp b/plugins/gpsnmea/gpsnmea.cpp index dcac3e6..ea6c262 100644 --- a/plugins/gpsnmea/gpsnmea.cpp +++ b/plugins/gpsnmea/gpsnmea.cpp @@ -413,6 +413,28 @@ GpsNmeaSource::GpsNmeaSource(AbstractRoutingEngine *re, map conf location.parse("GPRMC,023633.00,V,,,,,,,180314,,,N*75"); DebugOut(0)<<"lon: "<read(); + tryParse(data); +} + +bool GpsNmeaSource::tryParse(string data) +{ std::vector lines; - boost::split(lines,data,boost::is_any_of("$")); + boost::split(lines, data, boost::is_any_of("$")); + + bool weFoundAMessage = false; - for(int i = 0; i < lines.size(); i++) + for(auto line : lines) { - if(checksum(lines[i])) + if(checksum(line)) { - buffer = lines[i]; + buffer = line; } else { - buffer += lines[i]; + buffer += line; + } + + uint pos = buffer.find('G'); + + if(pos != std::string::npos && pos != 0) + { + ///Throw the incomplete stuff away. if it doesn't begin with "G" it'll never be complete + buffer = buffer.substr(pos); } if(checksum(buffer)) @@ -526,11 +563,26 @@ void GpsNmeaSource::canHasData() /// we have a complete message. parse it! DebugOut(7)<<"Complete message: "<parse(buffer); + weFoundAMessage = true; + buffer = ""; + } + else + { + if(pos == 0 ) + { + uint cs = buffer.find('*'); + if (cs != std::string::npos) + { + ///This means we have a false flag somewhere. + buffer = buffer.substr(cs+3); + } + } } DebugOut(7)<<"buffer: "<