Changed the way adding/removing targetted frames works. It's simpler
now.
This commit is contained in:
@@ -216,14 +216,11 @@ bool CANConManager::addTargettedFrame(int pBusId, uint32_t ID, uint32_t mask, QO
|
|||||||
foreach (CANConnection* conn, mConns)
|
foreach (CANConnection* conn, mConns)
|
||||||
{
|
{
|
||||||
if (pBusId == -1) conn->addTargettedFrame(pBusId, ID, mask, receiver);
|
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";
|
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();
|
busBase += conn->getNumBuses();
|
||||||
}
|
}
|
||||||
@@ -238,11 +235,11 @@ bool CANConManager::removeTargettedFrame(int pBusId, uint32_t ID, uint32_t mask,
|
|||||||
foreach (CANConnection* conn, mConns)
|
foreach (CANConnection* conn, mConns)
|
||||||
{
|
{
|
||||||
if (pBusId == -1) conn->removeTargettedFrame(pBusId, ID, mask, receiver);
|
if (pBusId == -1) conn->removeTargettedFrame(pBusId, ID, mask, receiver);
|
||||||
else
|
else if (pBusId < (uint32_t)(busBase + conn->getNumBuses()))
|
||||||
{
|
{
|
||||||
tempBusVal = pBusId >> busBase;
|
qDebug() << "Forwarding targetted frame setting to a connection object";
|
||||||
tempBusVal &= ((1 << conn->getNumBuses()) - 1);
|
conn->removeTargettedFrame(pBusId - busBase, ID, mask, receiver);
|
||||||
if (tempBusVal) conn->removeTargettedFrame(tempBusVal, ID, mask, receiver);
|
|
||||||
}
|
}
|
||||||
busBase += conn->getNumBuses();
|
busBase += conn->getNumBuses();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -285,20 +285,15 @@ bool CANConnection::addTargettedFrame(int pBusId, uint32_t ID, uint32_t mask, QO
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
/* sanity checks */
|
/* sanity checks */
|
||||||
if(pBusId < -1 || pBusId >= (1 << getNumBuses()))
|
if(pBusId < -1 || pBusId >= getNumBuses())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (int i = 0; i < getNumBuses(); i++)
|
qDebug() << "Connection is registering a new targetted frame filter, local bus " << pBusId;
|
||||||
{
|
|
||||||
if ( (pBusId == -1) || (pBusId && (1 << i)) ) {
|
|
||||||
qDebug() << "Connection is registering a new targetted frame filter, local bus " << i;
|
|
||||||
CANFlt target;
|
CANFlt target;
|
||||||
target.id = ID;
|
target.id = ID;
|
||||||
target.mask = mask;
|
target.mask = mask;
|
||||||
target.observer = receiver;
|
target.observer = receiver;
|
||||||
mBusData_p[i].mTargettedFrames.append(target);
|
mBusData_p[pBusId].mTargettedFrames.append(target);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -319,20 +314,14 @@ bool CANConnection::removeTargettedFrame(int pBusId, uint32_t ID, uint32_t mask,
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
/* sanity checks */
|
/* sanity checks */
|
||||||
if(pBusId < -1 || pBusId >= (1 << getNumBuses()))
|
if(pBusId < -1 || pBusId >= getNumBuses())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (int i = 0; i < getNumBuses(); i++)
|
|
||||||
{
|
|
||||||
if (pBusId == -1 || (pBusId && (1 << i)))
|
|
||||||
{
|
|
||||||
CANFlt target;
|
CANFlt target;
|
||||||
target.id = ID;
|
target.id = ID;
|
||||||
target.mask = mask;
|
target.mask = mask;
|
||||||
target.observer = receiver;
|
target.observer = receiver;
|
||||||
mBusData_p[i].mTargettedFrames.removeAll(target);
|
mBusData_p[pBusId].mTargettedFrames.removeAll(target);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user