summaryrefslogtreecommitdiffstats
path: root/src/serialbus/doc/src/socketcan.qdoc
diff options
context:
space:
mode:
Diffstat (limited to 'src/serialbus/doc/src/socketcan.qdoc')
-rw-r--r--src/serialbus/doc/src/socketcan.qdoc12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/serialbus/doc/src/socketcan.qdoc b/src/serialbus/doc/src/socketcan.qdoc
index a7cac9f..df58dae 100644
--- a/src/serialbus/doc/src/socketcan.qdoc
+++ b/src/serialbus/doc/src/socketcan.qdoc
@@ -111,13 +111,21 @@
Next, a connection to a specific interface can be established:
\code
+ QString errorString;
QCanBusDevice *device = QCanBus::instance()->createDevice(
- QStringLiteral("socketcan"), QStringLiteral("can0"));
- device->connectDevice();
+ QStringLiteral("socketcan"), QStringLiteral("can0"), &errorString);
+ if (!device) {
+ // Error handling goes here
+ qDebug << errorString;
+ } else {
+ device->connectDevice();
+ }
\endcode
Where \e can0 is the active CAN interface name. CAN interfaces act like regular
network interfaces on Linux systems and can be discovered using \c ifconfig.
+ Also, the \l {QCanBus::}{availableDevices()} method returns a list of currently
+ available devices.
The device is now open for writing and reading CAN frames: