option(opencvlux_plugin "OpenCV Lux plugin" OFF)
option(gpsd_plugin "gpsd location plugin" OFF)
option(murphy_plugin "murphy policy framework plugin" OFF)
+option(test_plugin "Test Plugin" ON)
if(opencvlux_plugin)
message(STATUS "OpenCV Lux plugin enabled")
--- /dev/null
+{
+ "sources" : [
+ {
+ "name" : "TestPlugin",
+ "path" : "/usr/lib/automotive-message-broker/testplugin.so"
+ }
+ ],
+ "sinks": [
+ {
+ "name" : "ExampleSink",
+ "path" : "/usr/lib/automotive-message-broker/examplesinkplugin.so"
+ }
+ ]
+}
+
#include <glib.h>
#include <list>
#include "timestamp.h"
-
+#include <debugout.h>
namespace Zone {
enum Type {
None = 0,
{
GVariantBuilder params;
- g_variant_builder_init(¶ms, G_VARIANT_TYPE_ARRAY);
+ g_variant_builder_init(¶ms, ((const GVariantType *) "av"));
for(auto itr = mList.begin(); itr != mList.end(); itr++)
{
AbstractPropertyType* t = *itr;
- g_variant_builder_add_value(¶ms, t->toVariant());
+ GVariant *var = t->toVariant();
+ GVariant *newvar = g_variant_new("v",var);
+ DebugOut() << "Ceated toVariant var" << endl;
+ g_variant_builder_add_value(¶ms, newvar);
+
}
GVariant* var = g_variant_builder_end(¶ms);
void fromVariant(GVariant* v)
{
/// TODO: fill this in
+ gsize dictsize = g_variant_n_children(v);
+ for (int i=0;i<dictsize;i++)
+ {
+ GVariant *childvariant = g_variant_get_child_value(v,i);
+ DebugOut() << "Got outer child" << endl;
+ GVariant *innervariant = g_variant_get_variant(childvariant);
+ DebugOut() << "Got inner child" << endl;
+ T *t = new T();
+ t->fromVariant(innervariant);
+ DebugOut() << "Parsed child" << endl;
+ appendPriv(t);
+ }
}
std::list<AbstractPropertyType*> list() { return mList; }
{
GVariantBuilder params;
g_variant_builder_init(¶ms, G_VARIANT_TYPE_DICTIONARY);
-
for(auto itr = mMap.begin(); itr != mMap.end(); itr++)
{
auto &foo = (*itr).first;
g_variant_builder_add(¶ms,"{?*}",const_cast<T&>(foo).toVariant(),(*itr).second.toVariant());
-
}
GVariant* var = g_variant_builder_end(¶ms);
add_subdirectory(opencvlux)
add_subdirectory(gpsd)
add_subdirectory(murphyplugin)
+add_subdirectory(testplugin)
--- /dev/null
+#if(test_plugin)
+
+include(CheckIncludeFiles)
+
+
+pkg_check_modules(gio REQUIRED gio-2.0)
+pkg_check_modules(gio-unix REQUIRED gio-unix-2.0)
+#pkg_check_modules(glibmm REQUIRED glibmm-2.4)
+
+include_directories(${CMAKE_SOURCE_DIR}/lib ${include_dirs} ${gio_INCLUDE_DIRS} ${gio-unix_INCLUDE_DIRS} )
+
+set(testplugin_headers testplugin.h)
+set(testplugin_sources testplugin.cpp)
+add_library(testplugin MODULE ${testplugin_sources})
+set_target_properties(testplugin PROPERTIES PREFIX "")
+target_link_libraries(testplugin amb -L${CMAKE_CURRENT_BINARY_DIR}/lib ${link_libraries} ${gio_LIBRARIES} ${gio-unix_LIBRARIES} )
+
+install(TARGETS testplugin LIBRARY DESTINATION lib${LIB_SUFFIX}/automotive-message-broker)
+
+#endif(test_plugin)
--- /dev/null
+OBD-II Source Plugin
+
+The OBD-II Source plugin uses ELM compatible scantools to get vehicle information.
+It is known to work with a number of commercial scantools including:
+
+OBDLink MX
+OBDLink S
+OBDPro USB
+
+To use the OBD-II Source plugin, add the following config to your /etc/ambd/config:
+
+
+"sources" : [
+ {
+ "name" : "OBD2Source",
+ "path" : "/usr/lib/automotive-message-broker/obd2sourceplugin.so",
+ "device" : "/dev/ttyUSB0",
+ "baud" : "9600",
+ "bluetoothAdapter" : ""
+ }
+ ]
+
+Configuration Key Definitions:
+
+"name"
+name of plugin. This key is not used by the plugin at this moment.
+
+"path"
+path to plugin on the filesystem.
+
+"device"
+OBD-II Scantool device. This is usually a serial device. For bluetooth devices, use the bluetooth address for example:
+"00:00:11:aa:bb:cc".
+
+"baud"
+baud rate for OBD-II scantool. OBDLink *-style scantool usually default to 115200. Refer to your scantool
+docutmentation for the correct baud rate. Note also that some bluetooth scantools, like the OBDLink MX have automatic baud selection and will ignore this value.
+
+"bluetoothAdapter"
+Hardware address of the bluetooth adapter to use. If value is blank (ie "bluetoothAdapter" : ""), the system default
+adapter will be used. The bluetoothAdapter key is only used if the "device" key is also set to a bluetooth device address.
+
+
+Performance
+
+Performance will vary with the scantool and the vehicle. Here are the current performance numbers per tested scantool
+using the ECUSim2000 from scantool.net:
+
+scantool - properties/second = (pids/s) - baud
+
+OBDLink MX - 120 pids/s - N/A (varies with bluetooth radio)
+OBDLink S - 100 pids/s - 115200
+OBDPro USB - 43 pids/s - 9600
+
+
+
--- /dev/null
+/*
+ Copyright (C) 2012 Intel Corporation
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+
+#include <iostream>
+#include <boost/assert.hpp>
+#include <boost/lexical_cast.hpp>
+#include <glib.h>
+#include <sstream>
+//#include <json-glib/json-glib.h>
+#include <listplusplus.h>
+#include "debugout.h"
+#include "timestamp.h"
+#include "testplugin.h"
+#define __SMALLFILE__ std::string(__FILE__).substr(std::string(__FILE__).rfind("/")+1)
+AbstractRoutingEngine *m_re;
+
+//std::list<ObdPid*> Obd2Amb::supportedPidsList;
+
+bool beginsWith(std::string a, std::string b)
+{
+ return (a.compare(0, b.length(), b) == 0);
+}
+void TestPlugin::updateProperty(VehicleProperty::Property property,AbstractPropertyType* value)
+{
+
+}
+
+void TestPlugin::setSupported(PropertyList list)
+{
+ m_re->updateSupported(list,PropertyList());
+}
+void TestPlugin::setConfiguration(map<string, string> config)
+{
+// //Config has been passed, let's start stuff up.
+}
+
+TestPlugin::TestPlugin(AbstractRoutingEngine *re, map<string, string> config)
+ : AbstractSource(re, config)
+{
+ DebugOut() << "Testing MapPropertyType" << endl;
+ MapPropertyType<BasicPropertyType<Door::Location>,BasicPropertyType<Door::Status>> propmap("something");
+ MapPropertyType<BasicPropertyType<Door::Location>,BasicPropertyType<Door::Status>> propmaptwo("something");
+ propmap.append(Door::LeftRear,Door::Ajar);
+ GVariant *var = propmap.toVariant();
+ gsize dictsize = g_variant_n_children(var);
+ //DebugOut() << var << endl;
+ propmaptwo.fromVariant(var);
+ DebugOut() << propmap.toString() << propmaptwo.toString() << endl;
+ if (propmap.toString() == propmap.toString())
+ {
+ DebugOut() << "Success!" << endl;
+ }
+ else
+ {
+ DebugOut() << "Failure" << endl;
+ exit(-1);
+ }
+ /*
+ DebugOut() << "Testing ListPropertyType" << endl;
+ ListPropertyType<BasicPropertyType<uint16_t> > listpropmap("something");
+ ListPropertyType<BasicPropertyType<uint16_t> > listpropmaptwo("something");
+ //listpropmap.append(new VehicleProperty::AccelerationXType());
+ //listpropmap.append(new VehicleProperty::MachineGunTurretStatusType());
+ listpropmap.append(new AbstractPropertyType<VehicleProperty::TripMeters>());
+ GVariant *newvar = listpropmap.toVariant();
+ DebugOut() << "Newvar created" << endl;
+ listpropmaptwo.fromVariant(newvar);
+ DebugOut() << listpropmap.toString() << listpropmaptwo.toString() << endl;
+ if (listpropmap.toString() == listpropmaptwo.toString())
+ {
+ DebugOut() << "Success!" << endl;
+ }
+ else
+ {
+ DebugOut() << "Failure" << endl;
+ exit(-1);
+ }*/
+
+ DebugOut() << "Exiting..." << endl;
+ exit(-1);
+}
+TestPlugin::~TestPlugin()
+{
+ DebugOut() << "TestPlugin Destructor called!!!"<<endl;
+}
+
+PropertyList TestPlugin::supported()
+{
+ return PropertyList();
+}
+
+int TestPlugin::supportedOperations()
+{
+ return Get | Set;
+}
+
+extern "C" AbstractSource * create(AbstractRoutingEngine* routingengine, map<string, string> config)
+{
+ return new TestPlugin(routingengine, config);
+
+}
+string TestPlugin::uuid()
+{
+ return "f77af740-f1f8-11e1-aff1-0800200c9a66";
+}
+void TestPlugin::subscribeToPropertyChanges(VehicleProperty::Property property)
+{
+}
+
+
+void TestPlugin::unsubscribeToPropertyChanges(VehicleProperty::Property property)
+{
+}
+
+
+void TestPlugin::getPropertyAsync(AsyncPropertyReply *reply)
+{
+
+}
+
+AsyncPropertyReply *TestPlugin::setProperty(AsyncSetPropertyRequest request )
+{
+ AsyncPropertyReply* reply = new AsyncPropertyReply (request);
+ return reply;
+}
--- /dev/null
+
+/*
+Copyright (C) 2012 Intel Corporation
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+
+#ifndef OBD2SOURCE_H
+#define OBD2SOURCE_H
+
+
+
+#include <abstractsource.h>
+#include <string>
+#include <sstream>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <termios.h>
+#include <glib.h>
+
+
+
+
+class TestPlugin : public AbstractSource
+{
+
+public:
+ TestPlugin(AbstractRoutingEngine* re, map<string, string> config);
+ ~TestPlugin();
+ string uuid();
+ int portHandle;
+ void getPropertyAsync(AsyncPropertyReply *reply);
+ void getRangePropertyAsync(AsyncRangePropertyReply *reply){}
+ AsyncPropertyReply * setProperty(AsyncSetPropertyRequest request);
+ void subscribeToPropertyChanges(VehicleProperty::Property property);
+ void unsubscribeToPropertyChanges(VehicleProperty::Property property);
+ PropertyList supported();
+
+ int supportedOperations();
+
+ void setSupported(PropertyList list);
+ void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, string uuid) {}
+ void supportedChanged(PropertyList) {}
+ void setConfiguration(map<string, string> config);
+ //void randomizeProperties();
+ void updateProperty(VehicleProperty::Property property,AbstractPropertyType *value);
+
+private:
+ PropertyList m_supportedProperties;
+};
+
+#endif // OBD2SOURCE_H