[ambd] - print out useful error if config can't open
authorKevron Rees <kevron.m.rees@intel.com>
Mon, 19 Jan 2015 19:08:00 +0000 (11:08 -0800)
committerKevron Rees <kevron.m.rees@intel.com>
Mon, 19 Jan 2015 19:08:00 +0000 (11:08 -0800)
CMakeLists.txt
README.md
TODO
ambd/pluginloader.cpp
lib/debugout.cpp
lib/debugout.h
lib/vehicleproperty.cpp
lib/vehicleproperty.h
plugins/bluemonkey/bluemonkey.cpp
plugins/common/abstractdbusinterface.cpp

index 124485d..794fe04 100644 (file)
@@ -87,6 +87,8 @@ add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/c
 
 configure_file("${CMAKE_CURRENT_SOURCE_DIR}/RELEASE.in.md" "${CMAKE_CURRENT_SOURCE_DIR}/RELEASE.md" @ONLY)
 
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/TODO" "${CMAKE_CURRENT_SOURCE_DIR}/TODO.md" @ONLY)
+
 # packaging stuff:
 # Common things to every type of package
 SET(CPACK_PACKAGE_DESCRIPTION "daemon that provides access vehicle data")
@@ -109,3 +111,5 @@ add_subdirectory(tools)
 add_subdirectory(examples)
 add_subdirectory(xwalk)
 add_subdirectory(packaging.in)
+
+
index 65479f1..b32a3b2 100644 (file)
--- a/README.md
+++ b/README.md
@@ -60,7 +60,7 @@ You will also need to edit your config to enable the Qt-based mainloop:
 
 ~~~~~~~~~~~~~{.json}
 {
-       "mainloop" : "/usr/lib/x86_64-linux-gnu/automotive-message-broker/qtmainloopplugin.so",
+       "mainloop" : "/usr/lib/i386-linux-gnu/automotive-message-broker/qtmainloopplugin.so",
        "plugins" : "/etc/ambd/plugins.d"
 }
 ~~~~~~~~~~~~~
diff --git a/TODO b/TODO
index 699abf6..31fb46b 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,4 +1,7 @@
-- Refactor obd2 plugin with AsyncQueue.  Use thread safe-update property.
+- Make updateFrequency a normal property
+- Core auto-calculate updateFrequency
+- Create API export class that creates the standardized API regardless of IPC mechanism.  That way, the same API can be used over websockets too.
+- Refactor obd2 plugin with AsyncQueue.  Use thread-safe updateProperty.
 - source export from database plugin does not reflect the source in the database
 - grep all the TODOs in the code and do them
 
index a6571f4..6727413 100644 (file)
@@ -21,20 +21,20 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 #include "glibmainloop.h"
 #include "core.h"
 
-#include <json.h>
 #include <gio/gio.h>
 #include <picojson.h>
 
 #include <iostream>
+#include <fstream>
 #include <stdexcept>
 #include <boost/concept_check.hpp>
 
 std::string get_file_contents(const char *filename)
 {
        std::ifstream in(filename, std::ios::in);
-       if(!in.is_open())
+       if(in.fail())
        {
-               DebugOut(DebugOut::Error) << "Failed to open file: " << filename << endl;
+               DebugOut(DebugOut::Error) << "Failed to open file '" << filename << "':' " << strerror(errno) << endl;
                return "";
        }
 
@@ -59,7 +59,7 @@ PluginLoader::PluginLoader(string configFile, int argc, char** argv): f_create(N
 
        if(!picojsonerr.empty())
        {
-               DebugOut(DebugOut::Error) << "Failed to parse main config! " << endl;
+               DebugOut(DebugOut::Error) << "Failed to parse main config! " << picojsonerr << endl;
                throw std::runtime_error("Error parsing config");
        }
 
index dd72c47..f9bac35 100644 (file)
@@ -32,3 +32,14 @@ void debugOut(const string &message)
 {
        DebugOut()<<"DEBUG: "<<message.c_str()<<endl;
 }
+
+
+void amb::deprecateMethod(const string & methodName, const string &version)
+{
+       DebugOut(DebugOut::Warning) << methodName << " is deprecated in " << version << endl;
+
+       if(version == PROJECT_SERIES)
+       {
+               throw std::runtime_error("Using deprecated function.");
+       }
+}
index 5dfe251..a164908 100644 (file)
@@ -59,6 +59,17 @@ void debugOut(const string &message);
  * DebugOut() << "This will log to stderr." << std::endl;
  * \endcode
  */
+
+namespace amb
+{
+/*!
+ * \brief deprecateMethod prints warning if method is used.  Throws if version >= PROJECT_SERIES
+ * \param methodName name of method being deprecated.
+ * \param version version in which this method will no longer function in.
+ */
+void deprecateMethod(const string &methodName, const std::string & version);
+}
+
 class DebugOut
 {
 public:
index ec186c1..a78df28 100644 (file)
@@ -137,6 +137,7 @@ const VehicleProperty::Property VehicleProperty::AccelerationX = "AccelerationX"
 const VehicleProperty::Property VehicleProperty::AccelerationY = "AccelerationY";
 const VehicleProperty::Property VehicleProperty::AccelerationZ = "AccelerationZ";
 const VehicleProperty::Property VehicleProperty::MassAirFlow = "MassAirFlow";
+[[deprecated("Deprecated in 0.14.  Use ButtonEventW3C")]]
 const VehicleProperty::Property VehicleProperty::ButtonEvent = "ButtonEvent";
 const VehicleProperty::Property VehicleProperty::AirIntakeTemperature = "AirIntakeTemperature";
 const VehicleProperty::Property VehicleProperty::BatteryVoltage = "BatteryVoltage";
index 6fdfbcf..ced4a40 100644 (file)
@@ -30,8 +30,6 @@
 #include "abstractpropertytype.h"
 #include "mappropertytype.hpp"
 
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-
 namespace ButtonEvents {
 enum ButtonEventType {
        NoButton = 0,
@@ -542,7 +540,6 @@ public:
 
        /**< Button Event @see ButtonEvents::ButtonEventType */
        ///TODO: deprecated.  Use ButtonEventW3C. Remove in 0.14
-       [[deprecated("Deprecated in 0.14.  Use ButtonEventW3C")]]
        static const Property ButtonEvent;
        PROPERTYTYPE(ButtonEvent, ButtonEventType, BasicPropertyType<ButtonEvents::ButtonEventType>, ButtonEvents::ButtonEventType)
 
index c5c70d7..958e43c 100644 (file)
@@ -317,6 +317,12 @@ void BluemonkeySink::reloadEngine()
        QJSValue value = engine->newQObject(this);
        engine->globalObject().setProperty("bluemonkey", value);
 
+       QThread* thread = new QThread(this);
+
+       engine->moveToThread(thread);
+
+       thread->start();
+
        loadConfig(configuration["config"].c_str());
 }
 
index eb57b1c..85940a0 100644 (file)
@@ -229,6 +229,7 @@ void AbstractDBusInterface::handleMyMethodCall(GDBusConnection       *connection
        ///TODO: Deprecated in 0.15
        else if(boost::algorithm::starts_with(method, "Get"))
        {
+               amb::deprecateMethod(method, "0.15");
                std::string propertyName = method.substr(3);
                auto propertyMap = iface->getProperties();
                if(propertyMap.find(propertyName) == propertyMap.end())