SerialBusConnection: Improve connect/disconnect handling
* disconnectDevice() already checks mDev_p * use the error description provided by QCanBus::createDevice()
This commit is contained in:
@@ -67,7 +67,6 @@ void SerialBusConnection::piSetBusSettings(int pBusIdx, CANBus bus)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* disconnect device if we have one connected */
|
/* disconnect device if we have one connected */
|
||||||
if(mDev_p)
|
|
||||||
disconnectDevice();
|
disconnectDevice();
|
||||||
|
|
||||||
/* copy bus config */
|
/* copy bus config */
|
||||||
@@ -78,10 +77,11 @@ void SerialBusConnection::piSetBusSettings(int pBusIdx, CANBus bus)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* create device */
|
/* create device */
|
||||||
mDev_p = QCanBus::instance()->createDevice("socketcan", getPort());
|
QString errorString;
|
||||||
|
mDev_p = QCanBus::instance()->createDevice("socketcan", getPort(), &errorString);
|
||||||
if (!mDev_p) {
|
if (!mDev_p) {
|
||||||
disconnectDevice();
|
disconnectDevice();
|
||||||
qDebug() << "can't create device";
|
qDebug() << "Error: createDevice(" << getType() << getPort() << "):" << errorString;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user