class BaseLoop: daemon command SET implemented.
This commit is contained in:
@@ -95,6 +95,7 @@ get;vwxhw;TankTemp;Speichertemperatur IST;MS;08;B509;3;0D0000;2;temp;sd;1,2;d2c;
|
|||||||
get;vwxhw;TankTypePipe;Speichertyp ist Rohr;MS;25;B509;3;0DCD01;1;-;sd;1;uch;-;-;-;-;;;;;;;;;;;;;;;;;;;;;;;;
|
get;vwxhw;TankTypePipe;Speichertyp ist Rohr;MS;25;B509;3;0DCD01;1;-;sd;1;uch;-;-;-;-;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
get;vwxmk;CoolingOperatingMode;Kühlung Betriebsart;MS;50;B509;3;0D8C01;1;-;sd;1;uch;-;-;-;-;;;;;;;;;;;;;;;;;;;;;;;;
|
get;vwxmk;CoolingOperatingMode;Kühlung Betriebsart;MS;50;B509;3;0D8C01;1;-;sd;1;uch;-;-;-;-;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
get;vwxmk;DesiredTemp;Solltemperatur;MS;50;B509;3;0D3200;1;-;sd;1;d1c;1.0;°C;-;-;;;;;;;;;;;;;;;;;;;;;;;;
|
get;vwxmk;DesiredTemp;Solltemperatur;MS;50;B509;3;0D3200;1;-;sd;1;d1c;1.0;°C;-;-;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
set;vwxmk;DesiredTemp;Solltemperatur;MS;50;B509;4;0E3200;1;-;sd;1;d1c;1.0;°C;-;-;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
get;vwxmk;DesiredTempLow;Absenktemperatur;MS;50;B509;3;0D3300;1;-;sd;1;d1c;1.0;°C;-;-;;;;;;;;;;;;;;;;;;;;;;;;
|
get;vwxmk;DesiredTempLow;Absenktemperatur;MS;50;B509;3;0D3300;1;-;sd;1;d1c;1.0;°C;-;-;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
get;vwxmk;FloorProtectionTempLimit;Fußbodenschutz Temp > VF2;MS;50;B509;3;0D7B01;1;-;sd;1;uch;-;°C;-;-;;;;;;;;;;;;;;;;;;;;;;;;
|
get;vwxmk;FloorProtectionTempLimit;Fußbodenschutz Temp > VF2;MS;50;B509;3;0D7B01;1;-;sd;1;uch;-;°C;-;-;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
get;vwxmk;FloorScreedDryingDay;Estrichtrocknung Tag;MS;50;B509;3;0D3B00;1;-;sd;1;uch;-;-;-;-;;;;;;;;;;;;;;;;;;;;;;;;
|
get;vwxmk;FloorScreedDryingDay;Estrichtrocknung Tag;MS;50;B509;3;0D3B00;1;-;sd;1;uch;-;-;-;-;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|||||||
|
Binary file not shown.
+72
-20
@@ -37,7 +37,7 @@ void BaseLoop::start()
|
|||||||
|
|
||||||
data.erase(std::remove(data.begin(), data.end(), '\r'), data.end());
|
data.erase(std::remove(data.begin(), data.end(), '\r'), data.end());
|
||||||
data.erase(std::remove(data.begin(), data.end(), '\n'), data.end());
|
data.erase(std::remove(data.begin(), data.end(), '\n'), data.end());
|
||||||
|
|
||||||
L.log(bas, event, ">>> %s", data.c_str());
|
L.log(bas, event, ">>> %s", data.c_str());
|
||||||
|
|
||||||
// decode message
|
// decode message
|
||||||
@@ -59,31 +59,29 @@ std::string BaseLoop::decodeMessage(const std::string& data)
|
|||||||
std::ostringstream result;
|
std::ostringstream result;
|
||||||
std::string cycdata;
|
std::string cycdata;
|
||||||
int index;
|
int index;
|
||||||
BusCommand* busCommand;
|
|
||||||
|
|
||||||
// prepare data
|
// prepare data
|
||||||
std::string token;
|
std::string token;
|
||||||
std::istringstream stream(data);
|
std::istringstream stream(data);
|
||||||
std::vector<std::string> cmd;
|
std::vector<std::string> cmd;
|
||||||
|
|
||||||
while (std::getline(stream, token, ' ') != 0)
|
while (std::getline(stream, token, ' ') != 0)
|
||||||
cmd.push_back(token);
|
cmd.push_back(token);
|
||||||
|
|
||||||
if (cmd.size() == 0)
|
if (cmd.size() == 0)
|
||||||
return "command missing";
|
return "command missing";
|
||||||
|
|
||||||
switch (getCase(cmd[0])) {
|
switch (getCase(cmd[0])) {
|
||||||
case notfound:
|
case notfound:
|
||||||
result << "command not found";
|
result << "command not found";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case get:
|
case get:
|
||||||
case set:
|
|
||||||
if (cmd.size() < 3) {
|
if (cmd.size() < 3) {
|
||||||
result << "format: type class cmd [sub]";
|
result << "format: type class cmd [sub]";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
index = m_commands->findCommand(data);
|
index = m_commands->findCommand(data);
|
||||||
|
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
@@ -92,11 +90,11 @@ std::string BaseLoop::decodeMessage(const std::string& data)
|
|||||||
std::string ebusCommand(A.getParam<const char*>("p_address"));
|
std::string ebusCommand(A.getParam<const char*>("p_address"));
|
||||||
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);
|
||||||
|
|
||||||
L.log(bas, event, " type: %s msg: %s", type.c_str(), ebusCommand.c_str());
|
L.log(bas, event, " type: %s msg: %s", type.c_str(), ebusCommand.c_str());
|
||||||
// send busCommand
|
// send busCommand
|
||||||
m_ebusloop->addBusCommand(new BusCommand(type, ebusCommand));
|
m_ebusloop->addBusCommand(new BusCommand(type, ebusCommand));
|
||||||
busCommand = m_ebusloop->getBusCommand();
|
BusCommand* busCommand = m_ebusloop->getBusCommand();
|
||||||
|
|
||||||
if (busCommand->getResult().c_str()[0] != '-') {
|
if (busCommand->getResult().c_str()[0] != '-') {
|
||||||
// decode data
|
// decode data
|
||||||
@@ -107,26 +105,80 @@ std::string BaseLoop::decodeMessage(const std::string& data)
|
|||||||
|
|
||||||
delete command;
|
delete command;
|
||||||
} else {
|
} else {
|
||||||
|
L.log(bas, error, " %s", busCommand->getResult().c_str());
|
||||||
result << busCommand->getResult().c_str();
|
result << busCommand->getResult().c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
delete busCommand;
|
delete busCommand;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
result << "ebus command not found";
|
result << "ebus command not found";
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case set:
|
||||||
|
if (cmd.size() != 4) {
|
||||||
|
result << "format: type class cmd value";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
index = m_commands->findCommand(data.substr(0, data.find(cmd[3])-1));
|
||||||
|
|
||||||
|
if (index >= 0) {
|
||||||
|
|
||||||
|
std::string type = m_commands->getType(index);
|
||||||
|
std::string ebusCommand(A.getParam<const char*>("p_address"));
|
||||||
|
ebusCommand += m_commands->getEbusCommand(index);
|
||||||
|
|
||||||
|
// encode data
|
||||||
|
Command* command = new Command(index, (*m_commands)[index], cmd[3]);
|
||||||
|
std::string value = command->calcData();
|
||||||
|
if (value[0] != '-') {
|
||||||
|
ebusCommand += value;
|
||||||
|
} else {
|
||||||
|
L.log(bas, error, " %s", value.c_str());
|
||||||
|
delete command;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::transform(ebusCommand.begin(), ebusCommand.end(), ebusCommand.begin(), tolower);
|
||||||
|
|
||||||
|
L.log(bas, event, " type: %s msg: %s", type.c_str(), ebusCommand.c_str());
|
||||||
|
// send busCommand
|
||||||
|
m_ebusloop->addBusCommand(new BusCommand(type, ebusCommand));
|
||||||
|
BusCommand* busCommand = m_ebusloop->getBusCommand();
|
||||||
|
|
||||||
|
if (busCommand->getResult().c_str()[0] != '-') {
|
||||||
|
// decode result
|
||||||
|
if (busCommand->getResult().substr(busCommand->getResult().length()-8) == "00000000")
|
||||||
|
result << "done";
|
||||||
|
else
|
||||||
|
result << "error";
|
||||||
|
|
||||||
|
} else {
|
||||||
|
L.log(bas, error, " %s", busCommand->getResult().c_str());
|
||||||
|
result << busCommand->getResult().c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
delete busCommand;
|
||||||
|
delete command;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
result << "ebus command not found";
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
case cyc:
|
case cyc:
|
||||||
if (cmd.size() < 3) {
|
if (cmd.size() < 3) {
|
||||||
result << "format: type class cmd [sub]";
|
result << "format: type class cmd [sub]";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
index = m_commands->findCommand(data);
|
index = m_commands->findCommand(data);
|
||||||
|
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
// get cycdata
|
// get cycdata
|
||||||
cycdata = m_cycdata->getData(index);
|
cycdata = m_cycdata->getData(index);
|
||||||
@@ -136,7 +188,7 @@ std::string BaseLoop::decodeMessage(const std::string& data)
|
|||||||
|
|
||||||
// return result
|
// return result
|
||||||
result << command->calcResult(cmd);
|
result << command->calcResult(cmd);
|
||||||
|
|
||||||
delete command;
|
delete command;
|
||||||
} else {
|
} else {
|
||||||
result << "no data stored";
|
result << "no data stored";
|
||||||
@@ -144,9 +196,9 @@ std::string BaseLoop::decodeMessage(const std::string& data)
|
|||||||
} else {
|
} else {
|
||||||
result << "ebus command not found";
|
result << "ebus command not found";
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case dump:
|
case dump:
|
||||||
if (cmd[1] == "on") m_ebusloop->dump(true);
|
if (cmd[1] == "on") m_ebusloop->dump(true);
|
||||||
if (cmd[1] == "off") m_ebusloop->dump(false);
|
if (cmd[1] == "off") m_ebusloop->dump(false);
|
||||||
@@ -160,7 +212,7 @@ std::string BaseLoop::decodeMessage(const std::string& data)
|
|||||||
if (cmd[1] == "debug") L.getSink(0)->setLevel(debug);
|
if (cmd[1] == "debug") L.getSink(0)->setLevel(debug);
|
||||||
result << "done";
|
result << "done";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with ebus-daemon. If not, see http://www.gnu.org/licenses/.
|
* along with ebus-daemon. If not, see http://www.gnu.org/licenses/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "libebus.h"
|
#include "libebus.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "daemon.h"
|
#include "daemon.h"
|
||||||
|
|||||||
+1
-1
@@ -25,8 +25,8 @@
|
|||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
#include "notify.h"
|
#include "notify.h"
|
||||||
#include "baseloop.h"
|
#include "baseloop.h"
|
||||||
#include <unistd.h>
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
class Connection : public Thread
|
class Connection : public Thread
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user