1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2017 Andre Hartmann <aha_1980@gmx.de> |
4 | ** Contact: http://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the QtSerialBus module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL3$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see http://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at http://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPLv3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or later as published by the Free |
28 | ** Software Foundation and appearing in the file LICENSE.GPL included in |
29 | ** the packaging of this file. Please review the following information to |
30 | ** ensure the GNU General Public License version 2.0 requirements will be |
31 | ** met: http://www.gnu.org/licenses/gpl-2.0.html. |
32 | ** |
33 | ** $QT_END_LICENSE$ |
34 | ** |
35 | ****************************************************************************/ |
36 | |
37 | #include "qcanbusdeviceinfo.h" |
38 | #include "qcanbusdeviceinfo_p.h" |
39 | |
40 | QT_BEGIN_NAMESPACE |
41 | |
42 | /*! |
43 | \class QCanBusDeviceInfo |
44 | \inmodule QtSerialBus |
45 | \since 5.9 |
46 | |
47 | \brief The QCanBusDeviceInfo provides information about CAN bus interfaces. |
48 | |
49 | Each plugin may support one or more interfaces with different |
50 | capabilities. This class provides information about available functions. |
51 | */ |
52 | |
53 | /*! |
54 | Constructs a copy of \a other. |
55 | */ |
56 | QCanBusDeviceInfo::QCanBusDeviceInfo(const QCanBusDeviceInfo &) = default; |
57 | |
58 | /*! |
59 | Constructs a CAN bus device info from QCanBusDeviceInfoPrivate \a dd. |
60 | \internal |
61 | */ |
62 | QCanBusDeviceInfo::QCanBusDeviceInfo(QCanBusDeviceInfoPrivate &dd) : |
63 | d_ptr(&dd) |
64 | { |
65 | } |
66 | |
67 | /*! |
68 | Destroys the CAN bus device info. |
69 | */ |
70 | QCanBusDeviceInfo::~QCanBusDeviceInfo() = default; |
71 | |
72 | /*! |
73 | \fn void QCanBusDeviceInfo::swap(QCanBusDeviceInfo &other) |
74 | Swaps this CAN bus device info with \a other. This operation is very fast |
75 | and never fails. |
76 | */ |
77 | |
78 | /*! |
79 | \fn QCanBusDeviceInfo &QCanBusDeviceInfo::operator=(QCanBusDeviceInfo &&other) |
80 | |
81 | Move-assigns other to this QCanBusDeviceInfo instance. |
82 | */ |
83 | |
84 | /*! |
85 | Assigns \a other to this CAN bus device info and returns a reference to this |
86 | CAN bus device info. |
87 | */ |
88 | QCanBusDeviceInfo &QCanBusDeviceInfo::operator=(const QCanBusDeviceInfo &) = default; |
89 | |
90 | /*! |
91 | Returns the interface name of this CAN bus interface, e.g. can0. |
92 | */ |
93 | QString QCanBusDeviceInfo::name() const |
94 | { |
95 | return d_ptr->name; |
96 | } |
97 | |
98 | /*! |
99 | \since 5.11 |
100 | Returns a textual description of the CAN bus interface, if available. |
101 | Example output: "PCAN USB Pro FD". If no description is available, |
102 | an empty string is returned. |
103 | */ |
104 | QString QCanBusDeviceInfo::description() const |
105 | { |
106 | return d_ptr->description; |
107 | } |
108 | |
109 | /*! |
110 | \since 5.11 |
111 | Returns the serial number of the CAN bus interface as string, if available. |
112 | Otherwise, an empty string is returned. |
113 | */ |
114 | QString QCanBusDeviceInfo::serialNumber() const |
115 | { |
116 | return d_ptr->serialNumber; |
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 | |