daemon parameter '--retries' (number retries send ebus command) added.
This commit is contained in:
@@ -35,6 +35,8 @@ EBusLoop::EBusLoop() : m_stop(false)
|
|||||||
A.getParam<long>("p_dumpsize"),
|
A.getParam<long>("p_dumpsize"),
|
||||||
A.getParam<bool>("p_dump"));
|
A.getParam<bool>("p_dump"));
|
||||||
|
|
||||||
|
m_retries = A.getParam<int>("p_retries");
|
||||||
|
|
||||||
m_bus->connect();
|
m_bus->connect();
|
||||||
|
|
||||||
if (m_bus->isConnected() == false)
|
if (m_bus->isConnected() == false)
|
||||||
@@ -54,6 +56,7 @@ EBusLoop::~EBusLoop()
|
|||||||
void* EBusLoop::run()
|
void* EBusLoop::run()
|
||||||
{
|
{
|
||||||
int busResult;
|
int busResult;
|
||||||
|
int retries = 0;
|
||||||
bool busCommandActive = false;
|
bool busCommandActive = false;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@@ -85,9 +88,18 @@ void* EBusLoop::run()
|
|||||||
m_bus->sendCommand();
|
m_bus->sendCommand();
|
||||||
BusCommand* busCommand = m_bus->recvCommand();
|
BusCommand* busCommand = m_bus->recvCommand();
|
||||||
L.log(bus, trace, " %s", busCommand->getResult().c_str());
|
L.log(bus, trace, " %s", busCommand->getResult().c_str());
|
||||||
|
|
||||||
|
if (busCommand->getResult().c_str()[0] == '-' && retries < m_retries) {
|
||||||
|
retries++;
|
||||||
|
L.log(bus, trace, " retry number: %d", retries);
|
||||||
|
busCommand->setResult(std::string());
|
||||||
|
m_bus->addCommand(busCommand);
|
||||||
|
} else {
|
||||||
|
retries = 0;
|
||||||
m_recvBuffer.add(busCommand);
|
m_recvBuffer.add(busCommand);
|
||||||
busCommandActive = false;
|
busCommandActive = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (busResult == 0)
|
if (busResult == 0)
|
||||||
L.log(bus, trace, " getBus failure");
|
L.log(bus, trace, " getBus failure");
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ private:
|
|||||||
bool m_stop;
|
bool m_stop;
|
||||||
WQueue<BusCommand*> m_sendBuffer;
|
WQueue<BusCommand*> m_sendBuffer;
|
||||||
WQueue<BusCommand*> m_recvBuffer;
|
WQueue<BusCommand*> m_recvBuffer;
|
||||||
|
int m_retries;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,10 @@ void define_args()
|
|||||||
"disable valid ebus device test\n",
|
"disable valid ebus device test\n",
|
||||||
Appl::type_bool, Appl::opt_none);
|
Appl::type_bool, Appl::opt_none);
|
||||||
|
|
||||||
|
A.addItem("p_retries", Appl::Param(2), "r", "retries",
|
||||||
|
"\tnumber retries send ebus command (default: 2)\n",
|
||||||
|
Appl::type_int, Appl::opt_mandatory);
|
||||||
|
|
||||||
A.addItem("p_ebusconfdir", Appl::Param("/etc/ebus-daemon"), "e", "ebusconfdir",
|
A.addItem("p_ebusconfdir", Appl::Param("/etc/ebus-daemon"), "e", "ebusconfdir",
|
||||||
"directory for ebus configuration (default: /etc/ebus-daemon)\n",
|
"directory for ebus configuration (default: /etc/ebus-daemon)\n",
|
||||||
Appl::type_string, Appl::opt_mandatory);
|
Appl::type_string, Appl::opt_mandatory);
|
||||||
|
|||||||
Reference in New Issue
Block a user