server command 'raw' - toggle log raw data added; log types of error messages changed from trace to error.

This commit is contained in:
Roland Jax
2014-11-08 09:39:25 +01:00
parent e6930d333d
commit e4544a98ad
4 changed files with 54 additions and 41 deletions
+22 -12
View File
@@ -292,17 +292,6 @@ std::string BaseLoop::decodeMessage(const std::string& data)
break; 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: case log:
if (cmd.size () != 3 ) { if (cmd.size () != 3 ) {
result << "usage: 'log areas area,area,..' (areas: bas|net|bus|cyc|all)" << std::endl 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; 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: case reload:
if (cmd.size() != 1) { if (cmd.size() != 1) {
result << "usage: 'reload'"; 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 << " set - set ebus values 'set class cmd value'" << std::endl
<< " cyc - fetch cycle data 'cyc class cmd (sub)'" << 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 << " 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 << " 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 << " - 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 << " reload - reload ebus configuration" << std::endl << std::endl
<< " stop - stop daemon" << std::endl << " stop - stop daemon" << std::endl
<< " quit - close connection" << std::endl << std::endl << " quit - close connection" << std::endl << std::endl
+4 -2
View File
@@ -50,8 +50,9 @@ private:
set, // set ebus value set, // set ebus value
cyc, // fetch cycle data cyc, // fetch cycle data
hex, // send hex value hex, // send hex value
dump, // change dump state
log, // logger settings log, // logger settings
raw, // toggle log raw data
dump, // toggle dump state
reload, // reload ebus configuration reload, // reload ebus configuration
help, // print commands help, // print commands
notfound notfound
@@ -63,8 +64,9 @@ private:
if (strcasecmp(item.c_str(), "SET") == 0) return set; if (strcasecmp(item.c_str(), "SET") == 0) return set;
if (strcasecmp(item.c_str(), "CYC") == 0) return cyc; if (strcasecmp(item.c_str(), "CYC") == 0) return cyc;
if (strcasecmp(item.c_str(), "HEX") == 0) return hex; 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(), "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(), "RELOAD") == 0) return reload;
if (strcasecmp(item.c_str(), "HELP") == 0) return help; if (strcasecmp(item.c_str(), "HELP") == 0) return help;
+17 -17
View File
@@ -247,7 +247,7 @@ void EBusLoop::analyseCycData()
tmp += (*m_commands)[index][1]; tmp += (*m_commands)[index][1];
tmp += " "; tmp += " ";
tmp += (*m_commands)[index][2]; 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 += (*m_commands)[index][1];
tmp += " "; tmp += " ";
tmp += (*m_commands)[index][2]; 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")); std::string ebusCommand(A.getParam<const char*>("p_address"));
ebusCommand += m_commands->getEbusCommand(index); ebusCommand += m_commands->getEbusCommand(index);
@@ -286,7 +286,7 @@ int EBusLoop::acquireBus()
// send QQ // send QQ
numSend = m_port->send(&sendByte); numSend = m_port->send(&sendByte);
if (numSend <= 0) { if (numSend <= 0) {
L.log(bus, trace, " ERR_SEND: send error"); L.log(bus, error, " ERR_SEND: send error");
return RESULT_ERR_SEND; return RESULT_ERR_SEND;
} }
@@ -294,7 +294,7 @@ int EBusLoop::acquireBus()
numRecv = m_port->recv(0); numRecv = m_port->recv(0);
if (numRecv < 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; return RESULT_ERR_DEVICE;
} }
@@ -319,15 +319,15 @@ int EBusLoop::acquireBus()
return RESULT_BUS_PRIOR_RETRY; 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; return RESULT_ERR_BUS_LOST;
} }
// cycle bytes // cycle bytes
collectCycData(numRecv); collectCycData(numRecv);
L.log(bus, trace, " ERR_BUS_LOST: lost bus arbitration"); L.log(bus, error, " ERR_EXTRA_DATA: received bytes > sent bytes");
return RESULT_ERR_BUS_LOST; return RESULT_ERR_EXTRA_DATA;
} }
BusCommand* EBusLoop::sendCommand() BusCommand* EBusLoop::sendCommand()
@@ -376,7 +376,7 @@ BusCommand* EBusLoop::sendCommand()
// is slave ACK negative? // is slave ACK negative?
if (recvByte == NAK) { if (recvByte == NAK) {
sendByte(SYN); sendByte(SYN);
L.log(bus, trace, " ERR_NAK: NAK received"); L.log(bus, error, " ERR_NAK: NAK received");
retval = RESULT_ERR_NAK; retval = RESULT_ERR_NAK;
goto on_exit; goto on_exit;
} }
@@ -419,7 +419,7 @@ BusCommand* EBusLoop::sendCommand()
// send ACK // send ACK
retval = sendByte(ACK); retval = sendByte(ACK);
if (retval == -1) { if (retval == -1) {
L.log(bus, trace, " ERR_ACK: ACK error"); L.log(bus, error, " ERR_ACK: ACK error");
retval = RESULT_ERR_ACK; retval = RESULT_ERR_ACK;
goto on_exit; goto on_exit;
} }
@@ -453,14 +453,14 @@ int EBusLoop::sendByte(const unsigned char sendByte)
numRecv = m_port->recv(RECV_TIMEOUT); numRecv = m_port->recv(RECV_TIMEOUT);
if (numSend != numRecv) { 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; return RESULT_ERR_EXTRA_DATA;
} }
recvByte = fetchByte(); recvByte = fetchByte();
if (sendByte != recvByte) { if (sendByte != recvByte) {
L.log(bus, trace, " ERR_SEND: send error"); L.log(bus, error, " ERR_SEND: send error");
return RESULT_ERR_SEND; return RESULT_ERR_SEND;
} }
@@ -475,11 +475,11 @@ int EBusLoop::recvSlaveAck(unsigned char& recvByte)
numRecv = m_port->recv(m_recvTimeout); numRecv = m_port->recv(m_recvTimeout);
if (numRecv > 1) { 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; return RESULT_ERR_EXTRA_DATA;
} }
else if (numRecv < 0) { else if (numRecv < 0) {
L.log(bus, trace, " ERR_TIMEOUT: read timeout"); L.log(bus, error, " ERR_TIMEOUT: read timeout");
return RESULT_ERR_TIMEOUT; return RESULT_ERR_TIMEOUT;
} }
@@ -487,7 +487,7 @@ int EBusLoop::recvSlaveAck(unsigned char& recvByte)
// is received byte SYN? // is received byte SYN?
if (recvByte == SYN) { if (recvByte == SYN) {
L.log(bus, trace, " ERR_SYN: SYN received"); L.log(bus, error, " ERR_SYN: SYN received");
return RESULT_ERR_SYN; return RESULT_ERR_SYN;
} }
@@ -505,7 +505,7 @@ int EBusLoop::recvSlaveData(SymbolString& result)
for (size_t i = 0, needed = 1; i < needed; i++) { for (size_t i = 0, needed = 1; i < needed; i++) {
numRecv = m_port->recv(RECV_TIMEOUT); numRecv = m_port->recv(RECV_TIMEOUT);
if (numRecv < 0) { if (numRecv < 0) {
L.log(bus, trace, " ERR_TIMEOUT: read timeout"); L.log(bus, error, " ERR_TIMEOUT: read timeout");
return RESULT_ERR_TIMEOUT; return RESULT_ERR_TIMEOUT;
} }
@@ -528,12 +528,12 @@ int EBusLoop::recvSlaveData(SymbolString& result)
} }
if (retval == RESULT_IN_ESC) { 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; return RESULT_ERR_ESC;
} }
if (updateCrc == true || calcCrc != result[result.size()-1]) { 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; return RESULT_ERR_CRC;
} }
+2 -1
View File
@@ -45,7 +45,8 @@ public:
void addBusCommand(BusCommand* busCommand) { m_sendBuffer.add(busCommand); } 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; } void newCommands(Commands* commands) { m_commands = commands; }