BusLoop::analyseCycData: check of input data for validity implemented.
This commit is contained in:
+47
-29
@@ -307,38 +307,56 @@ void BusLoop::collectCycData(const int numRecv)
|
||||
|
||||
void BusLoop::analyseCycData()
|
||||
{
|
||||
//TODO check the input data for validity
|
||||
int lenMaster = m_sstr[4];
|
||||
SymbolString master;
|
||||
|
||||
static bool skipfirst = false;
|
||||
for (int i = 0; i < 5+lenMaster; i++)
|
||||
master.push_back(m_sstr[i], true , true);
|
||||
|
||||
if (skipfirst == true) {
|
||||
L.log(cyc, trace, "%s", m_sstr.getDataStr().c_str());
|
||||
|
||||
int index = m_commands->storeCycData(m_sstr.getDataStr());
|
||||
|
||||
if (index == -1) {
|
||||
L.log(cyc, debug, " command not found");
|
||||
}
|
||||
else if (index == -2) {
|
||||
L.log(cyc, debug, " no commands defined");
|
||||
}
|
||||
else if (index == -3) {
|
||||
L.log(cyc, debug, " search skipped - string too short");
|
||||
}
|
||||
else {
|
||||
string tmp;
|
||||
tmp += (*m_commands)[index][1];
|
||||
tmp += " ";
|
||||
tmp += (*m_commands)[index][2];
|
||||
L.log(cyc, event, " cycle [%4d] %s", index, tmp.c_str());
|
||||
}
|
||||
|
||||
// collect Slave address
|
||||
if (index != -3)
|
||||
collectSlave();
|
||||
if (m_sstr[5+lenMaster] != master.getCRC()) {
|
||||
L.log(cyc, trace, "ERR_CYC_CRC_M %s - %02x %02x", master.getDataStr().c_str(), m_sstr[5+lenMaster], master.getCRC());
|
||||
return;
|
||||
}
|
||||
else
|
||||
skipfirst = true;
|
||||
|
||||
if (m_sstr[1] != BROADCAST || isMaster(m_sstr[1]) == false) {
|
||||
int lenSlave = m_sstr[5+lenMaster+2];
|
||||
SymbolString slave;
|
||||
|
||||
for (int i = 5+lenMaster+2; i < 5+lenMaster+3+lenSlave; i++)
|
||||
slave.push_back(m_sstr[i], true , true);
|
||||
|
||||
if (m_sstr[5+lenMaster+3+lenSlave] != slave.getCRC()) {
|
||||
L.log(cyc, trace, "ERR_CYC_CRC_S %s - %02x %02x", slave.getDataStr().c_str(), m_sstr[5+lenMaster+3+lenSlave], slave.getCRC());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
L.log(cyc, trace, "%s", m_sstr.getDataStr().c_str());
|
||||
|
||||
int index = m_commands->storeCycData(m_sstr.getDataStr());
|
||||
|
||||
if (index == -1) {
|
||||
L.log(cyc, debug, " command not found");
|
||||
}
|
||||
else if (index == -2) {
|
||||
L.log(cyc, debug, " no commands defined");
|
||||
}
|
||||
else if (index == -3) {
|
||||
L.log(cyc, debug, " search skipped - string too short");
|
||||
}
|
||||
else {
|
||||
string tmp;
|
||||
tmp += (*m_commands)[index][1];
|
||||
tmp += " ";
|
||||
tmp += (*m_commands)[index][2];
|
||||
L.log(cyc, event, " cycle [%4d] %s", index, tmp.c_str());
|
||||
}
|
||||
|
||||
// collect Slave address
|
||||
if (index != -3)
|
||||
collectSlave();
|
||||
|
||||
}
|
||||
|
||||
void BusLoop::collectSlave()
|
||||
|
||||
Reference in New Issue
Block a user