fixes for bluemonkey and wheel
authorKevron Rees <kevron.m.rees@intel.com>
Tue, 9 Sep 2014 22:19:23 +0000 (15:19 -0700)
committerKevron Rees <kevron.m.rees@intel.com>
Tue, 9 Sep 2014 22:19:23 +0000 (15:19 -0700)
TODO
lib/abstractpropertytype.h
lib/vehicleproperty.h
plugins/bluemonkey/bluemonkey.cpp
plugins/bluemonkey/bluemonkey.h
plugins/common/bluetooth5.cpp
plugins/common/bluetooth5.h
plugins/obd2plugin/obd2source.cpp
plugins/obd2plugin/obd2source.h
plugins/wheel/wheelplugin.cpp

diff --git a/TODO b/TODO
index 95f7c7f..35687bc 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,10 +1,6 @@
-For 0.12
 
+- Refactor obd2 plugin with AsyncQueue.  Use thread safe-update property.
 - Rewrite websocket test html
-
-
-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 (Verify)
@@ -15,17 +11,6 @@ For 0.11
 - create docs for all plugins (README)
 - handle badly formed messages properly (ie not crash) in websocketsink
 - GetHistory must filter on source
-
-Completed:
-
-- DBus support for time and sequece being an additional api call (ie, getVehicleSpeed()). - DONE
-- DBus support for objects with multiple sources and multiple 'zones' (/${sourceID}/[${zone}/]batteryVoltage) - DONE
-- Document changes to the DBus API in the IDL - DONE
-- 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
index f68bfca..c22d2ff 100644 (file)
@@ -368,20 +368,6 @@ public:
                setValue(basicValue() - 1);
        }
 
