/****************************************************************************
**
** Copyright (C) 2016 Denis Shienkov <denis.shienkov@gmail.com>
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
    \page qtserialbus-vectorcan-overview.html
    \title Using VectorCAN Plugin

    \brief Overview of how to use the VectorCAN plugin.

    The VectorCAN plugin encapsulates the low-level API to work with the
    \l{http://www.vector.com/}{Vector Informatik} CAN adapters.

    This plugin requires the Vector CAN device drivers and the vxlapi.dll
    (vxlapi64.dll for 64 bit builds).

    \section1 Creating CAN Bus Devices

    At first it is necessary to check that QCanBus provides the desired plugin:

    \code
        if (QCanBus::instance()->plugins().contains(QStringLiteral("vectorcan"))) {
            // plugin available
        }
    \endcode

    Where \e vectorcan is the plugin name.

    Next, a connection to a specific interface can be established:

    \code
        QString errorString;
        QCanBusDevice *device = QCanBus::instance()->createDevice(
            QStringLiteral("vectorcan"), QStringLiteral("can0"), &errorString);
        if (!device) {
            // Error handling goes here
            qDebug << errorString;
        } else {
            device->connectDevice();
        }
    \endcode

    Where \e can0 is the active CAN channel name. The VectorCAN plugin provides
    64 channels (defined by XL_CONFIG_MAX_CHANNELS in the Vector API) from \e can0
    to \e can63. Some of these channels can be virtual, and therefore can be used
    without actual CAN hardware. To find out the virtual channels, the program
    "Vector Hardware Config" (vcanconf.exe) can be used, which is included in
    Vector's driver package. The \l {QCanBus::}{availableDevices()} method returns
    a list of currently available devices.

    The device is now open for writing and reading CAN frames:

    \code
        QCanBusFrame frame;
        frame.setFrameId(8);
        QByteArray payload("A36E");
        frame.setPayload(payload);
        device->writeFrame(frame);
    \endcode

    The reading can be done using the \l {QCanBusDevice::}{readFrame()} method. The
    \l {QCanBusDevice::}{framesReceived()} signal is emitted when at least one new frame
    is available for reading:

    \code
        QCanBusFrame frame = device->readFrame();
    \endcode

    VectorCAN supports the following configurations that can be controlled through
    \l {QCanBusDevice::}{setConfigurationParameter()}:

    \table
        \header
            \li Configuration parameter key
            \li Description
        \row
            \li QCanBusDevice::BitRateKey
            \li Determines the bit rate of the CAN bus connection.
        \row
            \li QCanBusDevice::ReceiveOwnKey
            \li The reception of the CAN frames on the same device that was sending the CAN frame
                is disabled by default. When enabling this option, all CAN frames sent to the CAN
                bus immediately appear in the receive buffer. This can be used to check if sending
                was successful. If this option is enabled, the therefore received frames are marked
                with QCanBusFrame::hasLocalEcho()
        \row
            \li QCanBusDevice::CanFdKey
            \li Enable the use of CAN FD on the CAN bus connection. If this option is enabled, then
                it is not possible to receive your own CAN frames being sent, so setting
                QCanBusDevice::ReceiveOwnKey to true has no effect. Since Qt 5.15.
        \row
            \li QCanBusDevice::DataBitRateKey
            \li Determines the data bit rate of the CAN bus connection. This is only available when
                \l QCanBusDevice::CanFdKey is set to true. Since Qt 5.15.
   \endtable

    VectorCAN supports the following additional functions:

    \list
        \li QCanBusDevice::busStatus()
    \endlist

*/
