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