-       BasicPropertyType operator ++ (int)
-       {
-               BasicPropertyType<T> temp = *this;
-               temp.setValue(basicValue() + 1);
-               return temp;
-       }
-
-       BasicPropertyType operator -- (int)
-       {
-               BasicPropertyType<T> temp = *this;
-               temp.setValue(basicValue() - 1);
-               return temp;
-       }
-
        bool operator < (const BasicPropertyType<T>& other) const
        {
                return value<T>() < other.value<T>();
index b2cfa81..3c5b97d 100644 (file)
@@ -420,7 +420,6 @@ public:
        */
        static const Property SteeringWheelAngle;
        PROPERTYTYPE(SteeringWheelAngle, SteeringWheelAngleType, BasicPropertyType<uint16_t>, uint16_t)
-       //typedef BasicPropertyType<uint16_t> SteeringWheelAngleType;
 
        /// TODO: Rename to "SteeringWheel" in 0.13
        static const Property SteeringWheelAngleW3C;
@@ -429,22 +428,18 @@ public:
        /**< 0=off, 1=right, 2=left, 3=hazard */
        static const Property TurnSignal;
        PROPERTYTYPEBASIC(TurnSignal, TurnSignals::TurnSignalType)
-       //typedef BasicPropertyType<TurnSignals::TurnSignalType> TurnSignalType;
 
        /**< Clutch pedal status 0=off, 1=on */
        static const Property ClutchStatus;
        PROPERTYTYPE(ClutchStatus, ClutchStatusType,BasicPropertyType<bool>,bool)
-       //typedef BasicPropertyType<bool> ClutchStatusType;
 
         /**< Oil pressure TODO: units */
        static const Property EngineOilPressure;
-       PROPERTYTYPE(EngineOilPressure, EngineOilPressureType,BasicPropertyType<uint16_t>, uint16_t)
-       //typedef BasicPropertyType<uint16_t> EngineOilPressureType;
+       PROPERTYTYPE(EngineOilPressure, EngineOilPressureType, BasicPropertyType<uint16_t>, uint16_t)
 
        /**< Engine coolant temperature in degrees celcius **/
        static const Property EngineCoolantTemperature;
        PROPERTYTYPE(EngineCoolantTemperature, EngineCoolantTemperatureType, BasicPropertyType<int>, int)
-       //typedef BasicPropertyType<int> EngineCoolantTemperatureType;
 
        static const Property EngineCoolantLevel;
        PROPERTYTYPE(EngineCoolantLevel, EngineCoolantLevelType, BasicPropertyType<uint>, uint)
@@ -452,12 +447,10 @@ public:
        /**< 0=off, 1=on */
        static const Property MachineGunTurretStatus;
        PROPERTYTYPEBASIC(MachineGunTurretStatus, bool)
-       //typedef BasicPropertyType<bool> MachineGunTurretStatusType;
 
        /**< Acceleration on the 'x' axis in 1/1000 gravitational acceleration "g-force" */
        static const Property AccelerationX;
        PROPERTYTYPE(AccelerationX, AccelerationXType, BasicPropertyType<uint16_t>, uint16_t)
-       //typedef BasicPropertyType<uint16_t> AccelerationType;
 
        /**< Acceleration on the 'y' axis in 1/1000 gravitational acceleration "g-force" */
        static const Property AccelerationY;
index 4e577bb..5ff5689 100644 (file)
@@ -382,7 +382,7 @@ void Property::setValue(QVariant v)
        {
                if(reply->success)
                {
-                       propertyChanged(reply->property, reply->value, reply->value->sourceUuid);
+                       propertyChanged(reply->value);
                }
                delete reply;
        };
@@ -444,9 +444,9 @@ QString Property::type()
 void Property::setType(QString t)
 {
        if(mValue && type() != "")
-               routingEngine->unsubscribeToProperty(type().toStdString(),this);
+               routingEngine->unsubscribeToProperty(type().toStdString(), this);
 
-       routingEngine->subscribeToProperty(t.toStdString(),this);
+       routingEngine->subscribeToProperty(t.toStdString(), this);
 
        mValue = VehicleProperty::getPropertyTypeForPropertyNameValue(t.toStdString());
 
@@ -458,7 +458,7 @@ void Property::setType(QString t)
        request.completed = [this](AsyncPropertyReply* reply)
        {
                if(reply->success)
-                       propertyChanged(reply->property, reply->value,uuid());
+                       propertyChanged(reply->value);
 
                delete reply;
        };
@@ -466,7 +466,7 @@ void Property::setType(QString t)
        routingEngine->getPropertyAsync(request);
 }
 
-void Property::propertyChanged(VehicleProperty::Property property, AbstractPropertyType *value, string uuid)
+void Property::propertyChanged(AbstractPropertyType *value)
 {
        if(mValue)
        {
index e67814c..a9fd240 100644 (file)
@@ -54,7 +54,7 @@ public:
                DebugOut()<<"Bluemonkey Property Supported Changed"<<endl;
        }
 
-       virtual void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, std::string uuid);
+       virtual void propertyChanged(AbstractPropertyType* value);
 
        virtual const std::string uuid() { return mUuid; }
 
index 5244e70..cd346c8 100644 (file)
@@ -252,23 +252,52 @@ Bluetooth5::Bluetooth5()
        }
 }
 
