summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevron Rees <tripzero.kev@gmail.com>2013-10-07 19:20:49 -0700
committerKevron Rees <tripzero.kev@gmail.com>2013-10-07 19:20:49 -0700
commite01c58448e0b88f44558eccdca2ebccebfd27c58 (patch)
tree2e97ae0211f27b92f7bf1c78a53c1fb1f9b1d4c7
parent857e6ab73130278417b5d6f6db67c19f093db575 (diff)
parent0496d87a640a11b2e02a24fb68d607dc9d9cc04a (diff)
downloadautomotive-message-broker-e01c58448e0b88f44558eccdca2ebccebfd27c58.tar.gz
Merge branch 'master' of https://github.com/otcshare/automotive-message-broker
-rw-r--r--CMakeLists.txt7
-rw-r--r--TODO6
-rw-r--r--ambd/CMakeLists.txt1
-rw-r--r--ambd/core.cpp2
-rw-r--r--ambd/main.cpp32
-rw-r--r--docs/README14
-rw-r--r--lib/abstractpropertytype.h2
-rw-r--r--lib/debugout.cpp2
-rw-r--r--lib/debugout.h22
-rwxr-xr-xpackaging.in/ambd.conf.upstart (renamed from ambd.conf.upstart)0
-rw-r--r--packaging.in/ambd.service.systemd (renamed from ambd/ambd.service)0
-rw-r--r--packaging.in/config.tizen22
-rw-r--r--plugins/dbus/automotivemanager.cpp2
-rw-r--r--plugins/dbus/varianttype.cpp7
-rw-r--r--plugins/exampleplugin.cpp38
-rw-r--r--plugins/wheel/wheelplugin.cpp4
16 files changed, 119 insertions, 42 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 12c84c2e..2804b65b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,12 +6,14 @@ set(CMAKE_BUILD_TYPE, Debug)
include(FindPkgConfig)
set(PROJECT_NAME "automotive-message-broker")
-set(PROJECT_VERSION "0.10.999")
+set(PROJECT_VERSION "0.10.800")
set(PROJECT_CODENAME "challenger")
+set(PROJECT_QUALITY "alpha")
add_definitions(-DPROJECT_VERSION="${PROJECT_VERSION}")
add_definitions(-DPROJECT_NAME="${PROJECT_NAME}")
add_definitions(-DPROJECT_CODENAME="${PROJECT_CODENAME}")
+add_definitions(-DPROJECT_QUALITY="${PROJECT_QUALITY}")
set (LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" )
set (LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/${CMAKE_LIBRARY_ARCHITECTURE}" CACHE STRING "Directory where lib will install")
@@ -67,7 +69,7 @@ pkg_check_modules(glib REQUIRED glib-2.0 gobject-2.0)
pkg_check_modules(json REQUIRED json)
-add_definitions(-std=c++0x)
+add_definitions(-std=c++11)
add_definitions(-DDBusServiceName="org.automotive.message.broker")
set(include_dirs ${libtool_INCLUDE_DIR} ${glib_INCLUDE_DIRS} ${gio_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${json_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/lib)
@@ -83,7 +85,6 @@ if(qtmainloop)
set(QT_LIBRARIES ${Qt5Core_LIBRARIES})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")
if(CMAKE_SIZEOF_VOID_P MATCHES "8")
- message(STATUS "can has 64bits")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcmodel=large")
endif(CMAKE_SIZEOF_VOID_P MATCHES "8")
add_definitions(${Qt5Core_DEFINITIONS})
diff --git a/TODO b/TODO
index 3aae18ce..38cd7221 100644
--- a/TODO
+++ b/TODO
@@ -4,7 +4,7 @@ For 0.11
- Implement all the DBus properties in the docs/ directory.
- update json protocol to include getPropertyInfo calls
-- update json protocol to support rangerequests with PropertyList instead of a signel property
+- update json protocol to support rangerequests with PropertyList instead of a signel property (Verify)
- update database to support zone column
- general support for source and zone filtering in database plugin
- no reason for pluginloader to track sources. core already does it.
@@ -20,9 +20,11 @@ Completed:
- add API to get number of sources per a given property (ie uint AbstractRoutingEngine::getSourcesForProperty(VehicleProperty::Property)) - DONE
- per-source property filtering in routing engine - DONE
+
Other:
- grep all the TODOs in the code and do them
- improve obd2source speed via Physical Addressing (see https://www.scantool.net/forum/index.php?topic=6661.msg25024#msg25024)
- investigate and enable use of provisioning in ssl websockets
- enable ambd/plugins.d/
-- finish implementing openxc plugin
+- finish implementing openxc plugin (needs testing)
+- Document internal source/sink plugin API
diff --git a/ambd/CMakeLists.txt b/ambd/CMakeLists.txt
index 6ea67e4c..9ce7c18b 100644
--- a/ambd/CMakeLists.txt
+++ b/ambd/CMakeLists.txt
@@ -19,5 +19,4 @@ target_link_libraries(ambd ${link_libraries} amb)
install (TARGETS ambd RUNTIME DESTINATION bin)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/config DESTINATION /etc/ambd)
-install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/ambd.service DESTINATION /usr/lib/systemd/system)
diff --git a/ambd/core.cpp b/ambd/core.cpp
index 70d9daa0..13d02421 100644
--- a/ambd/core.cpp
+++ b/ambd/core.cpp
@@ -185,7 +185,7 @@ void Core::updateProperty(AbstractPropertyType *value, const string &uuid)
value->sourceUuid = uuid;
}
- sink->propertyChanged(property, value, uuid);
+ sink->propertyChanged(value, uuid);
}
}
}
diff --git a/ambd/main.cpp b/ambd/main.cpp
index c768ea42..abfd124f 100644
--- a/ambd/main.cpp
+++ b/ambd/main.cpp
@@ -64,7 +64,7 @@ void daemonize();
void printhelp(const char *argv0);
-static const char shortopts[] = "hvDc:d:l:";
+static const char shortopts[] = "hvDc:d:l:we";
static const struct option longopts[] = {
{ "help", no_argument, NULL, 'h' }, ///< Print the help text
@@ -73,13 +73,15 @@ static const struct option longopts[] = {
{ "config", required_argument, NULL, 'c' },
{ "debug", required_argument, NULL, 'd' },
{ "log", required_argument, NULL, 'l' },
+ { "warn", no_argument, NULL, 'w' },
+ { "err", no_argument, NULL, 'e' },
{ NULL, 0, NULL, 0 } ///< End
};
void printVersion()
{
DebugOut(0)<<PROJECT_NAME<<endl;
- DebugOut(0)<<"Version: "<<PROJECT_VERSION<<" ("<<PROJECT_CODENAME<<")"<<endl;
+ DebugOut(0)<<"Version: "<<PROJECT_VERSION<<" ( "<<PROJECT_CODENAME<<" "<<PROJECT_QUALITY<<" )"<<endl;
}
int main(int argc, char **argv)
@@ -115,6 +117,12 @@ int main(int argc, char **argv)
case 'l':
logfn = optarg;
break;
+ case 'w':
+ DebugOut::setThrowWarn(true);
+ break;
+ case 'e':
+ DebugOut::setThrowErr(true);
+ break;
default:
DebugOut(0)<<"Unknown option "<<optc<<endl;
printhelp(argv[0]);
@@ -132,6 +140,11 @@ int main(int argc, char **argv)
DebugOut::setOutput(logfile);
}
+ if(getuid() == 0)
+ {
+ DebugOut(DebugOut::Error)<<"Running as root. This is dangerous."<<endl;
+ }
+
VehicleProperty::factory();
Core routingEngine;
@@ -189,12 +202,15 @@ void daemonize()
void printhelp(const char *argv0)
{
printf("Usage: %s [args]\n"
- " [-D|--daemonise]\n"
- " [-v|--version]\n"
- " [-c|--config </path/to/config> \t]\n"
- " [-d|--debug <level (0-5)>\t]\n"
- " [-l]--log </path/to/logfile>\t]\n"
- " [-h|--help]\n"
+ " [-D|--daemonise] run ambd in daemon mode\n"
+ " [-v|--version] spit out the version then exit\n"
+ " [-c|--config </path/to/config> ] specify which config to use\n"
+ " [-d|--debug <level (0-5)> ] set the debug level\n"
+ " [-l]--log </path/to/logfile> ] specify an debug output log file\n"
+ " [-w]--warn] throw on warnings\n"
+ " [-e]--err] throw on errors\n"
+ " [-h|--help] print this menu and exit\n"
, argv0);
}
+
diff --git a/docs/README b/docs/README
index 25cffddb..c5d33d30 100644
--- a/docs/README
+++ b/docs/README
@@ -1,9 +1,9 @@
Automotive Message Broker DBus API Documentation
-AMB organizes the API into two general interfaces. First a Manager interface which includes
-tools for using the other interfaces. Second is a series of interfaces that represent vehicle
-data. The later follows the schema of "org.automotive.DataType" and are contained in verious
-DBus paths.
+AMB organizes the API into two general interfaces. First a Manager interface (see manager.txt)
+which includes tools for using the other interfaces. Second is a series of interfaces that
+represent vehicle data. The later follows the schema of "org.automotive.DataType" and are
+contained in verious DBus paths.
The data types are documented in the various *.txt files in this document folder. The manager
interface is documented in the manager.txt document.
@@ -11,16 +11,16 @@ interface is documented in the manager.txt document.
Basic Recommended Usage
It is recomended that the Manager interface be used to find the DBus Object that contains the
-data type you need. This is done through the findObject() call. It is expected that DBus
+data type you need. This is done through the FindObject() call. It is expected that DBus
Object Paths may change and so it is not appropriate to hard code DBus Object Paths. The
DBus paths in the various documents are examples of paths and are not gauranteed.
Here is a pseudo-code example of how the api is to be used:
-ObjectPath vehicleSpeed = manager.findObject("VehicleSpeed");
+Array<ObjectPath> vehicleSpeedObjects = manager.FindObject("VehicleSpeed");
/// interact with the 'VehicleSpeed' property on the vehicleSpeed object
-log(vehicleSpeed.VehicleSpeed);
+log(vehicleSpeedObjects[0].VehicleSpeed);
diff --git a/lib/abstractpropertytype.h b/lib/abstractpropertytype.h
index c5c10955..10c0498b 100644
--- a/lib/abstractpropertytype.h
+++ b/lib/abstractpropertytype.h
@@ -51,7 +51,7 @@ const Zone::Type FrontLeft = Zone::Type(Front | Left);
const Zone::Type MiddleRight = Zone::Type(Middle | Right);
const Zone::Type MiddleLeft = Zone::Type(Middle | Left);
const Zone::Type RearRight = Zone::Type(Rear | Right);
-const Zone::Type RearLeft = Zone::Type(Rear| Left);
+const Zone::Type RearLeft = Zone::Type(Rear | Left);
typedef std::list<Zone::Type> ZoneList;
diff --git a/lib/debugout.cpp b/lib/debugout.cpp
index ee7fa8b7..c33d4d08 100644
--- a/lib/debugout.cpp
+++ b/lib/debugout.cpp
@@ -22,6 +22,8 @@ using namespace std;
int DebugOut::debugThreshhold = 0;
std::streambuf * DebugOut::buf = cout.rdbuf();
+bool DebugOut::throwErr = false;
+bool DebugOut::throwWarn = false;
const int DebugOut::Error = 1 << 16;
const int DebugOut::Warning = 1 << 24;
diff --git a/lib/debugout.h b/lib/debugout.h
index ce6f038a..aa57725a 100644
--- a/lib/debugout.h
+++ b/lib/debugout.h
@@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include <iostream>
#include <fstream>
#include <sstream>
+#include <stdexcept>
#include "timestamp.h"
using namespace std;
@@ -72,6 +73,15 @@ public:
ostream out(buf);
out.precision(15);
out<<endl;
+
+ if((mDebugLevel == Error && throwErr))
+ {
+ throw std::runtime_error("Abort on Error is set");
+ }
+ else if ((mDebugLevel == Warning && throwWarn))
+ {
+ throw std::runtime_error("Abort on Warning is set");
+ }
}
return *this;
}
@@ -97,6 +107,16 @@ public:
buf = o.rdbuf();
}
+ static void setThrowWarn(bool v)
+ {
+ throwWarn = v;
+ }
+
+ static void setThrowErr(bool v)
+ {
+ throwErr = v;
+ }
+
private:
std::string bufferTime(double time)
@@ -117,6 +137,8 @@ private:
static int debugThreshhold;
static std::streambuf *buf;
+ static bool throwWarn;
+ static bool throwErr;
int mDebugLevel;
};
diff --git a/ambd.conf.upstart b/packaging.in/ambd.conf.upstart
index ebec0056..ebec0056 100755
--- a/ambd.conf.upstart
+++ b/packaging.in/ambd.conf.upstart
diff --git a/ambd/ambd.service b/packaging.in/ambd.service.systemd
index 679ba941..679ba941 100644
--- a/ambd/ambd.service
+++ b/packaging.in/ambd.service.systemd
diff --git a/packaging.in/config.tizen b/packaging.in/config.tizen
new file mode 100644
index 00000000..664195aa
--- /dev/null
+++ b/packaging.in/config.tizen
@@ -0,0 +1,22 @@
+{
+ "sources" : [
+ {
+ "name" : "Murphy Source",
+ "path" : "/usr/lib/automotive-message-broker/murphysourceplugin.so",
+ "address" : "unxs:/tmp/murphy/amb"
+ },
+ {
+ "name" : "VehicleSource",
+ "path" : "/usr/lib/automotive-message-broker/vehicleplugin.so",
+ "configfile" : "/etc/ambd/AMBformat.conf"
+ }
+
+ ],
+ "sinks": [
+ {
+ "name" : "DBusSink",
+ "path" : "/usr/lib/automotive-message-broker/dbussinkplugin.so"
+ }
+ ]
+}
+
diff --git a/plugins/dbus/automotivemanager.cpp b/plugins/dbus/automotivemanager.cpp
index 778a4b4b..972f08f6 100644
--- a/plugins/dbus/automotivemanager.cpp
+++ b/plugins/dbus/automotivemanager.cpp
@@ -43,6 +43,8 @@ static void handleMethodCall(GDBusConnection *connection,
if(method == "findProperty")
{
+ DebugOut(DebugOut::Warning)<<"org.automotive.Manager.findProperty() is deprecated. Use org.automotive.Manager.FindObject() instead."<<endl;
+
gchar* arg;
g_variant_get(parameters,"(s)",&arg);
diff --git a/plugins/dbus/varianttype.cpp b/plugins/dbus/varianttype.cpp
index 49fb1d66..0f6fecb0 100644
--- a/plugins/dbus/varianttype.cpp
+++ b/plugins/dbus/varianttype.cpp
@@ -1,6 +1,7 @@
#include "varianttype.h"
#include "abstractroutingengine.h"
#include "debugout.h"
+#include "listplusplus.h"
VariantType::VariantType(AbstractRoutingEngine* re, std::string signature, VehicleProperty::Property ambPropertyName, std::string propertyName, Access access, AbstractDBusInterface *interface)
:AbstractProperty(propertyName, signature, access, interface), mInitialized(false)
@@ -32,7 +33,11 @@ void VariantType::initialize()
delete reply;
};
- routingEngine->getPropertyAsync(request);
+ /// do not request if not supported:
+ PropertyList proplist = routingEngine->supported();
+
+ if(contains(proplist,mAmbPropertyName))
+ routingEngine->getPropertyAsync(request);
}
GVariant *VariantType::toGVariant()
diff --git a/plugins/exampleplugin.cpp b/plugins/exampleplugin.cpp
index a0074b76..49f332df 100644
--- a/plugins/exampleplugin.cpp
+++ b/plugins/exampleplugin.cpp
@@ -209,6 +209,20 @@ void ExampleSourcePlugin::getPropertyAsync(AsyncPropertyReply *reply)
reply->success = true;
reply->completed(reply);
}
+ else if(reply->property == VehicleProperty::ThrottlePosition)
+ {
+ VehicleProperty::ThrottlePositionType temp(throttlePos);
+ reply->value = &temp;
+ reply->success = true;
+ reply->completed(reply);
+ }
+ else if(reply->property == VehicleProperty::EngineCoolantTemperature)
+ {
+ VehicleProperty::EngineCoolantTemperatureType temp(engineCoolant);
+ reply->value = &temp;
+ reply->success = true;
+ reply->completed(reply);
+ }
else
{
reply->success=false;
@@ -271,22 +285,14 @@ void ExampleSourcePlugin::randomizeProperties()
machineGun = !machineGun;
- vel.timestamp = amb::currentTime();
- es.timestamp = amb::currentTime();
- ac.timestamp = amb::currentTime();
- swa.timestamp = amb::currentTime();
- tsp.timestamp = amb::currentTime();
- tp.timestamp = amb::currentTime();
- ec.timestamp = amb::currentTime();
-
- routingEngine->updateProperty(VehicleProperty::VehicleSpeed, &vel, uuid());
- routingEngine->updateProperty(VehicleProperty::EngineSpeed, &es, uuid());
- routingEngine->updateProperty(VehicleProperty::AccelerationX, &ac, uuid());
- routingEngine->updateProperty(VehicleProperty::SteeringWheelAngle, &swa, uuid());
- routingEngine->updateProperty(VehicleProperty::TransmissionShiftPosition,&tsp, uuid());
- routingEngine->updateProperty(VehicleProperty::ThrottlePosition, &tp, uuid());
- routingEngine->updateProperty(VehicleProperty::EngineCoolantTemperature, &ec, uuid());
- //routingEngine->updateProperty(VehicleProperty::MachineGunTurretStatus, &mgt);
+ routingEngine->updateProperty(&vel, uuid());
+ routingEngine->updateProperty(&es, uuid());
+ routingEngine->updateProperty(&ac, uuid());
+ routingEngine->updateProperty(&swa, uuid());
+ routingEngine->updateProperty(&tsp, uuid());
+ routingEngine->updateProperty(&tp, uuid());
+ routingEngine->updateProperty(&ec, uuid());
+
}
void ExampleSourcePlugin::addPropertySupport(VehicleProperty::Property property, Zone::Type zone)
diff --git a/plugins/wheel/wheelplugin.cpp b/plugins/wheel/wheelplugin.cpp
index 697b1f08..4e783a6a 100644
--- a/plugins/wheel/wheelplugin.cpp
+++ b/plugins/wheel/wheelplugin.cpp
@@ -335,14 +335,14 @@ void WheelPrivate::newButtonValue(char number, bool val)
checkButtonEvents();
break;
case 4: //Right paddle shifter
- if(this->currentGear < MAX_GEARS)
+ if(val && this->currentGear < MAX_GEARS)
{
this->changeGear(Transmission::TransmissionPositions(this->currentGear+1));
changeMachineGuns(val);
}
break;
case 5: //Left paddle shifter
- if(this->currentGear > 0)
+ if(val && this->currentGear > 0)
this->changeGear(Transmission::TransmissionPositions(this->currentGear-1));
break;
case 6: //Right upper wheel button