Further work to get more buses working on the GVRET/M2RET devices
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
#ifndef CONFIG
|
#ifndef CONFIG
|
||||||
#define CONFIG
|
#define CONFIG
|
||||||
|
|
||||||
#define VERSION 178
|
#define VERSION 179
|
||||||
|
|
||||||
//try to keep this in sync.
|
//try to keep this in sync.
|
||||||
//SavvyCAN will complain if you connect a GVRET board with a revision
|
//SavvyCAN will complain if you connect a GVRET board with a revision
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#ifndef CANBus_H
|
#ifndef CANBus_H
|
||||||
#define CANBus_H
|
#define CANBus_H
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
|
#include "can_structs.h"
|
||||||
|
|
||||||
class CANBus
|
class CANBus
|
||||||
{
|
{
|
||||||
@@ -31,4 +32,10 @@ QDataStream & operator>>(QDataStream & pStream, CANBus& pCanBus);
|
|||||||
|
|
||||||
Q_DECLARE_METATYPE(CANBus);
|
Q_DECLARE_METATYPE(CANBus);
|
||||||
|
|
||||||
|
struct BusData {
|
||||||
|
CANBus mBus;
|
||||||
|
bool mConfigured;
|
||||||
|
QVector<CANFltObserver> mTargettedFrames;
|
||||||
|
};
|
||||||
|
|
||||||
#endif // CANBus_H
|
#endif // CANBus_H
|
||||||
|
|||||||
@@ -21,4 +21,11 @@ namespace CANCon {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class CANConStatus
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CANCon::status conStatus;
|
||||||
|
int numHardwareBuses;
|
||||||
|
};
|
||||||
|
|
||||||
#endif // CANCONCONST_H
|
#endif // CANCONCONST_H
|
||||||
|
|||||||
@@ -2,14 +2,6 @@
|
|||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include "canconnection.h"
|
#include "canconnection.h"
|
||||||
|
|
||||||
|
|
||||||
struct BusData {
|
|
||||||
CANBus mBus;
|
|
||||||
bool mConfigured;
|
|
||||||
QVector<CANFltObserver> mTargettedFrames;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
CANConnection::CANConnection(QString pPort,
|
CANConnection::CANConnection(QString pPort,
|
||||||
CANCon::type pType,
|
CANCon::type pType,
|
||||||
int pNumBuses,
|
int pNumBuses,
|
||||||
@@ -27,7 +19,7 @@ CANConnection::CANConnection(QString pPort,
|
|||||||
/* register types */
|
/* register types */
|
||||||
qRegisterMetaType<CANBus>("CANBus");
|
qRegisterMetaType<CANBus>("CANBus");
|
||||||
qRegisterMetaType<CANFrame>("CANFrame");
|
qRegisterMetaType<CANFrame>("CANFrame");
|
||||||
qRegisterMetaType<CANCon::status>("CANCon::status");
|
qRegisterMetaType<CANConStatus>("CANConStatus");
|
||||||
qRegisterMetaType<CANFltObserver>("CANFlt");
|
qRegisterMetaType<CANFltObserver>("CANFlt");
|
||||||
|
|
||||||
/* set queue size */
|
/* set queue size */
|
||||||
@@ -35,9 +27,9 @@ CANConnection::CANConnection(QString pPort,
|
|||||||
|
|
||||||
/* allocate buses */
|
/* allocate buses */
|
||||||
/* TODO: change those tables for a vector */
|
/* TODO: change those tables for a vector */
|
||||||
mBusData_p = new BusData[mNumBuses];
|
mBusData.resize(mNumBuses);
|
||||||
for(int i=0 ; i<mNumBuses ; i++) {
|
for(int i=0 ; i<mNumBuses ; i++) {
|
||||||
mBusData_p[i].mConfigured = false;
|
mBusData[i].mConfigured = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if needed, create a thread and move ourself into it */
|
/* if needed, create a thread and move ourself into it */
|
||||||
@@ -57,10 +49,7 @@ CANConnection::~CANConnection()
|
|||||||
mThread_p = NULL;
|
mThread_p = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mBusData_p) {
|
mBusData.clear();
|
||||||
delete[] mBusData_p;
|
|
||||||
mBusData_p = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -206,13 +195,13 @@ int CANConnection::getNumBuses() const{
|
|||||||
bool CANConnection::isConfigured(int pBusId) {
|
bool CANConnection::isConfigured(int pBusId) {
|
||||||
if( pBusId < 0 || pBusId >= getNumBuses())
|
if( pBusId < 0 || pBusId >= getNumBuses())
|
||||||
return false;
|
return false;
|
||||||
return mBusData_p[pBusId].mConfigured;
|
return mBusData[pBusId].mConfigured;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CANConnection::setConfigured(int pBusId, bool pConfigured) {
|
void CANConnection::setConfigured(int pBusId, bool pConfigured) {
|
||||||
if( pBusId < 0 || pBusId >= getNumBuses())
|
if( pBusId < 0 || pBusId >= getNumBuses())
|
||||||
return;
|
return;
|
||||||
mBusData_p[pBusId].mConfigured = pConfigured;
|
mBusData[pBusId].mConfigured = pConfigured;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -220,7 +209,7 @@ bool CANConnection::getBusConfig(int pBusId, CANBus& pBus) {
|
|||||||
if( pBusId < 0 || pBusId >= getNumBuses() || !isConfigured(pBusId))
|
if( pBusId < 0 || pBusId >= getNumBuses() || !isConfigured(pBusId))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
pBus = mBusData_p[pBusId].mBus;
|
pBus = mBusData[pBusId].mBus;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,8 +218,8 @@ void CANConnection::setBusConfig(int pBusId, CANBus& pBus) {
|
|||||||
if( pBusId < 0 || pBusId >= getNumBuses())
|
if( pBusId < 0 || pBusId >= getNumBuses())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mBusData_p[pBusId].mConfigured = true;
|
mBusData[pBusId].mConfigured = true;
|
||||||
mBusData_p[pBusId].mBus = pBus;
|
mBusData[pBusId].mBus = pBus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -293,7 +282,7 @@ bool CANConnection::addTargettedFrame(int pBusId, uint32_t ID, uint32_t mask, QO
|
|||||||
target.id = ID;
|
target.id = ID;
|
||||||
target.mask = mask;
|
target.mask = mask;
|
||||||
target.observer = receiver;
|
target.observer = receiver;
|
||||||
mBusData_p[pBusId].mTargettedFrames.append(target);
|
mBusData[pBusId].mTargettedFrames.append(target);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -321,7 +310,7 @@ bool CANConnection::removeTargettedFrame(int pBusId, uint32_t ID, uint32_t mask,
|
|||||||
target.id = ID;
|
target.id = ID;
|
||||||
target.mask = mask;
|
target.mask = mask;
|
||||||
target.observer = receiver;
|
target.observer = receiver;
|
||||||
mBusData_p[pBusId].mTargettedFrames.removeAll(target);
|
mBusData[pBusId].mTargettedFrames.removeAll(target);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -329,9 +318,9 @@ bool CANConnection::removeTargettedFrame(int pBusId, uint32_t ID, uint32_t mask,
|
|||||||
bool CANConnection::removeAllTargettedFrames(QObject *receiver)
|
bool CANConnection::removeAllTargettedFrames(QObject *receiver)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < getNumBuses(); i++) {
|
for (int i = 0; i < getNumBuses(); i++) {
|
||||||
foreach (const CANFltObserver filt, mBusData_p[i].mTargettedFrames)
|
foreach (const CANFltObserver filt, mBusData[i].mTargettedFrames)
|
||||||
{
|
{
|
||||||
if (filt.observer == receiver) mBusData_p[i].mTargettedFrames.removeOne(filt);
|
if (filt.observer == receiver) mBusData[i].mTargettedFrames.removeOne(filt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,10 +331,10 @@ void CANConnection::checkTargettedFrame(CANFrame &frame)
|
|||||||
{
|
{
|
||||||
unsigned int maskedID;
|
unsigned int maskedID;
|
||||||
//qDebug() << "Got frame with ID " << frame.ID << " on bus " << frame.bus;
|
//qDebug() << "Got frame with ID " << frame.ID << " on bus " << frame.bus;
|
||||||
if (mBusData_p == 0) return;
|
if (mBusData.count() == 0) return;
|
||||||
|
|
||||||
if (mBusData_p[frame.bus].mTargettedFrames.length() == 0) return;
|
if (mBusData[frame.bus].mTargettedFrames.length() == 0) return;
|
||||||
foreach (const CANFltObserver filt, mBusData_p[frame.bus].mTargettedFrames)
|
foreach (const CANFltObserver filt, mBusData[frame.bus].mTargettedFrames)
|
||||||
{
|
{
|
||||||
//qDebug() << "Checking filter with id " << filt.id << " mask " << filt.mask;
|
//qDebug() << "Checking filter with id " << filt.id << " mask " << filt.mask;
|
||||||
maskedID = frame.ID & filt.mask;
|
maskedID = frame.ID & filt.mask;
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ signals:
|
|||||||
* @brief event emitted when the CANCon::status of the connection changes (connected->not_connected or the other way round)
|
* @brief event emitted when the CANCon::status of the connection changes (connected->not_connected or the other way round)
|
||||||
* @param pStatus: the new status of the device
|
* @param pStatus: the new status of the device
|
||||||
*/
|
*/
|
||||||
void status(CANCon::status pStatus);
|
void status(CANConStatus pStatus);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Event sent when device has done something worthy of debugging output.
|
* @brief Event sent when device has done something worthy of debugging output.
|
||||||
@@ -183,7 +183,8 @@ public slots:
|
|||||||
void debugInput(QByteArray bytes);
|
void debugInput(QByteArray bytes);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int mNumBuses; //protected to allow connected device to figure out how many buses are available
|
int mNumBuses; //protected to allow connected device to figure out how many buses are available
|
||||||
|
QVector<BusData> mBusData;
|
||||||
|
|
||||||
//determine if the passed frame is part of a filter or not.
|
//determine if the passed frame is part of a filter or not.
|
||||||
void checkTargettedFrame(CANFrame &frame);
|
void checkTargettedFrame(CANFrame &frame);
|
||||||
@@ -297,7 +298,6 @@ private:
|
|||||||
bool mIsCapSuspended;
|
bool mIsCapSuspended;
|
||||||
QAtomicInt mStatus;
|
QAtomicInt mStatus;
|
||||||
bool mStarted;
|
bool mStarted;
|
||||||
BusData* mBusData_p;
|
|
||||||
QThread* mThread_p;
|
QThread* mThread_p;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -65,11 +65,13 @@ int CANConnectionModel::rowCount(const QModelIndex &parent) const
|
|||||||
{
|
{
|
||||||
Q_UNUSED(parent);
|
Q_UNUSED(parent);
|
||||||
|
|
||||||
int rows=0;
|
int rows = 0;
|
||||||
QList<CANConnection*>& conns = CANConManager::getInstance()->getConnections();
|
QList<CANConnection*>& conns = CANConManager::getInstance()->getConnections();
|
||||||
|
|
||||||
foreach(const CANConnection* conn_p, conns)
|
foreach(const CANConnection* conn_p, conns)
|
||||||
rows+=conn_p->getNumBuses();
|
rows += conn_p->getNumBuses();
|
||||||
|
|
||||||
|
qDebug() << "Num Rows: " << rows;
|
||||||
|
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
@@ -143,6 +145,7 @@ QVariant CANConnectionModel::data(const QModelIndex &index, int role) const
|
|||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
qDebug() << "Row: " << index.row();
|
||||||
|
|
||||||
int busId;
|
int busId;
|
||||||
CANConnection *conn_p = getAtIdx(index.row(), busId);
|
CANConnection *conn_p = getAtIdx(index.row(), busId);
|
||||||
@@ -151,6 +154,8 @@ QVariant CANConnectionModel::data(const QModelIndex &index, int role) const
|
|||||||
ret = conn_p->getBusSettings(busId, bus);
|
ret = conn_p->getBusSettings(busId, bus);
|
||||||
bool isSocketCAN = (conn_p->getType() == CANCon::SOCKETCAN) ? true: false;
|
bool isSocketCAN = (conn_p->getType() == CANCon::SOCKETCAN) ? true: false;
|
||||||
|
|
||||||
|
qDebug() << "ConnP: " << conn_p << " ret " << ret;
|
||||||
|
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
if(!conn_p)
|
if(!conn_p)
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@@ -254,6 +259,9 @@ CANConnection* CANConnectionModel::getAtIdx(int pIdx, int& pBusId) const
|
|||||||
|
|
||||||
void CANConnectionModel::refresh(int pIndex)
|
void CANConnectionModel::refresh(int pIndex)
|
||||||
{
|
{
|
||||||
|
beginResetModel();
|
||||||
|
endResetModel();
|
||||||
|
/*
|
||||||
QModelIndex begin;
|
QModelIndex begin;
|
||||||
QModelIndex end;
|
QModelIndex end;
|
||||||
|
|
||||||
@@ -265,5 +273,5 @@ void CANConnectionModel::refresh(int pIndex)
|
|||||||
begin = createIndex(0, 0);
|
begin = createIndex(0, 0);
|
||||||
end = createIndex(rowCount()-1, columnCount()-1);
|
end = createIndex(rowCount()-1, columnCount()-1);
|
||||||
}
|
}
|
||||||
dataChanged(begin, end, QVector<int>(Qt::DisplayRole));
|
dataChanged(begin, end, QVector<int>(Qt::DisplayRole)); */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ void ConnectionWindow::handleConnTypeChanged()
|
|||||||
|
|
||||||
|
|
||||||
/* status */
|
/* status */
|
||||||
void ConnectionWindow::connectionStatus(CANCon::status pStatus)
|
void ConnectionWindow::connectionStatus(CANConStatus pStatus)
|
||||||
{
|
{
|
||||||
Q_UNUSED(pStatus);
|
Q_UNUSED(pStatus);
|
||||||
|
|
||||||
@@ -208,34 +208,9 @@ void ConnectionWindow::connectionStatus(CANCon::status pStatus)
|
|||||||
|
|
||||||
void ConnectionWindow::handleOKButton()
|
void ConnectionWindow::handleOKButton()
|
||||||
{
|
{
|
||||||
int whichRow = ui->tableConnections->selectionModel()->currentIndex().row();
|
|
||||||
|
|
||||||
CANConnection* conn_p = NULL;
|
CANConnection* conn_p = NULL;
|
||||||
|
|
||||||
if (whichRow > -1)
|
if( ! CANConManager::getInstance()->getByName(getPortName()) )
|
||||||
{
|
|
||||||
/* set information for selected connection */
|
|
||||||
int busId;
|
|
||||||
CANBus bus;
|
|
||||||
bool ret;
|
|
||||||
|
|
||||||
conn_p = connModel->getAtIdx(whichRow, busId);
|
|
||||||
if(!conn_p) return;
|
|
||||||
|
|
||||||
ret = conn_p->getBusSettings(busId, bus);
|
|
||||||
if(!ret) return;
|
|
||||||
|
|
||||||
|
|
||||||
//bus.setListenOnly(ui->ckListenOnly->isChecked());
|
|
||||||
//bus.setSingleWire(ui->ckSingleWire->isChecked());
|
|
||||||
//bus.setEnabled(ui->ckEnabled->isChecked());
|
|
||||||
//bus.setSpeed(ui->cbSpeed->currentText().toInt());
|
|
||||||
/* update bus settings */
|
|
||||||
conn_p->setBusSettings(busId, bus);
|
|
||||||
|
|
||||||
connModel->refresh(whichRow);
|
|
||||||
}
|
|
||||||
else if( ! CANConManager::getInstance()->getByName(getPortName()) )
|
|
||||||
{
|
{
|
||||||
/* create connection */
|
/* create connection */
|
||||||
conn_p = create(getConnectionType(), getPortName());
|
conn_p = create(getConnectionType(), getPortName());
|
||||||
@@ -483,8 +458,8 @@ CANConnection* ConnectionWindow::create(CANCon::type pTye, QString pPortName)
|
|||||||
if(conn_p)
|
if(conn_p)
|
||||||
{
|
{
|
||||||
/* connect signal */
|
/* connect signal */
|
||||||
connect(conn_p, SIGNAL(status(CANCon::status)),
|
connect(conn_p, SIGNAL(status(CANConStatus)),
|
||||||
this, SLOT(connectionStatus(CANCon::status)));
|
this, SLOT(connectionStatus(CANConStatus)));
|
||||||
|
|
||||||
/*TODO add return value and checks */
|
/*TODO add return value and checks */
|
||||||
conn_p->start();
|
conn_p->start();
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ private slots:
|
|||||||
void handleClearDebugText();
|
void handleClearDebugText();
|
||||||
void handleSendHex();
|
void handleSendHex();
|
||||||
void handleSendText();
|
void handleSendText();
|
||||||
void connectionStatus(CANCon::status);
|
void connectionStatus(CANConStatus);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ConnectionWindow *ui;
|
Ui::ConnectionWindow *ui;
|
||||||
|
|||||||
+105
-8
@@ -232,6 +232,10 @@ void GVRetSerial::connectDevice()
|
|||||||
output.append((char)0xE7); //this puts the device into binary comm mode
|
output.append((char)0xE7); //this puts the device into binary comm mode
|
||||||
output.append((char)0xE7);
|
output.append((char)0xE7);
|
||||||
|
|
||||||
|
output.append((char)0xF1);
|
||||||
|
output.append((char)0x0C); //get number of actually implemented buses. Not implemented except on M2RET
|
||||||
|
mNumBuses = 2; //the proper number if C/12 is not implemented
|
||||||
|
|
||||||
output.append((char)0xF1); //signal we want to issue a command
|
output.append((char)0xF1); //signal we want to issue a command
|
||||||
output.append((char)0x06); //request canbus stats from the board
|
output.append((char)0x06); //request canbus stats from the board
|
||||||
|
|
||||||
@@ -249,15 +253,11 @@ void GVRetSerial::connectDevice()
|
|||||||
output.append((char)0xFF); //signal we don't want single wire mode
|
output.append((char)0xFF); //signal we don't want single wire mode
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
output.append((char)0xF1); //yet another command
|
|
||||||
output.append((char)0x09); //comm validation command
|
|
||||||
|
|
||||||
output.append((char)0xF1); //and another command
|
output.append((char)0xF1); //and another command
|
||||||
output.append((char)0x01); //Time Sync - Not implemented until 333 but we can try
|
output.append((char)0x01); //Time Sync - Not implemented until 333 but we can try
|
||||||
|
|
||||||
output.append((char)0xF1);
|
output.append((char)0xF1); //yet another command
|
||||||
output.append((char)0x12); //get number of actually implemented buses. Not implemented except on M2RET
|
output.append((char)0x09); //comm validation command
|
||||||
mNumBuses = 2; //the proper number if 0x12 is not implemented
|
|
||||||
|
|
||||||
continuousTimeSync = true;
|
continuousTimeSync = true;
|
||||||
|
|
||||||
@@ -274,7 +274,10 @@ void GVRetSerial::connectDevice()
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setStatus(CANCon::CONNECTED);
|
setStatus(CANCon::CONNECTED);
|
||||||
emit status(getStatus());
|
CANConStatus stats;
|
||||||
|
stats.conStatus = getStatus();
|
||||||
|
stats.numHardwareBuses = mNumBuses;
|
||||||
|
emit status(stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* connect reading event */
|
/* connect reading event */
|
||||||
@@ -336,6 +339,10 @@ void GVRetSerial::debugInput(QByteArray bytes) {
|
|||||||
|
|
||||||
void GVRetSerial::procRXChar(unsigned char c)
|
void GVRetSerial::procRXChar(unsigned char c)
|
||||||
{
|
{
|
||||||
|
CANConStatus stats;
|
||||||
|
int oldBuses;
|
||||||
|
QByteArray output;
|
||||||
|
|
||||||
switch (rx_state)
|
switch (rx_state)
|
||||||
{
|
{
|
||||||
case IDLE:
|
case IDLE:
|
||||||
@@ -380,6 +387,12 @@ void GVRetSerial::procRXChar(unsigned char c)
|
|||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
rx_state = GET_NUM_BUSES;
|
rx_state = GET_NUM_BUSES;
|
||||||
|
qDebug() << "Got num buses reply";
|
||||||
|
rx_step = 0;
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
rx_state = GET_EXT_BUSES;
|
||||||
|
qDebug() << "Got extended buses info reply";
|
||||||
rx_step = 0;
|
rx_step = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -545,6 +558,8 @@ void GVRetSerial::procRXChar(unsigned char c)
|
|||||||
rx_state = IDLE;
|
rx_state = IDLE;
|
||||||
qDebug() << "Baud 0 = " << can0Baud;
|
qDebug() << "Baud 0 = " << can0Baud;
|
||||||
qDebug() << "Baud 1 = " << can1Baud;
|
qDebug() << "Baud 1 = " << can1Baud;
|
||||||
|
mBusData[0].mBus.setSpeed(can0Baud);
|
||||||
|
mBusData[1].mBus.setSpeed(can1Baud);
|
||||||
|
|
||||||
can0Baud |= 0x80000000;
|
can0Baud |= 0x80000000;
|
||||||
if (can0Enabled) can0Baud |= 0x40000000;
|
if (can0Enabled) can0Baud |= 0x40000000;
|
||||||
@@ -556,7 +571,9 @@ void GVRetSerial::procRXChar(unsigned char c)
|
|||||||
if (deviceSingleWireMode > 0) can1Baud |= 0x10000000;
|
if (deviceSingleWireMode > 0) can1Baud |= 0x10000000;
|
||||||
|
|
||||||
setStatus(CANCon::CONNECTED);
|
setStatus(CANCon::CONNECTED);
|
||||||
emit status(getStatus());
|
stats.conStatus = getStatus();
|
||||||
|
stats.numHardwareBuses = mNumBuses;
|
||||||
|
emit status(stats);
|
||||||
|
|
||||||
int can0Status = 0x78; //updating everything we can update
|
int can0Status = 0x78; //updating everything we can update
|
||||||
int can1Status = 0x78;
|
int can1Status = 0x78;
|
||||||
@@ -606,8 +623,88 @@ void GVRetSerial::procRXChar(unsigned char c)
|
|||||||
rx_state = IDLE;
|
rx_state = IDLE;
|
||||||
break;
|
break;
|
||||||
case GET_NUM_BUSES:
|
case GET_NUM_BUSES:
|
||||||
|
oldBuses = mNumBuses;
|
||||||
mNumBuses = c;
|
mNumBuses = c;
|
||||||
rx_state = IDLE;
|
rx_state = IDLE;
|
||||||
|
qDebug() << "Get number of buses = " << mNumBuses;
|
||||||
|
stats.conStatus = getStatus();
|
||||||
|
stats.numHardwareBuses = mNumBuses;
|
||||||
|
mBusData.resize(mNumBuses);
|
||||||
|
if (mNumBuses > oldBuses)
|
||||||
|
{
|
||||||
|
for (int i = oldBuses; i < mNumBuses; i++)
|
||||||
|
{
|
||||||
|
mBusData[i].mConfigured = true;
|
||||||
|
mBusData[i].mBus = mBusData[0].mBus;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
output.append((char)0xF1); //start a new command
|
||||||
|
output.append((char)13); //get extended buses
|
||||||
|
serial->write(output);
|
||||||
|
|
||||||
|
emit status(stats);
|
||||||
|
break;
|
||||||
|
case GET_EXT_BUSES:
|
||||||
|
switch (rx_step)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
swcanEnabled = (c & 0xF);
|
||||||
|
swcanListenOnly = (c >> 4);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
swcanBaud = c;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
swcanBaud |= c << 8;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
swcanBaud |= c << 16;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
swcanBaud |= c << 24;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
lin1Enabled = (c & 0xF);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
lin1Baud = c;
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
lin1Baud |= c << 8;
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
lin1Baud |= c << 16;
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
lin1Baud |= c << 24;
|
||||||
|
case 10:
|
||||||
|
lin2Enabled = (c & 0xF);
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
|
lin2Baud = c;
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
lin2Baud |= c << 8;
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
lin2Baud |= c << 16;
|
||||||
|
break;
|
||||||
|
case 14:
|
||||||
|
lin2Baud |= c << 24;
|
||||||
|
rx_state = IDLE;
|
||||||
|
qDebug() << "SWCAN Baud = " << swcanBaud;
|
||||||
|
qDebug() << "LIN1 Baud = " << lin1Baud;
|
||||||
|
qDebug() << "LIN2 Baud = " << lin2Baud;
|
||||||
|
mBusData[2].mBus.setSpeed(swcanBaud);
|
||||||
|
|
||||||
|
setStatus(CANCon::CONNECTED);
|
||||||
|
stats.conStatus = getStatus();
|
||||||
|
stats.numHardwareBuses = mNumBuses;
|
||||||
|
emit status(stats);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
rx_step++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
namespace SERIALSTATE {
|
namespace SERIALSTATE {
|
||||||
|
|
||||||
enum STATE //keep this enum synchronized with the Arduino firmware project
|
enum STATE
|
||||||
{
|
{
|
||||||
IDLE,
|
IDLE,
|
||||||
GET_COMMAND,
|
GET_COMMAND,
|
||||||
@@ -29,12 +29,12 @@ enum STATE //keep this enum synchronized with the Arduino firmware project
|
|||||||
GET_CANBUS_PARAMS,
|
GET_CANBUS_PARAMS,
|
||||||
GET_DEVICE_INFO,
|
GET_DEVICE_INFO,
|
||||||
SET_SINGLEWIRE_MODE,
|
SET_SINGLEWIRE_MODE,
|
||||||
GET_NUM_BUSES
|
GET_NUM_BUSES,
|
||||||
|
GET_EXT_BUSES
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
using namespace SERIALSTATE;
|
using namespace SERIALSTATE;
|
||||||
class GVRetSerial : public CANConnection
|
class GVRetSerial : public CANConnection
|
||||||
{
|
{
|
||||||
@@ -83,9 +83,9 @@ protected:
|
|||||||
STATE rx_state;
|
STATE rx_state;
|
||||||
uint32_t rx_step;
|
uint32_t rx_step;
|
||||||
CANFrame buildFrame;
|
CANFrame buildFrame;
|
||||||
int can0Baud, can1Baud;
|
int can0Baud, can1Baud, swcanBaud, lin1Baud, lin2Baud;
|
||||||
bool can0Enabled, can1Enabled;
|
bool can0Enabled, can1Enabled, swcanEnabled, lin1Enabled, lin2Enabled;
|
||||||
bool can0ListenOnly, can1ListenOnly;
|
bool can0ListenOnly, can1ListenOnly, swcanListenOnly;
|
||||||
int deviceBuildNum;
|
int deviceBuildNum;
|
||||||
int deviceSingleWireMode;
|
int deviceSingleWireMode;
|
||||||
uint32_t buildTimeBasis;
|
uint32_t buildTimeBasis;
|
||||||
|
|||||||
@@ -211,6 +211,7 @@ void SocketCan::framesReceived()
|
|||||||
|
|
||||||
void SocketCan::testConnection() {
|
void SocketCan::testConnection() {
|
||||||
QCanBusDevice* dev_p = QCanBus::instance()->createDevice("socketcan", getPort());
|
QCanBusDevice* dev_p = QCanBus::instance()->createDevice("socketcan", getPort());
|
||||||
|
CANConStatus stats;
|
||||||
|
|
||||||
switch(getStatus())
|
switch(getStatus())
|
||||||
{
|
{
|
||||||
@@ -220,7 +221,9 @@ void SocketCan::testConnection() {
|
|||||||
disconnectDevice();
|
disconnectDevice();
|
||||||
|
|
||||||
setStatus(CANCon::NOT_CONNECTED);
|
setStatus(CANCon::NOT_CONNECTED);
|
||||||
emit status(getStatus());
|
stats.conStatus = getStatus();
|
||||||
|
stats.numHardwareBuses = mNumBuses;
|
||||||
|
emit status(stats);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CANCon::NOT_CONNECTED:
|
case CANCon::NOT_CONNECTED:
|
||||||
@@ -235,7 +238,9 @@ void SocketCan::testConnection() {
|
|||||||
dev_p->disconnectDevice();
|
dev_p->disconnectDevice();
|
||||||
|
|
||||||
setStatus(CANCon::CONNECTED);
|
setStatus(CANCon::CONNECTED);
|
||||||
emit status(getStatus());
|
stats.conStatus = getStatus();
|
||||||
|
stats.numHardwareBuses = mNumBuses;
|
||||||
|
emit status(stats);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default: {}
|
default: {}
|
||||||
|
|||||||
Reference in New Issue
Block a user