+bool Bluetooth5::setDevice(string address)
+{
+       mPath = findDevice(address);
+
+
+       if(mPath == "")
+       {
+               DebugOut(DebugOut::Error) << "device path not found.  Not paired? " << endl;
+               return false;
+       }
+
+       return true;
+}
+
 void Bluetooth5::getDeviceForAddress(std::string address, ConnectedCallback connectedCallback)
 {
        mConnected = connectedCallback;
 
-       std::string devicePath = findDevice(address);
+       if(!setDevice(address))
+               return;
 
-       DebugOut() << "Bluetooth device path: " << devicePath << endl;
+       DebugOut() << "Bluetooth device path: " << mPath << endl;
 
-       if(devicePath == "")
+       connect(connectedCallback);
+}
+
+void Bluetooth5::connected(int fd)
+{
+       try
        {
-               DebugOut(DebugOut::Error) << "device path not found.  Not paired? " << endl;
+               mConnected(fd);
        }
+       catch(...)
+       {
+               DebugOut(DebugOut::Error) << "Error calling connected callback" << endl;
+       }
+}
+
+void Bluetooth5::connect(ConnectedCallback onconnectedCallback)
+{
+       mConnected = onconnectedCallback;
 
        GError* error = nullptr;
 
-       GDBusProxy * deviceProxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,G_DBUS_PROXY_FLAGS_NONE,NULL,
-                                                                                                                         "org.bluez", devicePath.c_str(), "org.bluez.Device1", nullptr, &error);
+       auto  deviceProxyPtr = amb::make_super(g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,G_DBUS_PROXY_FLAGS_NONE,NULL,
+                                                                                                                         "org.bluez", mPath.c_str(), "org.bluez.Device1", nullptr, &error));
 
        auto errorPtr = amb::make_super(error);
 
@@ -278,13 +307,13 @@ void Bluetooth5::getDeviceForAddress(std::string address, ConnectedCallback conn
                return;
        }
 
-       g_dbus_proxy_call(deviceProxy, "Connect", nullptr, G_DBUS_CALL_FLAGS_NONE, -1, nullptr,
+       g_dbus_proxy_call(deviceProxyPtr.get(), "Connect", nullptr, G_DBUS_CALL_FLAGS_NONE, -1, nullptr,
                                          [](GObject *source_object, GAsyncResult *res, gpointer user_data)
        {
 
                GError* error = nullptr;
 
-               g_dbus_proxy_call_finish(G_DBUS_PROXY (source_object),res, &error);
+               g_dbus_proxy_call_finish(G_DBUS_PROXY (source_object), res, &error);
 
                auto errorPtr = amb::make_super(error);
 
@@ -296,14 +325,32 @@ void Bluetooth5::getDeviceForAddress(std::string address, ConnectedCallback conn
        this);
 }
 
-void Bluetooth5::connected(int fd)
+void Bluetooth5::disconnect()
 {
-       //try
-       {
-               mConnected(fd);
-       }
-       //catch(...)
+       GError* error = nullptr;
+
+       auto  deviceProxyPtr = amb::make_super(g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,G_DBUS_PROXY_FLAGS_NONE,NULL,
+                                                                                                                         "org.bluez", mPath.c_str(), "org.bluez.Device1", nullptr, &error));
+
+       auto errorPtr = amb::make_super(error);
+
+       if(errorPtr)
        {
-               //DebugOut(DebugOut::Error) << "Error calling connected callback" << endl;
+               DebugOut(DebugOut::Error) << "Error getting bluetooth device proxy " << errorPtr->message <<endl;
+               return;
        }
+
+       g_dbus_proxy_call(deviceProxyPtr.get(), "Disconnect", nullptr, G_DBUS_CALL_FLAGS_NONE, -1, nullptr,[](GObject *source_object,
+                                         GAsyncResult *res, gpointer user_data){
+               GError* error = nullptr;
+
+               g_dbus_proxy_call_finish(G_DBUS_PROXY (source_object), res, &error);
+
+               auto errorPtr = amb::make_super(error);
+
+               if(errorPtr)
+               {
+                       DebugOut(DebugOut::Error) << "error trying to disconnect: " << errorPtr->message << endl;
+               }
+       }, nullptr);
 }
index 52170db..0b479c3 100644 (file)
@@ -11,13 +11,18 @@ class Bluetooth5
 public:
        Bluetooth5();
 
+       bool setDevice(std::string address);
        void getDeviceForAddress(std::string address,  ConnectedCallback onnectedCallback);
-       void disconnect(std::string address, std::string adapterAddy = "");
 
        void connected(int fd);
 
+       void connect( ConnectedCallback onconnectedCallback);
+       void disconnect();
+
+
 private:
        ConnectedCallback mConnected;
+       std::string mPath;
 };
 
 #endif
