Merge branch 'john30-master'
This commit is contained in:
+6
-6
@@ -151,7 +151,7 @@ std::string BaseLoop::decodeMessage(const std::string& data)
|
|||||||
ebusCommand += m_commands->getEbusCommand(index);
|
ebusCommand += m_commands->getEbusCommand(index);
|
||||||
std::transform(ebusCommand.begin(), ebusCommand.end(), ebusCommand.begin(), tolower);
|
std::transform(ebusCommand.begin(), ebusCommand.end(), ebusCommand.begin(), tolower);
|
||||||
|
|
||||||
BusCommand* busCommand = new BusCommand(ebusCommand);
|
BusCommand* busCommand = new BusCommand(ebusCommand, false);
|
||||||
L.log(bas, trace, " msg: %s", ebusCommand.c_str());
|
L.log(bas, trace, " msg: %s", ebusCommand.c_str());
|
||||||
// send busCommand
|
// send busCommand
|
||||||
m_ebusloop->addBusCommand(busCommand);
|
m_ebusloop->addBusCommand(busCommand);
|
||||||
@@ -159,7 +159,7 @@ std::string BaseLoop::decodeMessage(const std::string& data)
|
|||||||
|
|
||||||
if (!busCommand->isErrorResult()) {
|
if (!busCommand->isErrorResult()) {
|
||||||
// decode data
|
// decode data
|
||||||
Command* command = new Command(index, (*m_commands)[index], busCommand->getResult());
|
Command* command = new Command(index, (*m_commands)[index], busCommand->getMessageStr()); // TODO use getCommand()+getResult()
|
||||||
|
|
||||||
// return result
|
// return result
|
||||||
result << command->calcResult(cmd);
|
result << command->calcResult(cmd);
|
||||||
@@ -204,7 +204,7 @@ std::string BaseLoop::decodeMessage(const std::string& data)
|
|||||||
|
|
||||||
std::transform(ebusCommand.begin(), ebusCommand.end(), ebusCommand.begin(), tolower);
|
std::transform(ebusCommand.begin(), ebusCommand.end(), ebusCommand.begin(), tolower);
|
||||||
|
|
||||||
BusCommand* busCommand = new BusCommand(ebusCommand);
|
BusCommand* busCommand = new BusCommand(ebusCommand, false);
|
||||||
L.log(bas, event, " msg: %s", ebusCommand.c_str());
|
L.log(bas, event, " msg: %s", ebusCommand.c_str());
|
||||||
// send busCommand
|
// send busCommand
|
||||||
m_ebusloop->addBusCommand(busCommand);
|
m_ebusloop->addBusCommand(busCommand);
|
||||||
@@ -214,7 +214,7 @@ std::string BaseLoop::decodeMessage(const std::string& data)
|
|||||||
// decode result
|
// decode result
|
||||||
if (busCommand->getType()==broadcast)
|
if (busCommand->getType()==broadcast)
|
||||||
result << "done";
|
result << "done";
|
||||||
else if (busCommand->getResult().substr(busCommand->getResult().length()-8) == "00000000")
|
else if (busCommand->getMessageStr().substr(busCommand->getMessageStr().length()-8) == "00000000") // TODO use getResult()
|
||||||
result << "done";
|
result << "done";
|
||||||
else
|
else
|
||||||
result << "error";
|
result << "error";
|
||||||
@@ -273,7 +273,7 @@ std::string BaseLoop::decodeMessage(const std::string& data)
|
|||||||
ebusCommand += cmd[1];
|
ebusCommand += cmd[1];
|
||||||
std::transform(ebusCommand.begin(), ebusCommand.end(), ebusCommand.begin(), tolower);
|
std::transform(ebusCommand.begin(), ebusCommand.end(), ebusCommand.begin(), tolower);
|
||||||
|
|
||||||
BusCommand* busCommand = new BusCommand(ebusCommand);
|
BusCommand* busCommand = new BusCommand(ebusCommand, false);
|
||||||
L.log(bas, trace, " msg: %s", ebusCommand.c_str());
|
L.log(bas, trace, " msg: %s", ebusCommand.c_str());
|
||||||
// send busCommand
|
// send busCommand
|
||||||
m_ebusloop->addBusCommand(busCommand);
|
m_ebusloop->addBusCommand(busCommand);
|
||||||
@@ -283,7 +283,7 @@ std::string BaseLoop::decodeMessage(const std::string& data)
|
|||||||
L.log(bas, error, " %s", busCommand->getResultCodeCStr());
|
L.log(bas, error, " %s", busCommand->getResultCodeCStr());
|
||||||
result << busCommand->getResultCodeCStr();
|
result << busCommand->getResultCodeCStr();
|
||||||
} else {
|
} else {
|
||||||
result << busCommand->getResult();
|
result << busCommand->getMessageStr(); // TODO use getCommand()+getResult()
|
||||||
}
|
}
|
||||||
|
|
||||||
delete busCommand;
|
delete busCommand;
|
||||||
|
|||||||
+15
-10
@@ -80,15 +80,15 @@ void* EBusLoop::run()
|
|||||||
|
|
||||||
// new cyc message arrived
|
// new cyc message arrived
|
||||||
if (busResult == RESULT_SYN || busResult == RESULT_BUS_LOCKED) {
|
if (busResult == RESULT_SYN || busResult == RESULT_BUS_LOCKED) {
|
||||||
std::string data = m_bus->getCycData();
|
SymbolString data = m_bus->getCycData();
|
||||||
|
|
||||||
if (data.size() == 0 && m_logAutoSyn == true)
|
if (data.size() == 0 && m_logAutoSyn == true)
|
||||||
L.log(bus, trace, "%s", "aa");
|
L.log(bus, trace, "aa");
|
||||||
|
|
||||||
if (data.size() != 0) {
|
if (data.size() != 0) {
|
||||||
L.log(bus, trace, "%s", data.c_str());
|
L.log(bus, trace, "%s", data.getDataStr().c_str());
|
||||||
|
|
||||||
int index = m_commands->storeCycData(data);
|
int index = m_commands->storeCycData(data.getDataStr());
|
||||||
|
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
L.log(bus, debug, " command not found");
|
L.log(bus, debug, " command not found");
|
||||||
@@ -115,7 +115,7 @@ void* EBusLoop::run()
|
|||||||
// add new bus command to send
|
// add new bus command to send
|
||||||
if (busResult == RESULT_SYN && busCommandActive == false && m_sendBuffer.size() != 0) {
|
if (busResult == RESULT_SYN && busCommandActive == false && m_sendBuffer.size() != 0) {
|
||||||
BusCommand* busCommand = m_sendBuffer.remove();
|
BusCommand* busCommand = m_sendBuffer.remove();
|
||||||
L.log(bus, debug, " msg: %s", busCommand->getCommand().c_str());
|
L.log(bus, debug, " msg: %s", busCommand->getCommand().getDataStr(true).c_str());
|
||||||
m_bus->addCommand(busCommand);
|
m_bus->addCommand(busCommand);
|
||||||
L.log(bus, debug, " addCommand success");
|
L.log(bus, debug, " addCommand success");
|
||||||
busCommandActive = true;
|
busCommandActive = true;
|
||||||
@@ -148,7 +148,7 @@ void* EBusLoop::run()
|
|||||||
ebusCommand += m_commands->getEbusCommand(index);
|
ebusCommand += m_commands->getEbusCommand(index);
|
||||||
std::transform(ebusCommand.begin(), ebusCommand.end(), ebusCommand.begin(), tolower);
|
std::transform(ebusCommand.begin(), ebusCommand.end(), ebusCommand.begin(), tolower);
|
||||||
|
|
||||||
BusCommand* busCommand = new BusCommand(ebusCommand);
|
BusCommand* busCommand = new BusCommand(ebusCommand, true);
|
||||||
L.log(bus, trace, " msg: %s", ebusCommand.c_str());
|
L.log(bus, trace, " msg: %s", ebusCommand.c_str());
|
||||||
|
|
||||||
m_bus->addCommand(busCommand);
|
m_bus->addCommand(busCommand);
|
||||||
@@ -166,7 +166,7 @@ void* EBusLoop::run()
|
|||||||
L.log(bus, trace, " getBus success");
|
L.log(bus, trace, " getBus success");
|
||||||
lookbusretries = 0;
|
lookbusretries = 0;
|
||||||
BusCommand* busCommand = m_bus->sendCommand();
|
BusCommand* busCommand = m_bus->sendCommand();
|
||||||
L.log(bus, trace, " %s", busCommand->getResult().c_str());
|
L.log(bus, trace, " %s", busCommand->getMessageStr().c_str());
|
||||||
|
|
||||||
if (busCommand->isErrorResult() == true && retries < m_retries) {
|
if (busCommand->isErrorResult() == true && retries < m_retries) {
|
||||||
retries++;
|
retries++;
|
||||||
@@ -175,10 +175,10 @@ void* EBusLoop::run()
|
|||||||
m_bus->addCommand(busCommand);
|
m_bus->addCommand(busCommand);
|
||||||
} else {
|
} else {
|
||||||
retries = 0;
|
retries = 0;
|
||||||
if (pollCommandActive == true) {
|
if (busCommand->isPoll() == true) {
|
||||||
// only save correct results
|
// only save correct results
|
||||||
if (busCommand->isErrorResult() == false)
|
if (busCommand->isErrorResult() == false)
|
||||||
m_commands->storePolData(busCommand->getResult().c_str());
|
m_commands->storePolData(busCommand->getMessageStr().c_str()); // TODO use getResult()
|
||||||
|
|
||||||
delete busCommand;
|
delete busCommand;
|
||||||
pollCommandActive = false;
|
pollCommandActive = false;
|
||||||
@@ -198,7 +198,12 @@ void* EBusLoop::run()
|
|||||||
L.log(bus, trace, " getBus failure");
|
L.log(bus, trace, " getBus failure");
|
||||||
if (lookbusretries >= m_lookbusretries) {
|
if (lookbusretries >= m_lookbusretries) {
|
||||||
L.log(bus, event, " getBus failed - command deleted");
|
L.log(bus, event, " getBus failed - command deleted");
|
||||||
m_bus->delCommand();
|
BusCommand* busCommand = m_bus->delCommand();
|
||||||
|
if (busCommand->isPoll() == true) {
|
||||||
|
delete busCommand;
|
||||||
|
} else {
|
||||||
|
busCommand->sendSignal();
|
||||||
|
}
|
||||||
lookbusretries = 0;
|
lookbusretries = 0;
|
||||||
busCommandActive = false;
|
busCommandActive = false;
|
||||||
pollCommandActive = false;
|
pollCommandActive = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user