connect(obd,req->arglist[0],req->arglist[1]);
connected = true;
}
+ else if (req->req == "connectifnot")
+ {
+ if (!connected)
+ {
+ connect(obd,req->arglist[0],req->arglist[1]);
+ connected = true;
+ }
+ }
else if (req->req == "setportandbaud")
{
port = req->arglist[0];
}
if (reqList.size() > 0 && !connected)
{
- CommandRequest *req = new CommandRequest();
+ /*CommandRequest *req = new CommandRequest();
req->req = "connect";
req->arglist.push_back(port);
req->arglist.push_back(baud);
g_async_queue_push(privCommandQueue,req);
- continue;
+ continue;*/
}
else if (reqList.size() == 0 && connected)
{
g_async_queue_push(privCommandQueue,req);
continue;
}
+ if (!connected)
+ {
+ usleep(10000);
+ continue;
+ }
for (std::list<ObdPid*>::iterator i=reqList.begin();i!= reqList.end();i++)
{
repeatReqList.push_back(*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";
+ CommandRequest *req = new CommandRequest();
+ req->req = "disconnect";
+ g_async_queue_push(privCommandQueue,req);
continue;
}
//ObdPid *pid = ObdPid::pidFromReply(replyVector);
//DebugOut()<<"Reply: "<<replyVector[2]<<" "<<replyVector[3]<<endl;
}
- if (!connected)
- {
- usleep(10000);
- }
repeatReqList.clear();
}
ObdPid *pid = obd2AmbInstance->createPidforProperty(property);
g_async_queue_push(subscriptionAddQueue,pid);
+ CommandRequest *req = new CommandRequest();
+ req->req = "connectifnot";
+ g_async_queue_push(commandQueue,req);
}
}
ObdPid* requ = obd2AmbInstance->createPidforProperty(property);
g_async_queue_push(singleShotQueue,requ);
+ CommandRequest *req = new CommandRequest();
+ req->req = "connectifnot";
+ g_async_queue_push(commandQueue,req);
}
AsyncPropertyReply *OBD2Source::setProperty(AsyncSetPropertyRequest request )