Changed the way the filter system works in the CAN connection objects - now used only for sending frames immediately to relevant objects. Tested to work in firmware updater. Currently broken elsewhere. Also switched main frame update interval from 4 times per second to 8 to make things smoother.
This commit is contained in:
@@ -17,7 +17,7 @@ CANConManager* CANConManager::getInstance()
|
||||
CANConManager::CANConManager(QObject *parent): QObject(parent)
|
||||
{
|
||||
connect(&mTimer, SIGNAL(timeout()), this, SLOT(refreshCanList()));
|
||||
mTimer.setInterval(250); /*tick 4 times a second */
|
||||
mTimer.setInterval(125); /*tick 8 times a second */
|
||||
mTimer.setSingleShot(false);
|
||||
mTimer.start();
|
||||
|
||||
@@ -38,7 +38,8 @@ CANConManager::~CANConManager()
|
||||
|
||||
void CANConManager::add(CANConnection* pConn_p)
|
||||
{
|
||||
connect(pConn_p, SIGNAL(notify()), this, SLOT(refreshCanList()));
|
||||
//connect(pConn_p, SIGNAL(notify()), this, SLOT(refreshCanList()));
|
||||
connect(pConn_p, SIGNAL(targettedFrameReceived(CANFrame)), this, SLOT(gotTargettedFrame(CANFrame)));
|
||||
mConns.append(pConn_p);
|
||||
emit connectionStatusUpdated(getNumBuses());
|
||||
}
|
||||
@@ -179,3 +180,67 @@ bool CANConManager::sendFrames(const QList<CANFrame>& pFrames)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//For each device associated with buses go through and see if that device has a bus
|
||||
//that the filter should apply to. If so forward the data on but fudge
|
||||
//the bus numbers if bus wasn't -1 so that they're local to the device
|
||||
bool CANConManager::addTargettedFrame(int pBusId, const CANFlt &target)
|
||||
{
|
||||
int tempBusVal;
|
||||
int busBase = 0;
|
||||
|
||||
foreach (CANConnection* conn, mConns)
|
||||
{
|
||||
if (pBusId == -1) conn->addTargettedFrame(pBusId, target);
|
||||
else
|
||||
{
|
||||
tempBusVal = pBusId >> busBase;
|
||||
tempBusVal &= ((1 << conn->getNumBuses()) - 1);
|
||||
if (tempBusVal) {
|
||||
qDebug() << "Forwarding targetted frame setting to a connection object";
|
||||
conn->addTargettedFrame(tempBusVal, target);
|
||||
}
|
||||
}
|
||||
busBase += conn->getNumBuses();
|
||||
}
|
||||
}
|
||||
|
||||
bool CANConManager::removeTargettedFrame(int pBusId, const CANFlt &target)
|
||||
{
|
||||
int tempBusVal;
|
||||
int busBase = 0;
|
||||
|
||||
foreach (CANConnection* conn, mConns)
|
||||
{
|
||||
if (pBusId == -1) conn->removeTargettedFrame(pBusId, target);
|
||||
else
|
||||
{
|
||||
tempBusVal = pBusId >> busBase;
|
||||
tempBusVal &= ((1 << conn->getNumBuses()) - 1);
|
||||
if (tempBusVal) conn->removeTargettedFrame(tempBusVal, target);
|
||||
}
|
||||
busBase += conn->getNumBuses();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* A connected CANConnection object has passed us a frame that one or more
|
||||
* other objects are interested in. Fix up the bus number to be a system global bus
|
||||
* number instead of connection local bus number then send it off again.
|
||||
*/
|
||||
void CANConManager::gotTargettedFrame(CANFrame frame)
|
||||
{
|
||||
int busBase = 0;
|
||||
|
||||
foreach (CANConnection* conn, mConns)
|
||||
{
|
||||
if (conn != sender()) busBase += conn->getNumBuses();
|
||||
else break;
|
||||
}
|
||||
|
||||
qDebug() << "Targetted frame, offset was " << busBase << " id was " << frame.ID;
|
||||
|
||||
frame.bus += busBase;
|
||||
|
||||
emit targettedFrameReceived(frame);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user