Changed the way adding/removing targetted frames works. It's simpler

now.
This commit is contained in:
Collin Kidder
2017-08-22 20:03:06 -04:00
parent fc95e3dbea
commit 7c3fef54f9
2 changed files with 21 additions and 35 deletions
+7 -10
View File
@@ -216,14 +216,11 @@ bool CANConManager::addTargettedFrame(int pBusId, uint32_t ID, uint32_t mask, QO
foreach (CANConnection* conn, mConns)
{
if (pBusId == -1) conn->addTargettedFrame(pBusId, ID, mask, receiver);
else
else if (pBusId < (uint32_t)(busBase + conn->getNumBuses()))
{
tempBusVal = pBusId >> busBase;
tempBusVal &= ((1 << conn->getNumBuses()) - 1);
if (tempBusVal) {
qDebug() << "Forwarding targetted frame setting to a connection object";
conn->addTargettedFrame(tempBusVal, ID, mask, receiver);
}
conn->addTargettedFrame(pBusId - busBase, ID, mask, receiver);
}
busBase += conn->getNumBuses();
}
@@ -238,11 +235,11 @@ bool CANConManager::removeTargettedFrame(int pBusId, uint32_t ID, uint32_t mask,
foreach (CANConnection* conn, mConns)
{
if (pBusId == -1) conn->removeTargettedFrame(pBusId, ID, mask, receiver);
else
else if (pBusId < (uint32_t)(busBase + conn->getNumBuses()))
{
tempBusVal = pBusId >> busBase;
tempBusVal &= ((1 << conn->getNumBuses()) - 1);
if (tempBusVal) conn->removeTargettedFrame(tempBusVal, ID, mask, receiver);
qDebug() << "Forwarding targetted frame setting to a connection object";
conn->removeTargettedFrame(pBusId - busBase, ID, mask, receiver);
}
busBase += conn->getNumBuses();
}
+5 -16
View File
@@ -285,20 +285,15 @@ bool CANConnection::addTargettedFrame(int pBusId, uint32_t ID, uint32_t mask, QO
}
*/
/* sanity checks */
if(pBusId < -1 || pBusId >= (1 << getNumBuses()))
if(pBusId < -1 || pBusId >= getNumBuses())
return false;
for (int i = 0; i < getNumBuses(); i++)
{
if ( (pBusId == -1) || (pBusId && (1 << i)) ) {
qDebug() << "Connection is registering a new targetted frame filter, local bus " << i;
qDebug() << "Connection is registering a new targetted frame filter, local bus " << pBusId;
CANFlt target;
target.id = ID;
target.mask = mask;
target.observer = receiver;
mBusData_p[i].mTargettedFrames.append(target);
}
}
mBusData_p[pBusId].mTargettedFrames.append(target);
return true;
}
@@ -319,20 +314,14 @@ bool CANConnection::removeTargettedFrame(int pBusId, uint32_t ID, uint32_t mask,
}
*/
/* sanity checks */
if(pBusId < -1 || pBusId >= (1 << getNumBuses()))
if(pBusId < -1 || pBusId >= getNumBuses())
return false;
for (int i = 0; i < getNumBuses(); i++)
{
if (pBusId == -1 || (pBusId && (1 << i)))
{
CANFlt target;
target.id = ID;
target.mask = mask;
target.observer = receiver;
mBusData_p[i].mTargettedFrames.removeAll(target);
}
}
mBusData_p[pBusId].mTargettedFrames.removeAll(target);
return true;
}