diff options
12 files changed, 363 insertions, 26 deletions
diff --git a/enhanced-position-service/api/genivi-positioning-configuration.xml b/enhanced-position-service/api/genivi-positioning-configuration.xml index a3f9265..8ebedd3 100644 --- a/enhanced-position-service/api/genivi-positioning-configuration.xml +++ b/enhanced-position-service/api/genivi-positioning-configuration.xml @@ -12,10 +12,10 @@ this file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->
-<node name="/org/genivi/enhancedpositionservice" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="introspect.xsd">
+<node name="/org/genivi/positioning/Configuration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="introspect.xsd">
<interface name="org.genivi.positioning.Configuration">
- <version>2.0.0 (04-06-2013)</version>
+ <version>3.0.0-alpha (05-08-2014)</version>
<doc>
<line>Configuration = This interface allows a client application to set and retrieve configuration options</line>
</doc>
diff --git a/enhanced-position-service/api/genivi-positioning-enhancedposition.xml b/enhanced-position-service/api/genivi-positioning-enhancedposition.xml index aa9c230..a8b1dda 100644 --- a/enhanced-position-service/api/genivi-positioning-enhancedposition.xml +++ b/enhanced-position-service/api/genivi-positioning-enhancedposition.xml @@ -12,10 +12,10 @@ this file, You can obtain one at http://mozilla.org/MPL/2.0/. --> -<node name="/org/genivi/enhancedpositionservice" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="introspect.xsd"> +<node name="/org/genivi/positioning/EnhancedPosition" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="introspect.xsd"> <interface name="org.genivi.positioning.EnhancedPosition"> - <version>2.0.0 (04-06-2013)</version> + <version>3.0.0-alpha (05-08-2014)</version> <doc> <line>EnhancedPosition = This interface offers functionalities to retrieve the enhanced position of the vehicle</line> </doc> diff --git a/enhanced-position-service/api/genivi-positioning-positionfeedback.xml b/enhanced-position-service/api/genivi-positioning-positionfeedback.xml index c90910c..55418fd 100644 --- a/enhanced-position-service/api/genivi-positioning-positionfeedback.xml +++ b/enhanced-position-service/api/genivi-positioning-positionfeedback.xml @@ -11,10 +11,10 @@ this file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->
-<node name="/org/genivi/enhancedpositionservice" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="introspect.xsd">
+<node name="/org/genivi/positioning/PositionFeedback" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="introspect.xsd">
<interface name="org.genivi.positioning.PositionFeedback">
- <version>2.0.0 (04-06-2013)</version>
+ <version>3.0.0-alpha (05-08-2014)</version>
<doc>
<line>PositionFeedback = This interface allows the application implementing the map-matching algorithm to provide a position feedback to the EnahncedPositionService</line>
</doc>
diff --git a/enhanced-position-service/src/configuration.cpp b/enhanced-position-service/src/configuration.cpp index e99ccc2..959c4aa 100644 --- a/enhanced-position-service/src/configuration.cpp +++ b/enhanced-position-service/src/configuration.cpp @@ -67,10 +67,10 @@ Configuration::~Configuration() { ::DBus::Struct< uint16_t, uint16_t, uint16_t, std::string > Version; - Version._1 = 2; + Version._1 = 3; Version._2 = 0; Version._3 = 0; - Version._4 = std::string("04-06-2013"); + Version._4 = std::string("05-08-2014"); return Version; } diff --git a/enhanced-position-service/src/enhanced-position.cpp b/enhanced-position-service/src/enhanced-position.cpp index b8a1a13..a1b999e 100644 --- a/enhanced-position-service/src/enhanced-position.cpp +++ b/enhanced-position-service/src/enhanced-position.cpp @@ -17,6 +17,7 @@ **************************************************************************/ #include <stdio.h> +#include <stdlib.h> #include "enhanced-position.h" #include "positioning-constants.h" #include "log.h" @@ -72,10 +73,10 @@ EnhancedPosition::~EnhancedPosition() { ::DBus::Struct< uint16_t, uint16_t, uint16_t, std::string > Version; - Version._1 = 2; + Version._1 = 3; Version._2 = 0; Version._3 = 0; - Version._4 = std::string("04-06-2013"); + Version._4 = std::string("05-08-2014"); return Version; } diff --git a/enhanced-position-service/src/position-feedback.cpp b/enhanced-position-service/src/position-feedback.cpp index b36fc65..21251b9 100644 --- a/enhanced-position-service/src/position-feedback.cpp +++ b/enhanced-position-service/src/position-feedback.cpp @@ -34,10 +34,10 @@ PositionFeedback::~PositionFeedback() { ::DBus::Struct< uint16_t, uint16_t, uint16_t, std::string > Version; - Version._1 = 2; + Version._1 = 3; Version._2 = 0; Version._3 = 0; - Version._4 = std::string("04-06-2013"); + Version._4 = std::string("05-08-2014"); return Version; } diff --git a/enhanced-position-service/test/enhanced-position-client.cpp b/enhanced-position-service/test/enhanced-position-client.cpp index b68c1e2..01717f3 100644 --- a/enhanced-position-service/test/enhanced-position-client.cpp +++ b/enhanced-position-service/test/enhanced-position-client.cpp @@ -114,9 +114,6 @@ int main() DBus::default_dispatcher = &dispatcher; - // increase DBus-C++ frequency - new DBus::DefaultTimeout(100, false, &dispatcher); - DBus::Connection conn = DBus::Connection::SessionBus(); EnhancedPositionClient client(conn, diff --git a/enhanced-position-service/test/test-scripts/positioning-monitor.pl b/enhanced-position-service/test/test-scripts/positioning-monitor.pl new file mode 100755 index 0000000..624f3a4 --- /dev/null +++ b/enhanced-position-service/test/test-scripts/positioning-monitor.pl @@ -0,0 +1,59 @@ +#! /usr/bin/perl -w
+###########################################################################
+# Component Name: Navit POC
+# Author: Martin Schaller <martin.schaller@it-schaller.de>
+#
+# Copyright (C) 2012, GENIVI Alliance, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+###########################################################################
+$| = 1;
+open(MON,"dbus-monitor|");
+while (<MON>) {
+ if (/^method call.*;\ interface=org\.genivi\.positioning/) {
+ $serial=$_;
+ $serial=~s/.*serial=//;
+ $serial=~s/\ path=.*//;
+ $active=1;
+ print $_;
+ $serials{$serial}=1;
+ } elsif (/^method return/) {
+ $serial=$_;
+ $serial=~s/.*reply_serial=//;
+ if ($serials{$serial}) {
+ delete($serials{$serial});
+ $active=1;
+ print $_;
+ }
+ } elsif (/^error /) {
+ $serial=$_;
+ $serial=~s/.*reply_serial=//;
+ if ($serials{$serial}) {
+ delete($serials{$serial});
+ $active=1;
+ print $_;
+ }
+ } elsif (/^signal.*;\ interface=org\.genivi\.positioning/) {
+ $active=1;
+ print $_;
+ } elsif (/^ +/) {
+ if ($active) {
+ print $_;
+ }
+ } else {
+ $active=0;
+ }
+}
+close(MON);
diff --git a/enhanced-position-service/test/test-scripts/test-enhanced-position-service-tk-gui.py b/enhanced-position-service/test/test-scripts/test-enhanced-position-service-tk-gui.py new file mode 100644 index 0000000..2265e18 --- /dev/null +++ b/enhanced-position-service/test/test-scripts/test-enhanced-position-service-tk-gui.py @@ -0,0 +1,175 @@ +#!/usr/bin/python + +""" +************************************************************************** +* @licence app begin@ +* SPDX-License-Identifier: MPL-2.0 +* +* \copyright Copyright (C) 2014, XS Embedded GmbH +* +* \file test-enhanced-position-service.py +* +* \brief This simple test shows how the enhanced-position-service +* can be tested using a python script with a TK based GUI +* which reacts on DBus Signals +* It is based on test-enhanced-position-service.py from Marco Residori +* and the multithreaded Tk approach described in +* http://bytes.com/topic/python/answers/448559-oddities-tkinter +* +* \author Helmut Schmidt <Helmut.3.Schmidt@continental-corporation.com> +* +* \version 1.0 +* +* This Source Code Form is subject to the terms of the +* Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with +# this file, You can obtain one at http://mozilla.org/MPL/2.0/. +* List of changes: +* <date>, <name>, <description of change> +* +* @licence end@ +************************************************************************** +""" + +""" +************************************************************************** +* +* Current restrictions +* Stopping the GUI does not always work as expected +* - when the Exit button is clicked, it sometimes hangs for a while +* - it's not possible to stop the GUI by closing the window +* +* Alternative implementation +* - Poll on the queue instead of waiting for event +* as described in http://effbot.org/zone/tkinter-threads.htm +* But apparently this does not improve the issue conerning stopping +* +************************************************************************** +""" + +#for dbus access +import dbus +import gobject +import dbus.mainloop.glib + +#for the TK based GUI (dbus mainloop runs in background thread) +import threading +import Queue +from Tkinter import * + +#constants as defined in the Positioning API +LATITUDE = 0x0020 +LONGITUDE = 0x0021 +ALTITUDE = 0x0022 +CLIMB = 0x0032 +SPEED = 0x0031 +HEADING = 0x0030 + +if __name__ == '__main__': +#According http://dbus.freedesktop.org/doc/dbus-python/doc/tutorial.html#setting-up-an-event-loop +# the main loop must be setup before connecting to the bus. +#Probably this line could be moved further down + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) + + +#The following functions depend on global variables which are defined later +#That's ugly, but it works in python +#Probably we can avoid this with using classes in a redesign + +#DBus signal receiver +#Sends a custom event to the Tk main loop and puts the data in a queue +def catchall_positioning_signals_handler(changedValues): + #print ('PositionUpdate') + #print changedValues + ## Each time the signal is catched, put the parameter in the queue... + commQueue.put(changedValues) + ## ... and generate a custom event on the main window + try: + tk_root.event_generate('<<SignalPositionUpdate>>', when='tail') + ## If it failed, the window has been destoyed: over + except: + print ("Cannot send Tk Event, terminating ...."); + stopEvent.set() + +# Receive the custom event in the GUI thread: +# Retrieve changed data over dbus and display them +def signalPositionUpdate(event): + #print("signalPositionUpdate Event received by GUI thread") + changedValues = commQueue.get() + #print changedValues + position = enhanced_position_interface.GetPosition(changedValues) + for val in changedValues: + if val == LATITUDE: + labelLat.config(text='LATITUDE:' + str(position[dbus.UInt16(val)])) + if val == LONGITUDE: + labelLon.config(text='LONGITUDE:' + str(position[dbus.UInt16(val)])) + if val == ALTITUDE: + labelAlt.config(text='ALTITUDE:' + str(position[dbus.UInt16(val)])) + if val == CLIMB: + labelClimb.config(text='CLIMB:' + str(position[dbus.UInt16(val)])) + if val == SPEED: + labelSpeed.config(text='SPEED:' + str(position[dbus.UInt16(val)])) + if val == HEADING: + labelHeading.config(text='HEADING:' + str(position[dbus.UInt16(val)])) + #It's important to call update_idletasks() to update the GUI + tk_root.update_idletasks() + +#Tasks which have to be done periodically within the dbus thread +def dbus_timeout_periodic(): + #it seems that the dbus thread blocks the Tk GUI thread if we don't call update_idletasks() + tk_root.update_idletasks() + #Check whether the termination event is set and terminate dbus thread and Tk GUI + if stopEvent.is_set(): + print ('stopEvent.is_set()') + dbus_loop.quit() + tk_root.quit() # as well call root.destroy() ??? + else: + gobject.timeout_add(100, dbus_timeout_periodic) + +##############Here comes the real main()################# +print ('Enhanced Positioning Test GUI') +print ('== Always use the Exit button to terminate (closing the window may not work) ==') + +###Event and Queue for thread synchronization/communication +stopEvent = threading.Event() +commQueue = Queue.Queue() + +###Create Tk main window +tk_root = Tk() +tk_root.title("Enhanced Positioning Test GUI") +# Setup the GUI +labelLat = Label(tk_root, width=40, text='LATITUDE: UKNOWN') +labelLat.pack() +labelLon = Label(tk_root, width=40, text='LONGITUDE: UKNOWN') +labelLon.pack() +labelAlt = Label(tk_root, width=40, text='ALTITUDE: UKNOWN') +labelAlt.pack() +labelClimb = Label(tk_root, width=40, text='CLIMB: UKNOWN') +labelClimb .pack() +labelSpeed = Label(tk_root, width=40, text='SPEED: UKNOWN') +labelSpeed.pack() +labelHeading = Label(tk_root, width=40, text='HEADING: UKNOWN') +labelHeading.pack() +bExit = Button(tk_root, text="Exit", command=stopEvent.set) +bExit.pack() +#bind the event to the callback function +tk_root.bind('<<SignalPositionUpdate>>', signalPositionUpdate) + +### Setup the DBus +#connect to session bus +bus = dbus.SessionBus() +#some global variables for the dbus used inside the signal handler +enhanced_position = bus.get_object('org.genivi.positioning.EnhancedPosition','/org/genivi/positioning/EnhancedPosition') +enhanced_position_interface = dbus.Interface(enhanced_position, dbus_interface='org.genivi.positioning.EnhancedPosition') +#register the signal handler +bus.add_signal_receiver(catchall_positioning_signals_handler, \ + dbus_interface = "org.genivi.positioning.EnhancedPosition", \ + signal_name = "PositionUpdate") +#create the dbus loop (must be global so we can terminate it) +gobject.timeout_add(100, dbus_timeout_periodic) +dbus_loop = gobject.MainLoop() + + +###Finally: start the dbus thread and then the Tk main loop +dbus_thread=threading.Thread(target=dbus_loop.run) +dbus_thread.start() +tk_root.mainloop() diff --git a/enhanced-position-service/test/test-scripts/test-enhanced-position-service.py b/enhanced-position-service/test/test-scripts/test-enhanced-position-service.py new file mode 100755 index 0000000..9ae6f72 --- /dev/null +++ b/enhanced-position-service/test/test-scripts/test-enhanced-position-service.py @@ -0,0 +1,91 @@ +#!/usr/bin/python + +""" +************************************************************************** +* @licence app begin@ +* SPDX-License-Identifier: MPL-2.0 +* +* \copyright Copyright (C) 2014, XS Embedded GmbH +* +* \file test-enhanced-position-service.py +* +* \brief This simple test shows how the enhanced-position-service +* can be easily tested using a python script +* +* \author Marco Residori <marco.residori@xse.de> +* +* \version 1.0 +* +* This Source Code Form is subject to the terms of the +* Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with +# this file, You can obtain one at http://mozilla.org/MPL/2.0/. +* List of changes: +* <date>, <name>, <description of change> +* +* @licence end@ +************************************************************************** +""" + +import dbus +import gobject +import dbus.mainloop.glib + +#constants as defined in the Positioning API +LATITUDE = 0x0020 +LONGITUDE = 0x0021 +ALTITUDE = 0x0022 +CLIMB = 0x0032 +SPEED = 0x0031 +HEADING = 0x0030 + +print '\n--------------------------' +print 'Positioning Test' +print '--------------------------\n' + +if __name__ == '__main__': + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) + +#connect to session bus +bus = dbus.SessionBus() + +#signal receiver +def catchall_positioning_signals_handler(changedValues): + print 'PositonUpdate' + changedfields = dbus.Array(signature='q') + position = enhanced_position_interface.GetPosition(changedValues) + for val in changedValues: + if val == LATITUDE: + print 'LATITUDE:' + str(position[dbus.UInt16(val)]) + if val == LONGITUDE: + print 'LONGITUDE:' + str(position[dbus.UInt16(val)]) + if val == ALTITUDE: + print 'ALTITUDE:' + str(position[dbus.UInt16(val)]) + if val == CLIMB: + print 'CLIMB:' + str(position[dbus.UInt16(val)]) + if val == SPEED: + print 'SPEED:' + str(position[dbus.UInt16(val)]) + if val == HEADING: + print 'HEADING:' + str(position[dbus.UInt16(val)]) + +#add signal receiver +bus.add_signal_receiver(catchall_positioning_signals_handler, \ + dbus_interface = "org.genivi.positioning.EnhancedPosition", \ + signal_name = "PositionUpdate") + +#timeout +def timeout(): + print '\nTest Finished\n' + loop.quit() + +#get object +enhanced_position = bus.get_object('org.genivi.positioning.EnhancedPosition','/org/genivi/positioning/EnhancedPosition') + +#get interface +enhanced_position_interface = dbus.Interface(enhanced_position, dbus_interface='org.genivi.positioning.EnhancedPosition') + +#main loop +gobject.timeout_add(10000, timeout) +loop = gobject.MainLoop() +loop.run() + + diff --git a/positioning_1.0.bb b/positioning_1.0.bb index 6f53750..24192a7 100755 --- a/positioning_1.0.bb +++ b/positioning_1.0.bb @@ -35,7 +35,7 @@ LICENSE_${PN}-repl = "MPLv2" LICENSE_${PN}-enhpos = "MPLv2" SRC_URI = "git://git.projects.genivi.org/lbs/positioning.git;protocol=git" -SRCREV = "65cacfff17867aac958cdc1f1021864732fe277d" +SRCREV = "fbd1b0d48879146dc91a3959ced85d78db5d3098" LIC_FILES_CHKSUM = "file://LICENSE;md5=e73ca6874051c79a99d065bc57849af5" S = "${WORKDIR}/git" @@ -65,7 +65,7 @@ RDEPENDS_${PN}-enhpos-test = "${PN}-enhpos" DEPENDS_${PN}-enhpos-test = "${PN}-enhpos" do_configure() { - cd ${S}/gnss-service && cmake -DWITH_DLT=ON -DWITH_GPSD=OFF -DWITH_REPLAYER=ON -DWITH_TESTS=ON . + cd ${S}/gnss-service && cmake -DWITH_DLT=OFF -DWITH_GPSD=OFF -DWITH_REPLAYER=ON -DWITH_TESTS=ON . cd ${S}/sensors-service && cmake -DWITH_DLT=OFF -DWITH_REPLAYER=ON -DWITH_IPHONE=OFF -DWITH_TESTS=ON . cd ${S}/log-replayer && cmake -DWITH_DLT=OFF -DWITH_TESTS=ON . cd ${S}/enhanced-position-service && cmake -DWITH_DLT=OFF -DWITH_GPSD=OFF -DWITH_REPLAYER=ON -DWITH_IPHONE=OFF -DWITH_TESTS=ON . diff --git a/run-test.sh b/run-test.sh index 8a63e21..fd05d6b 100755 --- a/run-test.sh +++ b/run-test.sh @@ -34,10 +34,10 @@ testGnssService() { build/gnss-service/test/gnss-service-client & sleep 3 - echo 'starting log replayer...' + echo 'Starting log replayer...' build/log-replayer/src/log-replayer log-replayer/logs/20100411_Geko_Regensburg_short.log > /dev/null 2>&1 & sleep 10 - echo 'stopping test...' + echo 'Stopping test...' killall log-replayer killall gnss-service-client } @@ -46,10 +46,10 @@ testSensorsService() { build/sensors-service/test/sensors-service-client & sleep 3 - echo 'starting log replayer...' + echo 'Starting log replayer...' build/log-replayer/src/log-replayer log-replayer/logs/20100411_Geko_Regensburg_short.log > /dev/null 2>&1 & sleep 10 - echo 'stopping test...' + echo 'Stopping test...' killall log-replayer killall sensors-service-client } @@ -60,25 +60,37 @@ testEnhancedPositionService() sleep 3 build/enhanced-position-service/test/enhanced-position-client & sleep 3 - echo 'starting log replayer...' + echo 'Starting log replayer...' build/log-replayer/src/log-replayer log-replayer/logs/geneve-cologny.log > /dev/null 2>&1 & sleep 20 - echo 'stopping test...' + echo 'Stopping test...' killall enhanced-position-client killall enhanced-position-service killall log-replayer } +testEnhancedPositionService2() +{ + echo 'Starting enhanced position service...' + build/log-replayer/src/log-replayer log-replayer/logs/geneve-cologny.log > /dev/null 2>&1 & + echo 'Starting log replayer...' + build/enhanced-position-service/src/enhanced-position-service > /dev/null 2>&1 & + sleep 300 + echo 'Stopping test...' + killall enhanced-position-service + killall log-replayer +} + testLogReplayer() { - echo 'starting log replayer...' + echo 'Starting log replayer...' build/log-replayer/src/log-replayer log-replayer/logs/geneve-cologny.log > /dev/null 2>&1 & #build/log-replayer/src/log-replayer log-replayer/logs/20100411_Geko_Regensburg_short.log > /dev/null 2>&1 & sleep 1 - echo 'starting test application...' + echo 'Starting test application...' build/log-replayer/test/test-log-replayer 9930 & sleep 10 - echo 'stopping test...' + echo 'Stopping test...' killall log-replayer killall test-log-replayer } @@ -102,6 +114,8 @@ if [ $# -eq 1 ]; then testSensorsService elif [ $1 = enhpos ]; then testEnhancedPositionService + elif [ $1 = enhpos2 ]; then + testEnhancedPositionService2 elif [ $1 = repl ]; then testLogReplayer elif [ $1 = kill ]; then |