Merge branch 'john30-master'
This commit is contained in:
+25
-23
@@ -147,17 +147,17 @@ std::string BaseLoop::decodeMessage(const std::string& data)
|
||||
break;
|
||||
}
|
||||
|
||||
std::string type = m_commands->getEbusType(index);
|
||||
std::string ebusCommand(A.getParam<const char*>("p_address"));
|
||||
ebusCommand += m_commands->getEbusCommand(index);
|
||||
std::transform(ebusCommand.begin(), ebusCommand.end(), ebusCommand.begin(), tolower);
|
||||
|
||||
L.log(bas, trace, " type: %s msg: %s", type.c_str(), ebusCommand.c_str());
|
||||
BusCommand* busCommand = new BusCommand(ebusCommand);
|
||||
L.log(bas, trace, " type: %s msg: %s", busCommand->getTypeCStr(), ebusCommand.c_str());
|
||||
// send busCommand
|
||||
m_ebusloop->addBusCommand(new BusCommand(type, ebusCommand));
|
||||
BusCommand* busCommand = m_ebusloop->getBusCommand();
|
||||
m_ebusloop->addBusCommand(busCommand);
|
||||
busCommand = m_ebusloop->getBusCommand();
|
||||
|
||||
if (busCommand->getResult().c_str()[0] != '-') {
|
||||
if (!busCommand->isErrorResult()) {
|
||||
// decode data
|
||||
Command* command = new Command(index, (*m_commands)[index], busCommand->getResult());
|
||||
|
||||
@@ -166,8 +166,8 @@ std::string BaseLoop::decodeMessage(const std::string& data)
|
||||
|
||||
delete command;
|
||||
} else {
|
||||
L.log(bas, error, " %s", busCommand->getResult().c_str());
|
||||
result << busCommand->getResult();
|
||||
L.log(bas, error, " %s", busCommand->getResultCodeCStr());
|
||||
result << busCommand->getResultCodeCStr();
|
||||
}
|
||||
|
||||
delete busCommand;
|
||||
@@ -188,7 +188,6 @@ std::string BaseLoop::decodeMessage(const std::string& data)
|
||||
|
||||
if (index >= 0) {
|
||||
|
||||
std::string type = m_commands->getEbusType(index);
|
||||
std::string ebusCommand(A.getParam<const char*>("p_address"));
|
||||
ebusCommand += m_commands->getEbusCommand(index);
|
||||
|
||||
@@ -205,14 +204,15 @@ std::string BaseLoop::decodeMessage(const std::string& data)
|
||||
|
||||
std::transform(ebusCommand.begin(), ebusCommand.end(), ebusCommand.begin(), tolower);
|
||||
|
||||
L.log(bas, event, " type: %s msg: %s", type.c_str(), ebusCommand.c_str());
|
||||
BusCommand* busCommand = new BusCommand(ebusCommand);
|
||||
L.log(bas, event, " type: %s msg: %s", busCommand->getTypeCStr(), ebusCommand.c_str());
|
||||
// send busCommand
|
||||
m_ebusloop->addBusCommand(new BusCommand(type, ebusCommand));
|
||||
BusCommand* busCommand = m_ebusloop->getBusCommand();
|
||||
m_ebusloop->addBusCommand(busCommand);
|
||||
busCommand = m_ebusloop->getBusCommand();
|
||||
|
||||
if (busCommand->getResult().c_str()[0] != '-') {
|
||||
if (!busCommand->isErrorResult()) {
|
||||
// decode result
|
||||
if (strcasecmp(type.c_str(), "BC") == 0)
|
||||
if (busCommand->getType()==broadcast)
|
||||
result << "done";
|
||||
else if (busCommand->getResult().substr(busCommand->getResult().length()-8) == "00000000")
|
||||
result << "done";
|
||||
@@ -220,8 +220,8 @@ std::string BaseLoop::decodeMessage(const std::string& data)
|
||||
result << "error";
|
||||
|
||||
} else {
|
||||
L.log(bas, error, " %s", busCommand->getResult().c_str());
|
||||
result << busCommand->getResult();
|
||||
L.log(bas, error, " %s", busCommand->getResultCodeCStr());
|
||||
result << busCommand->getResultCodeCStr();
|
||||
}
|
||||
|
||||
delete busCommand;
|
||||
@@ -271,21 +271,23 @@ std::string BaseLoop::decodeMessage(const std::string& data)
|
||||
|| (strcasecmp(cmd[1].c_str(), "MM") == 0)
|
||||
|| (strcasecmp(cmd[1].c_str(), "BC") == 0)) {
|
||||
|
||||
std::string type = cmd[1];
|
||||
std::string ebusCommand(A.getParam<const char*>("p_address"));
|
||||
cmd[2].erase(std::remove_if(cmd[2].begin(), cmd[2].end(), isspace), cmd[2].end());
|
||||
ebusCommand += cmd[2];
|
||||
std::transform(ebusCommand.begin(), ebusCommand.end(), ebusCommand.begin(), tolower);
|
||||
|
||||
L.log(bas, trace, " type: %s msg: %s", type.c_str(), ebusCommand.c_str());
|
||||
BusCommand* busCommand = new BusCommand(ebusCommand);
|
||||
L.log(bas, trace, " type: %s msg: %s", busCommand->getTypeCStr(), ebusCommand.c_str());
|
||||
// send busCommand
|
||||
m_ebusloop->addBusCommand(new BusCommand(type, ebusCommand));
|
||||
BusCommand* busCommand = m_ebusloop->getBusCommand();
|
||||
m_ebusloop->addBusCommand(busCommand);
|
||||
busCommand = m_ebusloop->getBusCommand();
|
||||
|
||||
if (busCommand->getResult().c_str()[0] == '-')
|
||||
L.log(bas, error, " %s", busCommand->getResult().c_str());
|
||||
|
||||
result << busCommand->getResult();
|
||||
if (busCommand->isErrorResult()) {
|
||||
L.log(bas, error, " %s", busCommand->getResultCodeCStr());
|
||||
result << busCommand->getResultCodeCStr();
|
||||
} else {
|
||||
result << busCommand->getResult();
|
||||
}
|
||||
|
||||
delete busCommand;
|
||||
|
||||
|
||||
+12
-13
@@ -75,7 +75,7 @@ void* EBusLoop::run()
|
||||
busResult = m_bus->proceed();
|
||||
|
||||
// new cyc message arrived
|
||||
if (busResult == 2) {
|
||||
if (busResult == RESULT_SYN) {
|
||||
std::string data = m_bus->getCycData();
|
||||
L.log(bus, trace, "%s", data.c_str());
|
||||
|
||||
@@ -101,10 +101,10 @@ void* EBusLoop::run()
|
||||
}
|
||||
|
||||
// add new bus command to send
|
||||
if (busResult == 4 && busCommandActive == false && m_sendBuffer.size() != 0) {
|
||||
if (busResult == RESULT_AUTO_SYN && 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());
|
||||
busCommand->getTypeCStr(), busCommand->getCommand().c_str());
|
||||
m_bus->addCommand(busCommand);
|
||||
L.log(bus, debug, " addCommand success");
|
||||
busCommandActive = true;
|
||||
@@ -117,7 +117,7 @@ void* EBusLoop::run()
|
||||
pollDelta = difftime(end, start);
|
||||
|
||||
// add new polling command to send
|
||||
if (busResult == 4 && busCommandActive == false && pollDelta >= m_pollInterval) {
|
||||
if (busResult == RESULT_AUTO_SYN && busCommandActive == false && pollDelta >= m_pollInterval) {
|
||||
L.log(bus, trace, "polling Intervall reached");
|
||||
|
||||
int index = m_commands->nextPolCommand();
|
||||
@@ -133,14 +133,13 @@ void* EBusLoop::run()
|
||||
tmp += (*m_commands)[index][2];
|
||||
L.log(bus, event, " polling [%d] %s", index, tmp.c_str());
|
||||
|
||||
std::string type = m_commands->getEbusType(index);
|
||||
std::string ebusCommand(A.getParam<const char*>("p_address"));
|
||||
ebusCommand += m_commands->getEbusCommand(index);
|
||||
std::transform(ebusCommand.begin(), ebusCommand.end(), ebusCommand.begin(), tolower);
|
||||
|
||||
L.log(bus, trace, " type: %s msg: %s", type.c_str(), ebusCommand.c_str());
|
||||
BusCommand* busCommand = new BusCommand(ebusCommand);
|
||||
L.log(bus, trace, " type: %s msg: %s", busCommand->getTypeCStr(), ebusCommand.c_str());
|
||||
|
||||
BusCommand* busCommand = new BusCommand(type, ebusCommand);
|
||||
m_bus->addCommand(busCommand);
|
||||
L.log(bus, debug, " addCommand success");
|
||||
busCommandActive = true;
|
||||
@@ -152,23 +151,23 @@ void* EBusLoop::run()
|
||||
}
|
||||
|
||||
// send bus command
|
||||
if (busResult == 1 && busCommandActive == true) {
|
||||
if (busResult == RESULT_BUS_ACQUIRED && busCommandActive == true) {
|
||||
L.log(bus, trace, " getBus success");
|
||||
lookbusretries = 0;
|
||||
m_bus->sendCommand();
|
||||
BusCommand* busCommand = m_bus->recvCommand();
|
||||
L.log(bus, trace, " %s", busCommand->getResult().c_str());
|
||||
|
||||
if (busCommand->getResult().c_str()[0] == '-' && retries < m_retries) {
|
||||
if (busCommand->isErrorResult() && retries < m_retries) {
|
||||
retries++;
|
||||
L.log(bus, trace, " retry number: %d", retries);
|
||||
busCommand->setResult(std::string());
|
||||
busCommand->setResult(std::string(), RESULT_OK);
|
||||
m_bus->addCommand(busCommand);
|
||||
} else {
|
||||
retries = 0;
|
||||
if (pollCommandActive == true) {
|
||||
// only save correct results
|
||||
if (busCommand->getResult().c_str()[0] != '-')
|
||||
if (!busCommand->isErrorResult())
|
||||
m_commands->storePolData(busCommand->getResult().c_str());
|
||||
|
||||
delete busCommand;
|
||||
@@ -181,7 +180,7 @@ void* EBusLoop::run()
|
||||
}
|
||||
}
|
||||
|
||||
if (busResult == 0) {
|
||||
if (busResult == RESULT_ERR_BUS_LOST) {
|
||||
L.log(bus, trace, " getBus failure");
|
||||
if (lookbusretries >= m_lookbusretries) {
|
||||
L.log(bus, event, " getBus failed - command deleted");
|
||||
@@ -192,7 +191,7 @@ void* EBusLoop::run()
|
||||
}
|
||||
}
|
||||
|
||||
if (busResult == -1)
|
||||
if (busResult == RESULT_ERR_SEND)
|
||||
L.log(bus, event, " getBus error");
|
||||
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user