Implemented connection save with speeds and can fd at least for bus 0.
This commit is contained in:
@@ -14,7 +14,7 @@ CANConnection* CanConFactory::create(type pType, QString pPortName, QString pDri
|
||||
{
|
||||
switch(pType) {
|
||||
case SERIALBUS:
|
||||
return new SerialBusConnection(pPortName, pDriverName);
|
||||
return new SerialBusConnection(pPortName, pDriverName, pBusSpeed, pDataRate, pCanFd);
|
||||
case GVRET_SERIAL:
|
||||
if(pPortName.contains(".") && !pPortName.contains("tty") && !pPortName.contains("serial"))
|
||||
return new GVRetSerial(pPortName, true);
|
||||
|
||||
@@ -41,8 +41,13 @@ CANConnection::CANConnection(QString pPort,
|
||||
|
||||
if (pBusSpeed > 0) mBusData[0].mBus.setSpeed(pBusSpeed);
|
||||
mBusData[0].mBus.setCanFD(pCanFd);
|
||||
if (pDataRate > 0) mBusData[0].mBus.setDataRate(pDataRate);
|
||||
|
||||
if (pDataRate > 0) {
|
||||
mBusData[0].mBus.setDataRate(pDataRate);
|
||||
if (pCanFd) {
|
||||
mBusData[0].mBus.setCanFD(pCanFd);
|
||||
}
|
||||
}
|
||||
|
||||
/* if needed, create a thread and move ourself into it */
|
||||
if(pUseThread) {
|
||||
mThread_p = new QThread();
|
||||
@@ -210,6 +215,10 @@ int CANConnection::getNumBuses() const{
|
||||
return mNumBuses;
|
||||
}
|
||||
|
||||
int CANConnection::getSerialSpeed() const{
|
||||
return mSerialSpeed;
|
||||
}
|
||||
|
||||
|
||||
bool CANConnection::isConfigured(int pBusId) {
|
||||
if( pBusId < 0 || pBusId >= getNumBuses())
|
||||
|
||||
@@ -52,6 +52,12 @@ public:
|
||||
*/
|
||||
int getNumBuses() const;
|
||||
|
||||
/**
|
||||
* @brief getserialSpeed
|
||||
* @return returns the serial speed of the device
|
||||
*/
|
||||
int getSerialSpeed() const;
|
||||
|
||||
/**
|
||||
* @brief getPort
|
||||
* @return returns the port name of the device
|
||||
|
||||
@@ -551,13 +551,17 @@ void ConnectionWindow::loadConnections()
|
||||
QVector<QString> driverNames = settings.value("connections/driverNames").value<QVector<QString>>();
|
||||
QVector<int> devTypes = settings.value("connections/types").value<QVector<int>>();
|
||||
|
||||
QVector<int> busSpeeds = settings.value("connections/busSpeeds_0").value<QVector<int>>();
|
||||
QVector<int> DataRates = settings.value("connections/DataRates_0").value<QVector<int>>();
|
||||
QVector<int> isCanFds = settings.value("connections/isCanFds_0").value<QVector<int>>();
|
||||
QVector<int> serialSpeeds = settings.value("connections/serialSpeeds").value<QVector<int>>();
|
||||
//don't load the connections if the three setting arrays above aren't all the same size.
|
||||
if (portNames.count() != driverNames.count() || devTypes.count() != driverNames.count()) return;
|
||||
if (portNames.count() != driverNames.count() || devTypes.count() != driverNames.count() || busSpeeds.count() != driverNames.count() || isCanFds.count() != driverNames.count() ||
|
||||
DataRates.count() != driverNames.count() || serialSpeeds.count() != driverNames.count() ) return;
|
||||
|
||||
for(int i = 0 ; i < portNames.count() ; i++)
|
||||
{
|
||||
//TODO: add serial speed and bus speed to this properly.
|
||||
CANConnection* conn_p = create((CANCon::type)devTypes[i], portNames[i], driverNames[i], 0, 0, false, 0);
|
||||
CANConnection* conn_p = create((CANCon::type)devTypes[i], portNames[i], driverNames[i], serialSpeeds[i], busSpeeds[i], isCanFds[i] ? true : false, DataRates[i]);
|
||||
/* add connection to model */
|
||||
connModel->add(conn_p);
|
||||
}
|
||||
@@ -577,10 +581,19 @@ void ConnectionWindow::saveConnections()
|
||||
QVector<QString> driverNames;
|
||||
QVector<int> serialSpeeds;
|
||||
QVector<int> busSpeeds;
|
||||
|
||||
QVector<int> DataRates;
|
||||
QVector<int> CanFds;
|
||||
|
||||
/* save connections */
|
||||
foreach(CANConnection* conn_p, conns)
|
||||
{
|
||||
{ CANBus bus;
|
||||
|
||||
if (conn_p->getBusSettings(0, bus)) {
|
||||
busSpeeds.append(bus.getSpeed());
|
||||
CanFds.append(bus.isCanFD() ? 1 : 0);
|
||||
DataRates.append(bus.getDataRate());
|
||||
}
|
||||
serialSpeeds.append(conn_p->getSerialSpeed());
|
||||
portNames.append(conn_p->getPort());
|
||||
devTypes.append(conn_p->getType());
|
||||
driverNames.append(conn_p->getDriver());
|
||||
@@ -589,6 +602,10 @@ void ConnectionWindow::saveConnections()
|
||||
settings.setValue("connections/portNames", QVariant::fromValue(portNames));
|
||||
settings.setValue("connections/types", QVariant::fromValue(devTypes));
|
||||
settings.setValue("connections/driverNames", QVariant::fromValue(driverNames));
|
||||
settings.setValue("connections/busSpeeds_0", QVariant::fromValue(busSpeeds));
|
||||
settings.setValue("connections/isCanFds_0", QVariant::fromValue(CanFds));
|
||||
settings.setValue("connections/DataRates_0", QVariant::fromValue(DataRates));
|
||||
settings.setValue("connections/serialSpeeds", QVariant::fromValue(serialSpeeds));
|
||||
}
|
||||
|
||||
void ConnectionWindow::moveConnUp()
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
/**** class definition ****/
|
||||
/***********************************/
|
||||
|
||||
SerialBusConnection::SerialBusConnection(QString portName, QString driverName) :
|
||||
CANConnection(portName, driverName, CANCon::SERIALBUS,0 ,0, false, 0 ,1, 4000, true),
|
||||
SerialBusConnection::SerialBusConnection(QString portName, QString driverName, int pBusSpeed, int pDataRate, bool pCanFd) :
|
||||
CANConnection(portName, driverName, CANCon::SERIALBUS,0 ,pBusSpeed, pCanFd, pDataRate ,1, 4000, true),
|
||||
mTimer(this) /*NB: set connection as parent of timer to manage it from working thread */
|
||||
{
|
||||
}
|
||||
|
||||
@@ -27,7 +27,8 @@ class SerialBusConnection : public CANConnection
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SerialBusConnection(QString portName, QString driverName);
|
||||
SerialBusConnection(QString portName, QString driverName, int pBusSpeed,
|
||||
int pDataRate, bool pCanFd);
|
||||
virtual ~SerialBusConnection();
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user