some cosmetics.
This commit is contained in:
+1
-1
@@ -91,7 +91,7 @@ std::string BaseLoop::decodeMessage(const std::string& data)
|
||||
ebusCommand += m_commands->getEbusCommand(index);
|
||||
std::transform(ebusCommand.begin(), ebusCommand.end(), ebusCommand.begin(), tolower);
|
||||
|
||||
L.log(bas, event, " type: %s msg: %s", type.c_str(), ebusCommand.c_str());
|
||||
L.log(bas, trace, " type: %s msg: %s", type.c_str(), ebusCommand.c_str());
|
||||
// send busCommand
|
||||
m_ebusloop->addBusCommand(new BusCommand(type, ebusCommand));
|
||||
BusCommand* busCommand = m_ebusloop->getBusCommand();
|
||||
|
||||
+13
-10
@@ -28,13 +28,13 @@ extern Appl& A;
|
||||
EBusLoop::EBusLoop() : m_stop(false)
|
||||
{
|
||||
m_deviceName = A.getParam<const char*>("p_device");
|
||||
|
||||
|
||||
m_bus = new Bus(m_deviceName,
|
||||
A.getParam<bool>("p_nodevicecheck"),
|
||||
A.getParam<const char*>("p_dumpfile"),
|
||||
A.getParam<long>("p_dumpsize"),
|
||||
A.getParam<bool>("p_dump"));
|
||||
|
||||
|
||||
m_bus->connect();
|
||||
|
||||
if (m_bus->isConnected() == false)
|
||||
@@ -44,10 +44,10 @@ EBusLoop::EBusLoop() : m_stop(false)
|
||||
EBusLoop::~EBusLoop()
|
||||
{
|
||||
m_bus->disconnect();
|
||||
|
||||
|
||||
if (m_bus->isConnected() == true)
|
||||
L.log(bus, error, "error during disconnect.");
|
||||
|
||||
|
||||
delete m_bus;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ void* EBusLoop::run()
|
||||
{
|
||||
int busResult;
|
||||
bool busCommandActive = false;
|
||||
|
||||
|
||||
for (;;) {
|
||||
if (m_bus->isConnected() == true) {
|
||||
|
||||
@@ -72,13 +72,16 @@ void* EBusLoop::run()
|
||||
// add new bus command to send
|
||||
if (busResult == 4 && busCommandActive == false && m_sendBuffer.size() != 0) {
|
||||
BusCommand* busCommand = m_sendBuffer.remove();
|
||||
L.log(bus, debug, " type: %s msg: %s",
|
||||
busCommand->getType().c_str(), busCommand->getCommand().c_str());
|
||||
m_bus->addCommand(busCommand);
|
||||
L.log(bus, debug, " addCommand success");
|
||||
busCommandActive = true;
|
||||
}
|
||||
|
||||
// send bus command
|
||||
if (busResult == 1 && busCommandActive == true) {
|
||||
L.log(bus, event, " getBus success");
|
||||
L.log(bus, trace, " getBus success");
|
||||
m_bus->sendCommand();
|
||||
BusCommand* busCommand = m_bus->recvCommand();
|
||||
L.log(bus, trace, " %s", busCommand->getResult().c_str());
|
||||
@@ -87,21 +90,21 @@ void* EBusLoop::run()
|
||||
}
|
||||
|
||||
if (busResult == 0)
|
||||
L.log(bus, event, " getBus failure");
|
||||
L.log(bus, trace, " getBus failure");
|
||||
|
||||
if (busResult == -1)
|
||||
L.log(bus, event, " getBus error");
|
||||
|
||||
|
||||
} else {
|
||||
sleep(10);
|
||||
m_bus->connect();
|
||||
|
||||
|
||||
if (m_bus->isConnected() == false)
|
||||
L.log(bus, error, "can't open %s", m_deviceName.c_str());
|
||||
}
|
||||
|
||||
if (m_stop == true) {
|
||||
m_bus->disconnect();
|
||||
m_bus->disconnect();
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
+16
-16
@@ -38,7 +38,7 @@ void Connection::addResult(Message message)
|
||||
void* Connection::run()
|
||||
{
|
||||
m_running = true;
|
||||
|
||||
|
||||
int maxfd;
|
||||
fd_set checkfds;
|
||||
struct timeval timeout;
|
||||
@@ -46,7 +46,7 @@ void* Connection::run()
|
||||
FD_ZERO(&checkfds);
|
||||
FD_SET(m_notify.notifyFD(), &checkfds);
|
||||
FD_SET(m_socket->getFD(), &checkfds);
|
||||
|
||||
|
||||
(m_notify.notifyFD() > m_socket->getFD()) ?
|
||||
(maxfd = m_notify.notifyFD()) : (maxfd = m_socket->getFD());
|
||||
|
||||
@@ -56,7 +56,7 @@ void* Connection::run()
|
||||
|
||||
// set select timeout 10 secs
|
||||
timeout.tv_sec = 10;
|
||||
timeout.tv_usec = 0;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
// set readfds to inital checkfds
|
||||
readfds = checkfds;
|
||||
@@ -65,7 +65,7 @@ void* Connection::run()
|
||||
if (ret == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// new data from notify
|
||||
if (FD_ISSET(m_notify.notifyFD(), &readfds))
|
||||
break;
|
||||
@@ -79,7 +79,7 @@ void* Connection::run()
|
||||
datalen = m_socket->recv(data, sizeof(data)-1);
|
||||
else
|
||||
break;
|
||||
|
||||
|
||||
// removed closed socket
|
||||
if (datalen <= 0 || strncasecmp(data, "quit", 4) == 0)
|
||||
break;
|
||||
@@ -94,12 +94,12 @@ void* Connection::run()
|
||||
|
||||
L.log(net, debug, "[%08x] result added", getID());
|
||||
std::string result(message->getData());
|
||||
|
||||
|
||||
if (m_socket->isValid() == true)
|
||||
m_socket->send(result.c_str(), result.size());
|
||||
else
|
||||
break;
|
||||
|
||||
break;
|
||||
|
||||
delete message;
|
||||
|
||||
}
|
||||
@@ -108,7 +108,7 @@ void* Connection::run()
|
||||
|
||||
delete m_socket;
|
||||
m_running = false;
|
||||
L.log(net, event, "[%08x] connection closed - active connections: %d", getID(), m_count);
|
||||
L.log(net, trace, "[%08x] connection closed - active connections: %d", getID(), m_count);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -137,10 +137,10 @@ Network::~Network()
|
||||
connection->join();
|
||||
delete connection;
|
||||
}
|
||||
|
||||
|
||||
if (m_running == true)
|
||||
stop();
|
||||
|
||||
|
||||
delete m_Listener;
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ void* Network::run()
|
||||
FD_ZERO(&checkfds);
|
||||
FD_SET(m_notify.notifyFD(), &checkfds);
|
||||
FD_SET(m_Listener->getFD(), &checkfds);
|
||||
|
||||
|
||||
(m_notify.notifyFD() > m_Listener->getFD()) ?
|
||||
(maxfd = m_notify.notifyFD()) : (maxfd = m_Listener->getFD());
|
||||
|
||||
@@ -168,7 +168,7 @@ void* Network::run()
|
||||
|
||||
// set select timeout 1 secs
|
||||
timeout.tv_sec = 1;
|
||||
timeout.tv_usec = 0;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
// set readfds to inital checkfds
|
||||
readfds = checkfds;
|
||||
@@ -178,7 +178,7 @@ void* Network::run()
|
||||
cleanConnections();
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// new data from notify
|
||||
if (FD_ISSET(m_notify.notifyFD(), &readfds)) {
|
||||
m_running = false;
|
||||
@@ -190,14 +190,14 @@ void* Network::run()
|
||||
TCPSocket* socket = m_Listener->newSocket();
|
||||
if (socket == NULL)
|
||||
continue;
|
||||
|
||||
|
||||
Connection* connection = new Connection(socket, m_queue);
|
||||
if (connection == NULL)
|
||||
continue;
|
||||
|
||||
connection->start("netConnection");
|
||||
m_connections.push_back(connection);
|
||||
L.log(net, event, "[%08x] connection opened %s", connection->getID(), socket->getIP().c_str());
|
||||
L.log(net, trace, "[%08x] connection opened %s", connection->getID(), socket->getIP().c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user