ebusd: main.cpp renamed into ebusd.cpp; daemon option 'aquiretime' added.
This commit is contained in:
+1
-1
@@ -4,7 +4,7 @@ AC_INIT([ebusd], [0.5.0], [ebusd@liwest.at], [ebusd], [https://github.com/yuhu-/
|
||||
AC_PROG_CXX
|
||||
|
||||
AC_CONFIG_AUX_DIR([build])
|
||||
AC_CONFIG_SRCDIR([src/ebusd/main.cpp])
|
||||
AC_CONFIG_SRCDIR([src/ebusd/ebusd.cpp])
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
AC_CONFIG_FILES([Makefile
|
||||
src/lib/ebus/Makefile
|
||||
|
||||
@@ -15,7 +15,7 @@ ebusd_SOURCES = message.h \
|
||||
ebusloop.h \
|
||||
baseloop.cpp \
|
||||
baseloop.h \
|
||||
main.cpp
|
||||
ebusd.cpp
|
||||
|
||||
ebusd_LDADD = $(top_srcdir)/src/lib/utils/libutils.a \
|
||||
$(top_srcdir)/src/lib/ebus/libebus.a \
|
||||
|
||||
@@ -60,7 +60,11 @@ void define_args()
|
||||
Appl::type_int, Appl::opt_mandatory);
|
||||
|
||||
A.addItem("p_recvtimeout", Appl::Param(15000), "", "recvtimeout",
|
||||
"receive timeout in 'us' (15000)\n",
|
||||
"receive timeout in 'us' (15000)",
|
||||
Appl::type_long, Appl::opt_mandatory);
|
||||
|
||||
A.addItem("p_acquiretime", Appl::Param(4200), "", "acquiretime",
|
||||
"waiting time for bus acquire in 'us' (4200)\n",
|
||||
Appl::type_long, Appl::opt_mandatory);
|
||||
|
||||
A.addItem("p_pollinterval", Appl::Param(5), "", "pollinterval",
|
||||
@@ -45,6 +45,8 @@ EBusLoop::EBusLoop(Commands* commands)
|
||||
m_sendRetries = A.getParam<int>("p_sendretries");
|
||||
|
||||
m_lockRetries = A.getParam<int>("p_lockretries");
|
||||
|
||||
m_acquireTime = A.getParam<long>("p_acquiretime");
|
||||
}
|
||||
|
||||
EBusLoop::~EBusLoop()
|
||||
@@ -111,18 +113,18 @@ void* EBusLoop::run()
|
||||
busCommand->setResult(std::string(), RESULT_OK);
|
||||
}
|
||||
else {
|
||||
sendRetries = 0;
|
||||
L.log(bus, event, " send retry failed", sendRetries);
|
||||
|
||||
if (busCommand->isPoll() == true)
|
||||
delete m_sendBuffer.remove();
|
||||
else
|
||||
busCommand->sendSignal();
|
||||
|
||||
sendRetries = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
sendRetries = 0;
|
||||
|
||||
if (busCommand->isPoll() == true) {
|
||||
m_commands->storePolData(busCommand->getMessageStr().c_str()); // TODO use getResult()
|
||||
delete busCommand;
|
||||
@@ -138,14 +140,14 @@ void* EBusLoop::run()
|
||||
L.log(bus, trace, " acquire bus failed");
|
||||
|
||||
if (lockRetries >= m_lockRetries) {
|
||||
lockRetries = 0;
|
||||
L.log(bus, event, " lock bus failed");
|
||||
|
||||
BusCommand* busCommand = m_sendBuffer.remove();
|
||||
if (busCommand->isPoll() == true)
|
||||
delete busCommand;
|
||||
else
|
||||
busCommand->sendSignal();
|
||||
|
||||
lockRetries = 0;
|
||||
}
|
||||
else {
|
||||
lockRetries++;
|
||||
@@ -294,6 +296,9 @@ int EBusLoop::acquireBus()
|
||||
return RESULT_ERR_SEND;
|
||||
}
|
||||
|
||||
// wait ~4200 usec for receive
|
||||
usleep(m_acquireTime);
|
||||
|
||||
// receive 1 byte - must be QQ
|
||||
numRecv = m_port->recv(0);
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ private:
|
||||
long m_recvTimeout;
|
||||
int m_sendRetries;
|
||||
int m_lockRetries;
|
||||
long m_acquireTime;
|
||||
|
||||
unsigned char fetchByte();
|
||||
void collectCycData(const int numRecv);
|
||||
|
||||
Reference in New Issue
Block a user