server command 'raw' - toggle log raw data added; log types of error messages changed from trace to error.
This commit is contained in:
+22
-12
@@ -292,17 +292,6 @@ std::string BaseLoop::decodeMessage(const std::string& data)
|
||||
|
||||
break;
|
||||
|
||||
case dump:
|
||||
if (cmd.size() != 2) {
|
||||
result << "usage: 'dump state' (state: on|off)";
|
||||
break;
|
||||
}
|
||||
|
||||
if (strcasecmp(cmd[1].c_str(), "ON") == 0) m_ebusloop->dump(true);
|
||||
if (strcasecmp(cmd[1].c_str(), "OFF") == 0) m_ebusloop->dump(false);
|
||||
result << "done";
|
||||
break;
|
||||
|
||||
case log:
|
||||
if (cmd.size () != 3 ) {
|
||||
result << "usage: 'log areas area,area,..' (areas: bas|net|bus|cyc|all)" << std::endl
|
||||
@@ -328,6 +317,26 @@ std::string BaseLoop::decodeMessage(const std::string& data)
|
||||
|
||||
break;
|
||||
|
||||
case raw:
|
||||
if (cmd.size() != 1) {
|
||||
result << "usage: 'raw'";
|
||||
break;
|
||||
}
|
||||
|
||||
m_ebusloop->raw();
|
||||
result << "done";
|
||||
break;
|
||||
|
||||
case dump:
|
||||
if (cmd.size() != 1) {
|
||||
result << "usage: 'dump'";
|
||||
break;
|
||||
}
|
||||
|
||||
m_ebusloop->dump();
|
||||
result << "done";
|
||||
break;
|
||||
|
||||
case reload:
|
||||
if (cmd.size() != 1) {
|
||||
result << "usage: 'reload'";
|
||||
@@ -356,9 +365,10 @@ std::string BaseLoop::decodeMessage(const std::string& data)
|
||||
<< " set - set ebus values 'set class cmd value'" << std::endl
|
||||
<< " cyc - fetch cycle data 'cyc class cmd (sub)'" << std::endl
|
||||
<< " hex - send given hex value 'hex type value' (value: ZZPBSBNNDx)" << std::endl << std::endl
|
||||
<< " dump - change dump state 'dump state' (state: on|off)" << std::endl << std::endl
|
||||
<< " log - change log areas 'log areas area,area,..' (areas: bas|net|bus|cyc|all)" << std::endl
|
||||
<< " - change log level 'log level level' (level: error|event|trace|debug)" << std::endl << std::endl
|
||||
<< " raw - toggle log raw data" << std::endl
|
||||
<< " dump - toggle dump state" << std::endl << std::endl
|
||||
<< " reload - reload ebus configuration" << std::endl << std::endl
|
||||
<< " stop - stop daemon" << std::endl
|
||||
<< " quit - close connection" << std::endl << std::endl
|
||||
|
||||
+13
-11
@@ -46,16 +46,17 @@ private:
|
||||
WQueue<Message*> m_queue;
|
||||
|
||||
enum ClientCommand {
|
||||
get, // get ebus data
|
||||
set, // set ebus value
|
||||
cyc, // fetch cycle data
|
||||
hex, // send hex value
|
||||
dump, // change dump state
|
||||
log, // logger settings
|
||||
reload, // reload ebus configuration
|
||||
help, // print commands
|
||||
notfound
|
||||
};
|
||||
get, // get ebus data
|
||||
set, // set ebus value
|
||||
cyc, // fetch cycle data
|
||||
hex, // send hex value
|
||||
log, // logger settings
|
||||
raw, // toggle log raw data
|
||||
dump, // toggle dump state
|
||||
reload, // reload ebus configuration
|
||||
help, // print commands
|
||||
notfound
|
||||
};
|
||||
|
||||
ClientCommand getCase(const std::string& item)
|
||||
{
|
||||
@@ -63,8 +64,9 @@ private:
|
||||
if (strcasecmp(item.c_str(), "SET") == 0) return set;
|
||||
if (strcasecmp(item.c_str(), "CYC") == 0) return cyc;
|
||||
if (strcasecmp(item.c_str(), "HEX") == 0) return hex;
|
||||
if (strcasecmp(item.c_str(), "DUMP") == 0) return dump;
|
||||
if (strcasecmp(item.c_str(), "LOG") == 0) return log;
|
||||
if (strcasecmp(item.c_str(), "RAW") == 0) return raw;
|
||||
if (strcasecmp(item.c_str(), "DUMP") == 0) return dump;
|
||||
if (strcasecmp(item.c_str(), "RELOAD") == 0) return reload;
|
||||
if (strcasecmp(item.c_str(), "HELP") == 0) return help;
|
||||
|
||||
|
||||
+17
-17
@@ -247,7 +247,7 @@ void EBusLoop::analyseCycData()
|
||||
tmp += (*m_commands)[index][1];
|
||||
tmp += " ";
|
||||
tmp += (*m_commands)[index][2];
|
||||
L.log(bus, event, " cycle [%d] %s", index, tmp.c_str());
|
||||
L.log(bus, event, " cycle [%4d] %s", index, tmp.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ void EBusLoop::addPollCommand()
|
||||
tmp += (*m_commands)[index][1];
|
||||
tmp += " ";
|
||||
tmp += (*m_commands)[index][2];
|
||||
L.log(bus, event, " polling [%d] %s", index, tmp.c_str());
|
||||
L.log(bus, event, " polling [%4d] %s", index, tmp.c_str());
|
||||
|
||||
std::string ebusCommand(A.getParam<const char*>("p_address"));
|
||||
ebusCommand += m_commands->getEbusCommand(index);
|
||||
@@ -286,7 +286,7 @@ int EBusLoop::acquireBus()
|
||||
// send QQ
|
||||
numSend = m_port->send(&sendByte);
|
||||
if (numSend <= 0) {
|
||||
L.log(bus, trace, " ERR_SEND: send error");
|
||||
L.log(bus, error, " ERR_SEND: send error");
|
||||
return RESULT_ERR_SEND;
|
||||
}
|
||||
|
||||
@@ -294,7 +294,7 @@ int EBusLoop::acquireBus()
|
||||
numRecv = m_port->recv(0);
|
||||
|
||||
if (numRecv < 0) {
|
||||
L.log(bus, trace, " ERR_DEVICE: generic device error");
|
||||
L.log(bus, error, " ERR_DEVICE: generic device error");
|
||||
return RESULT_ERR_DEVICE;
|
||||
}
|
||||
|
||||
@@ -319,15 +319,15 @@ int EBusLoop::acquireBus()
|
||||
return RESULT_BUS_PRIOR_RETRY;
|
||||
}
|
||||
|
||||
L.log(bus, trace, " ERR_BUS_LOST: lost bus arbitration");
|
||||
L.log(bus, error, " ERR_BUS_LOST: lost bus arbitration");
|
||||
return RESULT_ERR_BUS_LOST;
|
||||
}
|
||||
|
||||
// cycle bytes
|
||||
collectCycData(numRecv);
|
||||
|
||||
L.log(bus, trace, " ERR_BUS_LOST: lost bus arbitration");
|
||||
return RESULT_ERR_BUS_LOST;
|
||||
L.log(bus, error, " ERR_EXTRA_DATA: received bytes > sent bytes");
|
||||
return RESULT_ERR_EXTRA_DATA;
|
||||
}
|
||||
|
||||
BusCommand* EBusLoop::sendCommand()
|
||||
@@ -376,7 +376,7 @@ BusCommand* EBusLoop::sendCommand()
|
||||
// is slave ACK negative?
|
||||
if (recvByte == NAK) {
|
||||
sendByte(SYN);
|
||||
L.log(bus, trace, " ERR_NAK: NAK received");
|
||||
L.log(bus, error, " ERR_NAK: NAK received");
|
||||
retval = RESULT_ERR_NAK;
|
||||
goto on_exit;
|
||||
}
|
||||
@@ -419,7 +419,7 @@ BusCommand* EBusLoop::sendCommand()
|
||||
// send ACK
|
||||
retval = sendByte(ACK);
|
||||
if (retval == -1) {
|
||||
L.log(bus, trace, " ERR_ACK: ACK error");
|
||||
L.log(bus, error, " ERR_ACK: ACK error");
|
||||
retval = RESULT_ERR_ACK;
|
||||
goto on_exit;
|
||||
}
|
||||
@@ -453,14 +453,14 @@ int EBusLoop::sendByte(const unsigned char sendByte)
|
||||
numRecv = m_port->recv(RECV_TIMEOUT);
|
||||
|
||||
if (numSend != numRecv) {
|
||||
L.log(bus, trace, " ERR_EXTRA_DATA: received bytes > sent bytes");
|
||||
L.log(bus, error, " ERR_EXTRA_DATA: received bytes > sent bytes");
|
||||
return RESULT_ERR_EXTRA_DATA;
|
||||
}
|
||||
|
||||
recvByte = fetchByte();
|
||||
|
||||
if (sendByte != recvByte) {
|
||||
L.log(bus, trace, " ERR_SEND: send error");
|
||||
L.log(bus, error, " ERR_SEND: send error");
|
||||
return RESULT_ERR_SEND;
|
||||
}
|
||||
|
||||
@@ -475,11 +475,11 @@ int EBusLoop::recvSlaveAck(unsigned char& recvByte)
|
||||
numRecv = m_port->recv(m_recvTimeout);
|
||||
|
||||
if (numRecv > 1) {
|
||||
L.log(bus, trace, " ERR_EXTRA_DATA: received bytes > sent bytes");
|
||||
L.log(bus, error, " ERR_EXTRA_DATA: received bytes > sent bytes");
|
||||
return RESULT_ERR_EXTRA_DATA;
|
||||
}
|
||||
else if (numRecv < 0) {
|
||||
L.log(bus, trace, " ERR_TIMEOUT: read timeout");
|
||||
L.log(bus, error, " ERR_TIMEOUT: read timeout");
|
||||
return RESULT_ERR_TIMEOUT;
|
||||
}
|
||||
|
||||
@@ -487,7 +487,7 @@ int EBusLoop::recvSlaveAck(unsigned char& recvByte)
|
||||
|
||||
// is received byte SYN?
|
||||
if (recvByte == SYN) {
|
||||
L.log(bus, trace, " ERR_SYN: SYN received");
|
||||
L.log(bus, error, " ERR_SYN: SYN received");
|
||||
return RESULT_ERR_SYN;
|
||||
}
|
||||
|
||||
@@ -505,7 +505,7 @@ int EBusLoop::recvSlaveData(SymbolString& result)
|
||||
for (size_t i = 0, needed = 1; i < needed; i++) {
|
||||
numRecv = m_port->recv(RECV_TIMEOUT);
|
||||
if (numRecv < 0) {
|
||||
L.log(bus, trace, " ERR_TIMEOUT: read timeout");
|
||||
L.log(bus, error, " ERR_TIMEOUT: read timeout");
|
||||
return RESULT_ERR_TIMEOUT;
|
||||
}
|
||||
|
||||
@@ -528,12 +528,12 @@ int EBusLoop::recvSlaveData(SymbolString& result)
|
||||
}
|
||||
|
||||
if (retval == RESULT_IN_ESC) {
|
||||
L.log(bus, trace, " ERR_ESC: invalid escape sequence received");
|
||||
L.log(bus, error, " ERR_ESC: invalid escape sequence received");
|
||||
return RESULT_ERR_ESC;
|
||||
}
|
||||
|
||||
if (updateCrc == true || calcCrc != result[result.size()-1]) {
|
||||
L.log(bus, trace, " ERR_CRC: CRC error");
|
||||
L.log(bus, error, " ERR_CRC: CRC error");
|
||||
return RESULT_ERR_CRC;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,8 @@ public:
|
||||
|
||||
void addBusCommand(BusCommand* busCommand) { m_sendBuffer.add(busCommand); }
|
||||
|
||||
void dump(const bool dumpState) { m_dumpState = dumpState; }
|
||||
void dump() { m_dumpState == true ? m_dumpState = false : m_dumpState = true ; }
|
||||
void raw() { m_logRawData == true ? m_logRawData = false : m_logRawData = true ; }
|
||||
|
||||
void newCommands(Commands* commands) { m_commands = commands; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user