diff --git a/src/ebusd/baseloop.cpp b/src/ebusd/baseloop.cpp index c23607fd..bf97f169 100644 --- a/src/ebusd/baseloop.cpp +++ b/src/ebusd/baseloop.cpp @@ -149,7 +149,7 @@ std::string BaseLoop::decodeMessage(const std::string& data) } std::string ebusCommand(A.getParam("p_address")); - ebusCommand += m_commands->getEbusCommand(index); + ebusCommand += m_commands->getEbusCommand(index, false); std::transform(ebusCommand.begin(), ebusCommand.end(), ebusCommand.begin(), tolower); BusCommand* busCommand = new BusCommand(ebusCommand, false); @@ -190,7 +190,7 @@ std::string BaseLoop::decodeMessage(const std::string& data) if (index >= 0) { std::string ebusCommand(A.getParam("p_address")); - ebusCommand += m_commands->getEbusCommand(index); + ebusCommand += m_commands->getEbusCommand(index, false); // encode data Command* command = new Command(index, (*m_commands)[index], cmd[3]); diff --git a/src/ebusd/ebusloop.cpp b/src/ebusd/ebusloop.cpp index a2881117..79f0d778 100644 --- a/src/ebusd/ebusloop.cpp +++ b/src/ebusd/ebusloop.cpp @@ -267,7 +267,7 @@ void EBusLoop::addPollCommand() L.log(bus, event, " polling [%4d] %s", index, tmp.c_str()); std::string ebusCommand(A.getParam("p_address")); - ebusCommand += m_commands->getEbusCommand(index); + ebusCommand += m_commands->getEbusCommand(index, false); std::transform(ebusCommand.begin(), ebusCommand.end(), ebusCommand.begin(), tolower); BusCommand* busCommand = new BusCommand(ebusCommand, true); diff --git a/src/lib/ebus/commands.cpp b/src/lib/ebus/commands.cpp index 97146ce2..cee9ad91 100644 --- a/src/lib/ebus/commands.cpp +++ b/src/lib/ebus/commands.cpp @@ -127,15 +127,20 @@ int Commands::findCommand(const std::string& data) const return -1; } -std::string Commands::getEbusCommand(const int index) const +std::string Commands::getEbusCommand(const int index, const bool cycle) const { cmd_t command = m_cmdDB.at(index); - std::string cmd(command[5]); - cmd += command[6]; + std::string cmd; std::stringstream sstr; + + if (cycle == true) + cmd += command[4]; // QQ + + cmd += command[5]; // ZZ + cmd += command[6]; // PBSB sstr << std::setw(2) << std::hex << std::setfill('0') << command[7]; - cmd += sstr.str(); - cmd += command[8]; + cmd += sstr.str(); // NN + cmd += command[8]; // Dx return cmd; } @@ -158,7 +163,7 @@ int Commands::storeCycData(const std::string& data) const // walk through commands for (; iter != m_cycDB.end(); iter++) { - std::string command = getEbusCommand(iter->first); + std::string command = getEbusCommand(iter->first, true); // skip wrong search string length if (command.length() > search.length()) @@ -211,7 +216,7 @@ void Commands::storePolData(const std::string& data) const // walk through commands for (; iter != m_polDB.end(); iter++) { - std::string command = getEbusCommand(iter->first); + std::string command = getEbusCommand(iter->first, false); // skip wrong search string length if (command.length() > search.length()) diff --git a/src/lib/ebus/commands.h b/src/lib/ebus/commands.h index 121587a0..09c96a89 100644 --- a/src/lib/ebus/commands.h +++ b/src/lib/ebus/commands.h @@ -56,7 +56,7 @@ public: std::string getCmdType(const int index) const { return std::string(m_cmdDB.at(index)[0]); } std::string getEbusType(const int index) const { return std::string(m_cmdDB.at(index)[4]); } - std::string getEbusCommand(const int index) const; + std::string getEbusCommand(const int index, const bool cycle) const; int storeCycData(const std::string& data) const; std::string getCycData(int index) const;