index 3253c15..aa585b5 100644 (file)
 #include "debugout.h"
 #include "bluetooth.hpp"
 #include "timestamp.h"
+#include "bluetooth5.h"
+#include "superptr.hpp"
+
+#ifdef USE_BLUEZ5
+Bluetooth5 bt;
+#endif
 
 #define __SMALLFILE__ std::string(__FILE__).substr(std::string(__FILE__).rfind("/")+1)
 AbstractRoutingEngine *m_re;
@@ -39,7 +45,7 @@ int calledPersecond = 0;
 
 bool sendElmCommand(obdLib *obd,std::string command)
 {
-       std::vector<unsigned char> replyVector;
+       std::vector<unsigned char> replyVector;
        std::string reply;
        obd->sendObdRequestString(command.append("\r").c_str(),command.length()+1,&replyVector,10,3);
        for (unsigned int i=0;i<replyVector.size();i++)
@@ -72,7 +78,7 @@ bool connect(obdLib* obd, std::string device, std::string strbaud, int fd = -1)
 
        if(fd != -1)
        {
-               if(obd->openPort(fd,baud) == -1)
+               if(obd->openPort(fd, baud) == -1)
                        return false;
        }
        else
@@ -123,7 +129,7 @@ bool connect(obdLib* obd, std::string device, std::string strbaud, int fd = -1)
                DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Error turning off linefeeds"<<endl;
                return false;
        }
-       obd->sendObdRequestString("010C1\r",6,&replyVector,500,5);
+       obd->sendObdRequestString("010C1\r", 6, &replyVector, 500, 5);
 
        return true;
 }
@@ -136,17 +142,16 @@ void threadLoop(gpointer data)
        GAsyncQueue *privSubscriptionAddQueue = g_async_queue_ref(((OBD2Source*)data)->subscriptionAddQueue);
        GAsyncQueue *privSubscriptionRemoveQueue = g_async_queue_ref(((OBD2Source*)data)->subscriptionRemoveQueue);
        GAsyncQueue *privStatusQueue = g_async_queue_ref(((OBD2Source*)data)->statusQueue);
-       
+
        obdLib *obd = new obdLib();
        OBD2Source *source = (OBD2Source*)data;
 
        obd->setCommsCallback([](const char* mssg, void* data) { DebugOut(6)<<mssg<<endl; },NULL);
        obd->setDebugCallback([](const char* mssg, void* data, obdLib::DebugLevel debugLevel) { DebugOut(debugLevel)<<mssg<<endl; },NULL);
-       
+
        std::list<ObdPid*> reqList;
        std::list<ObdPid*> repeatReqList;
        ObdPid::ByteArray replyVector;
-       std::string reply;
        std::string port;
        std::string baud;
        bool connected=false;
