1// Copyright (C) 2017 Andre Hartmann <aha_1980@gmx.de>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qcanbusdeviceinfo.h"
5#include "qcanbusdeviceinfo_p.h"
6
7QT_BEGIN_NAMESPACE
8
9QT_DEFINE_QSDP_SPECIALIZATION_DTOR(QCanBusDeviceInfoPrivate)
10
11/*!
12 \class QCanBusDeviceInfo
13 \inmodule QtSerialBus
14 \since 5.9
15
16 \brief The QCanBusDeviceInfo provides information about CAN bus interfaces.
17
18 Each plugin may support one or more interfaces with different
19 capabilities. This class provides information about available functions.
20*/
21
22/*!
23 Constructs a copy of \a other.
24*/
25QCanBusDeviceInfo::QCanBusDeviceInfo(const QCanBusDeviceInfo &) = default;
26
27/*!
28 \fn QCanBusDeviceInfo::QCanBusDeviceInfo(QCanBusDeviceInfo &&other)
29
30 Move-constructs a CAN bus device info from \a other.
31 \since 6.10
32*/
33
34/*!
35 Constructs a CAN bus device info from QCanBusDeviceInfoPrivate \a dd.
36 \internal
37*/
38QCanBusDeviceInfo::QCanBusDeviceInfo(QCanBusDeviceInfoPrivate &dd) :
39 d_ptr(&dd)
40{
41}
42
43/*!
44 Destroys the CAN bus device info.
45*/
46QCanBusDeviceInfo::~QCanBusDeviceInfo() = default;
47
48/*!
49 \fn void QCanBusDeviceInfo::swap(QCanBusDeviceInfo &other)
50 Swaps this CAN bus device info with \a other. This operation is very fast
51 and never fails.
52*/
53
54/*!
55 \fn QCanBusDeviceInfo &QCanBusDeviceInfo::operator=(QCanBusDeviceInfo &&other)
56
57 Move-assigns \a other to this QCanBusDeviceInfo instance.
58*/
59
60/*!
61 Assigns \a other to this CAN bus device info and returns a reference to this
62 CAN bus device info.
63*/
64QCanBusDeviceInfo &QCanBusDeviceInfo::operator=(const QCanBusDeviceInfo &) = default;
65
66 /*!
67 \since 6.2
68 Returns the plugin name of this CAN bus interface, e.g. "peakcan".
69
70 This corresponds to the \c plugin parameter of QCanBus::createDevice().
71 */
72QString QCanBusDeviceInfo::plugin() const
73{
74 return d_ptr->plugin;
75}
76
77/*!
78 Returns the interface name of this CAN bus interface, e.g. "can0".
79
80 This corresponds to the \c interfaceName parameter of QCanBus::createDevice().
81*/
82QString QCanBusDeviceInfo::name() const
83{
84 return d_ptr->name;
85}
86
87/*!
88 \since 5.11
89 Returns a textual description of the CAN bus interface, if available.
90 Example output: "PCAN USB Pro FD". If no description is available,
91 an empty string is returned.
92*/
93QString QCanBusDeviceInfo::description() const
94{
95 return d_ptr->description;
96}
97
98/*!
99 \since 5.11
100 Returns the serial number of the CAN bus interface as string, if available.
101 Otherwise, an empty string is returned.
102
103 \sa alias()
104*/
105QString QCanBusDeviceInfo::serialNumber() const
106{
107 return d_ptr->serialNumber;
108}
109
110/*!
111 \since 6.0
112 Returns a user defineable alias associated with this CAN bus interface.
113
114 Some CAN bus interfaces can have a user defined alias associated. This is mostly
115 done with the CAN hardware vendors tools. The alias allows to identify this
116 hardware later, especially when multiple interfaces are connected.
117
118 \note In contrast to serialNumber(), the alias is not guaranteed to be unique.
119
120 If this function is not supported by the CAN plugin, an empty string is returned.
121 \sa serialNumber()
122*/
123QString QCanBusDeviceInfo::alias() const
124{
125 return d_ptr->alias;
126}
127
128/*!
129 \since 5.11
130 Returns the sequential channel number of the CAN bus interface, starting
131 with zero. For example, a two channel CAN interface may have the channels
132 0 and 1. If the interface has only one channel or if no information about
133 the channel is available, zero is returned.
134*/
135int QCanBusDeviceInfo::channel() const
136{
137 return d_ptr->channel;
138}
139
140/*!
141 Returns true, if the CAN bus interface is CAN FD (flexible data rate) capable.
142
143 If this information is not available, false is returned.
144*/
145bool QCanBusDeviceInfo::hasFlexibleDataRate() const
146{
147 return d_ptr->hasFlexibleDataRate;
148}
149
150/*!
151 Returns true, if the CAN bus interface is virtual (i.e. not connected to real
152 CAN hardware).
153
154 If this information is not available, false is returned.
155*/
156bool QCanBusDeviceInfo::isVirtual() const
157{
158 return d_ptr->isVirtual;
159}
160
161QT_END_NAMESPACE
162

source code of qtserialbus/src/serialbus/qcanbusdeviceinfo.cpp