}
else if (req->req == "disconnect")
{
- DebugOut() << __SMALLFILE__ << ":" << __LINE__ << "Using queued disconnect" << (ulong)req << "\n";
+ DebugOut() << __SMALLFILE__ << ":" << __LINE__ << "Using queued disconnect" << (ulong)req << endl;
obd->closePort();
ObdBluetoothDevice bt;
bt.disconnect(source->m_btDeviceAddress, source->m_btAdapterAddress);
query = g_async_queue_try_pop(privSubscriptionRemoveQueue);
if (query != nullptr)
{
- DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Got unsubscription request\n";
+ DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Got unsubscription request"<<endl;
ObdPid *req = (ObdPid*)query;
for (std::list<ObdPid*>::iterator i=reqList.begin();i!= reqList.end();i++)
{
if (!obd->sendObdRequestString((*i)->pid.c_str(),(*i)->pid.length(),&replyVector))
{
//This only happens during a error with the com port. Close it and re-open it later.
- DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Unable to send request:" << (*i)->pid << "!\n";
+ DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Unable to send request:" << (*i)->pid << endl;
if (obd->lastError() == obdLib::NODATA)
{
- DebugOut() << __SMALLFILE__ << ":" << __LINE__ << "OBDLib::NODATA for pid" << (*i)->pid << "\n";
+ DebugOut() << __SMALLFILE__ << ":" << __LINE__ << "OBDLib::NODATA for pid" << (*i)->pid <<endl;
if (source->m_blacklistPidCountMap.find((*i)->pid) != source->m_blacklistPidCountMap.end())
{
//pid value i not yet in the list.
timeoutCount++;
if (timeoutCount < 2)
{
- DebugOut() << __SMALLFILE__ << ":" << __LINE__ << "OBDLib::TIMEOUT for pid" << (*i)->pid << "\n";
+ DebugOut() << __SMALLFILE__ << ":" << __LINE__ << "OBDLib::TIMEOUT for pid" << (*i)->pid << endl;
StatusMessage *statusreq = new StatusMessage();
statusreq->statusStr = "error:timeout";
g_async_queue_push(privStatusQueue,statusreq);
continue;
}
g_async_queue_push(privResponseQueue,pid);
- //printf("Req: %s\n",(*i).c_str());
- /*if ((*i) == "ATRV\r")
- {
- //printf("Requesting voltage...\n");
- if (!obd->sendObdRequestString((*i).c_str(),(*i).length(),&replyVector))
- {
- //printf("Unable to request voltage!!!\n");
- DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Unable to request voltage!\n";
- continue;
- }
- std::string replystring = "";
- for (int j=0;j<replyVector.size();j++)
- {
- replystring += replyVector[j];
- }
- //printf("Voltage reply: %s\n",replystring.c_str());
- replystring.substr(0,replystring.find("V"));*/
- /*ObdReply *rep = new ObdReply();
- rep->req = "ATRV\r";
- rep->reply = replystring;
- g_async_queue_push(privResponseQueue,rep);*/
- /*}
- if (!obd->sendObdRequest((*i).c_str(),(*i).length(),&replyVector))
- {
- //printf("Error sending obd2 request\n");
- DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Error sending OBD2 request\n";
- continue;
- }*/
- //printf("Reply: %i %i\n",replyVector[0],replyVector[1]);
- /*
- /*
- else if (replyVector[0] == 0x49)
- {
- /*
- 49 02 01 00 00 00 31
- 49 02 02 47 31 4A 43
- 49 02 03 35 34 34 34
- 49 02 04 52 37 32 35
- 49 02 05 32 33 36 37
- //VIN number reply
- string vinstring;
- for (int j=0;j<replyVector.size();j++)
- {
- if(replyVector[j] == 0x49 && replyVector[j+1] == 0x02)
- {
- //We're at a reply header
- j+=3;
- }
- if (replyVector[j] != 0x00)
- {
- vinstring += (char)replyVector[j];
- //printf("VIN: %i %c\n",replyVector[j],replyVector[j]);
- }
- }
- /*ObdReply *rep = new ObdReply();
- rep->req = "0902";
- rep->reply = vinstring;
- g_async_queue_push(privResponseQueue,rep);*/
-
- //DebugOut()<<"Reply: "<<replyVector[2]<<" "<<replyVector[3]<<endl;
}
if (badloop == 0)
{
obd->closePort();
}
}
-static int updateProperties(/*gpointer retval,*/ gpointer data)
+static int updateProperties( gpointer data)
{
OBD2Source* src = (OBD2Source*)data;
AbstractPropertyType* value = VehicleProperty::getPropertyTypeForPropertyNameValue(reply->property, reply->value);
src->updateProperty(reply->property, value);
- /*if (reply->req == "05")
- {
- VehicleProperty::EngineCoolantTemperatureType speed(reply->reply);
- src->updateProperty(VehicleProperty::EngineCoolantTemperature,&speed);
- }
- else if (reply->req == "0C")
- {
- VehicleProperty::EngineSpeedType speed(reply->reply);
- src->updateProperty(VehicleProperty::EngineSpeed,&speed);
- }
- else if (reply->req == "0D")
- {
- VehicleProperty::VehicleSpeedType speed(reply->reply);
- src->updateProperty(VehicleProperty::VehicleSpeed,&speed);
- }
- else if (reply->req == "10")
- {
- VehicleProperty::MassAirFlowType mass(reply->reply);
- src->updateProperty(VehicleProperty::MassAirFlow,&mass);
- }
- else if (reply->req == "ATRV\r")
- {
- VehicleProperty::BatteryVoltageType volts(reply->reply);
- src->updateProperty(VehicleProperty::BatteryVoltage,&volts);
-
- }
- else if (reply->req == "0902")
- {
- //VIN number and WMI
- VehicleProperty::VINType vin(reply->reply);
- src->updateProperty(VehicleProperty::VIN,&vin);
- VehicleProperty::WMIType wmi(reply->reply.substr(0,3));
- src->updateProperty(VehicleProperty::WMI,&wmi);
- }
- else if (reply->req == "5C")
- {
- VehicleProperty::EngineCoolantTemperatureType ect(reply->reply);
- src->updateProperty(VehicleProperty::EngineCoolantTemperature,&ect);
- }
- else if (reply->req == "46")
- {
- VehicleProperty::InteriorTemperatureType temp(reply->reply);
- src->updateProperty(VehicleProperty::InteriorTemperature,&temp);
- }
- //5C -- engine oil temp
- //46 interior temp*/
-
delete reply;
}
}
void OBD2Source::subscribeToPropertyChanges(VehicleProperty::Property property)
{
- /*//printf("Subscribed to property: %s\n",property.c_str());
- if (property == VehicleProperty::EngineSpeed)
- {
- ObdRequest *requ = new ObdRequest();
- requ->req = "010C1\r";
- g_async_queue_push(subscriptionAddQueue,requ);
- }
- else if (property == VehicleProperty::MassAirFlow)
- {
- ObdRequest *requ = new ObdRequest();
- requ->req = "01101\r";
- g_async_queue_push(subscriptionAddQueue,requ);
- }
- else if (property == VehicleProperty::VehicleSpeed)
- {
- ObdRequest *requ = new ObdRequest();
- requ->req = "010D1\r";
- g_async_queue_push(subscriptionAddQueue,requ);
- }
- else if (property == VehicleProperty::EngineCoolantTemperature)
- {
- ObdRequest *requ = new ObdRequest();
- requ->req = "01051\r";
- g_async_queue_push(subscriptionAddQueue,requ);
- }
- else if (property == VehicleProperty::VIN)
- {
- DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "VIN subscription requested... but there's no point!\n";
- }
- else if (property == VehicleProperty::WMI)
- {
- DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "WMI subscription requested... but there's no point!\n";
- }
- else if (property == VehicleProperty::EngineOilTemperature)
- {
- ObdRequest *requ = new ObdRequest();
- requ->req = "015C1\r";
- g_async_queue_push(subscriptionAddQueue,requ);
- }
- else if (property == VehicleProperty::InteriorTemperature)
- {
- ObdRequest *requ = new ObdRequest();
- requ->req = "01461\r";
- g_async_queue_push(subscriptionAddQueue,requ);
- }
- else if (property == VehicleProperty::BatteryVoltage)
- {
- ObdRequest *requ = new ObdRequest();
- requ->req = "ATRV\r";
- g_async_queue_push(subscriptionAddQueue,requ);
- }
- /*m_supportedProperties.push_back(VehicleProperty::VIN);
- m_supportedProperties.push_back(VehicleProperty::WMI);
- m_supportedProperties.push_back(VehicleProperty::EngineOilTemperature);
- m_supportedProperties.push_back(VehicleProperty::InteriorTemperature);
- m_supportedProperties.push_back(VehicleProperty::BatteryVoltage);*/
- /*else
- {
- //printf("Unsupported property: %s\n",property.c_str());
- DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Unsupported property requested:" << property << "\n";
- }*/
-
if (property == VehicleProperty::VIN)
{
DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "VIN subscription requested... but there's no point!"<<endl;
void OBD2Source::unsubscribeToPropertyChanges(VehicleProperty::Property property)
{
- //
- /*if (property == VehicleProperty::EngineSpeed)
- {
- ObdRequest *requ = new ObdRequest();
- requ->req = "010C1\r";
- g_async_queue_push(subscriptionRemoveQueue,requ);
- }
- else if (property == VehicleProperty::MassAirFlow)
- {
- ObdRequest *requ = new ObdRequest();
- requ->req = "01101\r";
- g_async_queue_push(subscriptionRemoveQueue,requ);
- }
- else if (property == VehicleProperty::VehicleSpeed)
- {
- ObdRequest *requ = new ObdRequest();
- requ->req = "010D1\r";
- g_async_queue_push(subscriptionRemoveQueue,requ);
- }
- else if (property == VehicleProperty::EngineCoolantTemperature)
- {
- ObdRequest *requ = new ObdRequest();
- requ->req = "01051\r";
- g_async_queue_push(subscriptionRemoveQueue,requ);
- }
- else if (property == VehicleProperty::VIN)
- {
- ObdRequest *requ = new ObdRequest();
- requ->req = "0902\r";
- g_async_queue_push(subscriptionRemoveQueue,requ);
- }
- else if (property == VehicleProperty::WMI)
- {
- ObdRequest *requ = new ObdRequest();
- requ->req = "0902\r";
- g_async_queue_push(subscriptionRemoveQueue,requ);
- }
- else if (property == VehicleProperty::EngineOilTemperature)
- {
- ObdRequest *requ = new ObdRequest();
- requ->req = "015C1\r";
- g_async_queue_push(subscriptionRemoveQueue,requ);
- }
- else if (property == VehicleProperty::InteriorTemperature)
- {
- ObdRequest *requ = new ObdRequest();
- requ->req = "01461\r";
- g_async_queue_push(subscriptionRemoveQueue,requ);
- }
- else if (property == VehicleProperty::BatteryVoltage)
- {
- ObdRequest *requ = new ObdRequest();
- requ->req = "ATRV\r";
- g_async_queue_push(subscriptionRemoveQueue,requ);
- }
- */
-
if(!ListPlusPlus<VehicleProperty::Property>(&m_supportedProperties).contains(property))
{
DebugOut(0)<<"obd plugin does not support: "<<property<<endl;
propertyReplyMap[reply->property] = reply;
VehicleProperty::Property property = reply->property;
- //TODO: There is a much better way to do this, but for now it's hardcoded.
- /*if (property == VehicleProperty::EngineSpeed)
- {
- ObdRequest *requ = new ObdRequest();
- requ->req = "010C\r";
- g_async_queue_push(singleShotQueue,requ);
- }
- else if (property == VehicleProperty::MassAirFlow)
- {
- ObdRequest *requ = new ObdRequest();
- requ->req = "0110\r";
- g_async_queue_push(singleShotQueue,requ);
- }
- else if (property == VehicleProperty::VehicleSpeed)
- {
- ObdRequest *requ = new ObdRequest();
- requ->req = "010D\r";
- g_async_queue_push(singleShotQueue,requ);
- }
- else if (property == VehicleProperty::EngineCoolantTemperature)
- {
- ObdRequest *requ = new ObdRequest();
- requ->req = "0105\r";
- g_async_queue_push(singleShotQueue,requ);
- }
- else if (property == VehicleProperty::VIN)
- {
- ObdRequest *requ = new ObdRequest();
- requ->req = "0902\r";
- g_async_queue_push(singleShotQueue,requ);
- }
- else if (property == VehicleProperty::WMI)
- {
- ObdRequest *requ = new ObdRequest();
- requ->req = "0902\r";
- g_async_queue_push(singleShotQueue,requ);
- }
- else if (property == VehicleProperty::EngineOilTemperature)
- {
- ObdRequest *requ = new ObdRequest();
- requ->req = "015C\r";
- g_async_queue_push(singleShotQueue,requ);
- }
- else if (property == VehicleProperty::InteriorTemperature)
- {
- ObdRequest *requ = new ObdRequest();
- requ->req = "0146\r";
- g_async_queue_push(singleShotQueue,requ);
- }
- else if (property == VehicleProperty::BatteryVoltage)
- {
- ObdRequest *requ = new ObdRequest();
- requ->req = "ATRV\r";
- g_async_queue_push(singleShotQueue,requ);
- }
- */
-
- ///Here's a better way:
if(!ListPlusPlus<VehicleProperty::Property>(&m_supportedProperties).contains(property))
{