@@ -154,14 +159,11 @@ void threadLoop(gpointer data)
        int timeoutCount = 0;
        while (source->m_threadLive)
        {
-               //gpointer query = g_async_queue_pop(privCommandQueue);
-               
-               
                gpointer query = g_async_queue_try_pop(privSingleShotQueue);
                if (query != nullptr)
                {
                        //printf("Got request!\n");
-                       
+
                        ObdPid *req = (ObdPid*)query;
                        DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Got single shot request: " << req->pid.substr(0,req->pid.length()-1) << ":" << req->property <<endl;
                        repeatReqList.push_back(req);
@@ -182,74 +184,78 @@ void threadLoop(gpointer data)
                        //commandMap[req->req] = req->arg;
                        //printf("Command: %s\n",req->req.c_str());
                        DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Command:" << req->req << endl;
-                       if (req->req == "connect" )
-                       {
-
-                               if (source->m_isBluetooth)
-                               {
-
-                                       BluetoothDevice bt;
-                                       std::string tempPort = bt.getDeviceForAddress(source->m_btDeviceAddress, source->m_btAdapterAddress);
-                                       if(tempPort != "")
-                                       {
-                                               DebugOut(3)<<"Using bluetooth device \""<<source->m_btDeviceAddress<<"\" bound to: "<<tempPort<<endl;
-                                               port = tempPort;
-                                       }
-                               }
-                               else
-                               {
-                                       port = req->arglist[0];
-                                       baud = req->arglist[1];
-                               }
-                               connected = connect(obd,port,baud);
-
-                               if(connected)
-                               {
-                                       StatusMessage *statusreq = new StatusMessage();
-                                       statusreq->statusStr = "connected";
-                                       g_async_queue_push(privStatusQueue,statusreq);
-                               }
-                               else
-                               {
-                                       StatusMessage *statusreq = new StatusMessage();
-                                       statusreq->statusStr = "disconnected";
-                                       g_async_queue_push(privStatusQueue,statusreq);
-                               }
-                               
-                       }
-                       else if (req->req == "connectifnot")
+                       if (req->req == "connectifnot")
                        {
                                if (!connected)
                                {
                                        if (source->m_isBluetooth)
                                        {
+#ifdef USE_BLUEZ5
+                                               bt.getDeviceForAddress(source->m_btDeviceAddress, [&obd, baud, &privStatusQueue](int fd)
+                                               {
+                                                       bool connected = connect(obd, "", baud, fd);
+
+                                                       if(connected)
+                                                       {
+                                                               StatusMessage *statusreq = new StatusMessage();
+                                                               statusreq->statusStr = "connected";
+                                                               g_async_queue_push(privStatusQueue, statusreq);
+                                                       }
+                                                       else
+                                                       {
+                                                               StatusMessage *statusreq = new StatusMessage();
+                                                               statusreq->statusStr = "disconnected";
+                                                               g_async_queue_push(privStatusQueue, statusreq);
+                                                       }
+                                               });
+#else
                                                BluetoothDevice bt;
                                                std::string tempPort = bt.getDeviceForAddress(source->m_btDeviceAddress, source->m_btAdapterAddress);
                                                if(tempPort != "")
                                                {
-                                                       DebugOut(3)<<"Using bluetooth device \""<<source->m_btDeviceAddress<<"\" bound to: "<<tempPort<<endl;
+                                                       DebugOut(3) << "Using bluetooth device \"" << source->m_btDeviceAddress << "\" bound to: " << tempPort << endl;
                                                        port = tempPort;
                                                }
                                                else
                                                {
-                                                       DebugOut(DebugOut::Error)<<"Error creating bluetooth device"<<endl;
+                                                       DebugOut(DebugOut::Error) << "Error creating bluetooth device" << endl;
                                                        continue;
                                                }
-                                       }
 
-                                       connected = connect(obd,port,baud);
+                                               connected = connect(obd, port, baud);
 
-                                       if(connected)
-                                       {
-                                               StatusMessage *statusreq = new StatusMessage();
-                                               statusreq->statusStr = "connected";
-                                               g_async_queue_push(privStatusQueue,statusreq);
+                                               if(connected)
+                                               {
+                                                       StatusMessage *statusreq = new StatusMessage();
+                                                       statusreq->statusStr = "connected";
+                                                       g_async_queue_push(privStatusQueue, statusreq);
+                                               }
+                                               else
+                                               {
+                                                       StatusMessage *statusreq = new StatusMessage();
+                                                       statusreq->statusStr = "disconnected";
+                                                       g_async_queue_push(privStatusQueue, statusreq);
+                                               }
+
+#endif
                                        }
                                        else
                                        {
-                                               StatusMessage *statusreq = new StatusMessage();
-                                               statusreq->statusStr = "disconnected";
-                                               g_async_queue_push(privStatusQueue,statusreq);
+
+                                               connected = connect(obd, port, baud);
+
+                                               if(connected)
+                                               {
+                                                       StatusMessage *statusreq = new StatusMessage();
+                                                       statusreq->statusStr = "connected";
+                                                       g_async_queue_push(privStatusQueue, statusreq);
+                                               }
+                                               else
+                                               {
+                                                       StatusMessage *statusreq = new StatusMessage();
+                                                       statusreq->statusStr = "disconnected";
+                                                       g_async_queue_push(privStatusQueue, statusreq);
+                                               }
                                        }
                                }
                        }
@@ -262,8 +268,12 @@ void threadLoop(gpointer data)
                        {
                                DebugOut() << __SMALLFILE__ << ":" << __LINE__ << "Using queued disconnect" << (ulong)req << endl;
                                obd->closePort();
+#ifdef USE_BLUEZ5
+                               bt.disconnect();
+#else
                                BluetoothDevice bt;
                                bt.disconnect(source->m_btDeviceAddress, source->m_btAdapterAddress);
+#endif
                                connected = false;
                                StatusMessage *statusreq = new StatusMessage();
                                statusreq->statusStr = "disconnected";
@@ -360,7 +370,7 @@ void threadLoop(gpointer data)
                                                int count = (*source->m_blacklistPidCountMap.find((*i)->pid)).second;
                                                if (count > 10)
                                                {
-                                                       
+
                                                }
                                                source->m_blacklistPidCountMap.erase(source->m_blacklistPidCountMap.find((*i)->pid));
                                                source->m_blacklistPidCountMap.insert(pair<std::string,int>((*i)->pid,count));
@@ -391,7 +401,7 @@ void threadLoop(gpointer data)
                                {
                                        DebugOut() << __SMALLFILE__ << ":" << __LINE__ << "OBD Other error:" << obd->lastError() << endl;
                                }
-                               
+
                                CommandRequest *req = new CommandRequest();
                                DebugOut() << __SMALLFILE__ << ":" << __LINE__ << "Queuing up a disconnect" << (ulong)req << endl;
                                req->req = "disconnect";
@@ -436,7 +446,7 @@ void threadLoop(gpointer data)
                        //usleep(10000);
                }
                repeatReqList.clear();
-               
+
        }
        if (connected)
        {
@@ -447,19 +457,20 @@ static int updateProperties( gpointer data)
 {
 
        OBD2Source* src = (OBD2Source*)data;
-       
+
        while (gpointer retval = g_async_queue_try_pop(src->statusQueue))
        {
                StatusMessage *reply = (StatusMessage*)retval;
                if (reply->statusStr == "disconnected")
                {
                        OBD2Source::Obd2ConnectType val(Obd2Connected,false);
-                       src->updateProperty(Obd2Connected,&val);
+                       src->updateProperty(&val);
                }
                else if (reply->statusStr == "connected")
                {
                        OBD2Source::Obd2ConnectType val(Obd2Connected, true);
-                       src->updateProperty(Obd2Connected,&val);
+                       val.priority = OBD2Source::Obd2ConnectType::Instant;
+                       src->updateProperty(&val);
                }
                else if (reply->statusStr == "error:nodata" || reply->statusStr == "error:timeout")
                {
@@ -487,20 +498,20 @@ static int updateProperties( gpointer data)
        {
                ObdPid *reply = (ObdPid*)retval;
 
-               
-               AbstractPropertyType* value = VehicleProperty::getPropertyTypeForPropertyNameValue(reply->property, reply->value);
-               src->updateProperty(reply->property, value);
-               delete value;
+               auto value = amb::make_unique(VehicleProperty::getPropertyTypeForPropertyNameValue(reply->property, reply->value));
+               value->priority = AbstractPropertyType::Instant;
+               src->updateProperty(value.get());
        }
 
        return true;
 }
 
-void OBD2Source::updateProperty(VehicleProperty::Property property,AbstractPropertyType* value)
+void OBD2Source::updateProperty(AbstractPropertyType* value)
 {
+       VehicleProperty::Property property = value->name;
        if(property == Obd2Connected)
                obd2Connected.setValue(value->anyValue());
-       
+
        if (propertyReplyMap.find(property) != propertyReplyMap.end())
        {
                propertyReplyMap[property]->value = value;
@@ -549,13 +560,13 @@ void OBD2Source::setConfiguration(map<string, string> config)
 {
 //     //Config has been passed, let's start stuff up.
        configuration = config;
-       
+
        //Default values
        std::string port = "/dev/ttyUSB0";
        std::string baud = "115200";
        std::string btadapter = "";
        m_isBluetooth = false;
-       
+
        //Try to load config
        //printf("OBD2Source::setConfiguration\n");
        for (map<string,string>::iterator i=configuration.begin();i!=configuration.end();i++)
@@ -607,7 +618,7 @@ void OBD2Source::setConfiguration(map<string, string> config)
        req->arglist.push_back(port);
        req->arglist.push_back(baud);
        g_async_queue_push(commandQueue,req);
-       
+
        m_port = port;
        m_baud = baud;
        m_gThread = g_thread_new("mythread",(GThreadFunc)&threadLoop,this);
@@ -626,7 +637,7 @@ OBD2Source::OBD2Source(AbstractRoutingEngine *re, map<string, string> config)
        }
 
        clientConnected = false;
-       m_re = re;  
+       m_re = re;
 
        m_threadLive = true;
        Obd2Amb obd2amb;
@@ -670,7 +681,7 @@ int OBD2Source::supportedOperations()
 extern "C" AbstractSource * create(AbstractRoutingEngine* routingengine, map<string, string> config)
 {
        return new OBD2Source(routingengine, config);
-       
+
 }
 const string OBD2Source::uuid()
 {
@@ -699,18 +710,19 @@ void OBD2Source::subscribeToPropertyChanges(VehicleProperty::Property property)
 
                if(!pid)
                {
+                       DebugOut(DebugOut::Warning) << "We don't support this property: " << property <<endl;
                        return;
                }
-               
+
                //If the pid is currently in the blacklist map, erase it. This allows for applications
                //to "un-blacklist" a pid by re-subscribing to it.
                if (m_blacklistPidCountMap.find(pid->pid) != m_blacklistPidCountMap.end())
                {
                        m_blacklistPidCountMap.erase(m_blacklistPidCountMap.find(pid->pid));
                }
-                                       
-                                       
-               g_async_queue_push(subscriptionAddQueue,pid);
+
+
+               g_async_queue_push(subscriptionAddQueue, pid);
                CommandRequest *req = new CommandRequest();
                req->req = "connectifnot";
                g_async_queue_push(commandQueue,req);
index 6b20e30..d93f1b4 100644 (file)
@@ -114,7 +114,7 @@ public:
                        {
                                continue;
                        }
-                       
+
                        ObdPid* pid = (*itr)->create();
                        return pid;
                }
@@ -181,7 +181,7 @@ public:
        std::string m_btDeviceAddress;
        std::string m_btAdapterAddress;
        map<VehicleProperty::Property,AsyncPropertyReply*> propertyReplyMap;
-       void updateProperty(VehicleProperty::Property property,AbstractPropertyType *value);
+       void updateProperty(AbstractPropertyType *value);
        obdLib * obd;
        bool m_threadLive;
        GThread *m_gThread;
index e8cb142..f6ebdbb 100644 (file)
@@ -517,7 +517,11 @@ void WheelPrivate::changeGear(int gear)
 
 void WheelPrivate::changeOilPressure(bool increase)
 {
-       (increase ? *(oilPSI)++ : *(oilPSI)--);
+       if(increase)
+               oilPSI->setValue(oilPSI->basicValue()+1);
+       else if(oilPSI->basicValue() > 0)
+               oilPSI->setValue(oilPSI->basicValue()-1);
+
        this->re->updateProperty(oilPSI, mParent->uuid());
 }