Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
nmea.qdoc
Go to the documentation of this file.
1
// Copyright (C) 2021 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4
/*!
5
\page position-plugin-nmea.html
6
\title Qt Positioning NMEA plugin
7
\ingroup QtPositioning-plugins
8
9
\brief Reads the NMEA stream to provide position updates.
10
11
\section1 Overview
12
13
Included with Qt Positioning is a position plugin which parses NMEA sentences
14
into position updates. This plugin can use serial port, socket or file as a
15
source.
16
17
This plugin can be loaded by using the provider name \b nmea.
18
19
\section1 Parameters
20
21
The following table lists parameters that \e can be passed to the nmea plugin.
22
23
\table
24
\header
25
\li Parameter
26
\li Description
27
\row
28
\li nmea.source
29
\li The source that will be used to get NMEA data.
30
\row
31
\li nmea.baudrate
32
\li The baud rate to be used by the serial port connection, expressed with
33
a positive integer number. Typically it should be one of the values
34
from the \l QSerialPort::BaudRate enum. If the parameter is not
35
specified or does not contain a positive integer, the default value
36
of \c 4800 is used.
37
\row
38
\li nmea.satellite_info_simulation_interval
39
\li The interval for reading satellite information data from the file in
40
simulation mode.
41
\endtable
42
43
Different sources require different ways of providing the data. The following
44
table lists different ways of providing \c {nmea.source} parameter for socket,
45
serial port and file inputs.
46
47
\table
48
\header
49
\li Scheme
50
\li Example
51
\li Description
52
\row
53
\li socket://hostname:port
54
\li \c {socket://localhost:12345}
55
\li Use \b {socket:} keyword to specify that you want to get the nmea data
56
from the socket. A TCP socket will be created, which will try to connect
57
to host \c hostname using port \c port. Upon successful connection
58
a text NMEA stream is expected to be received from the server.
59
\row
60
\li {1, 3} serial:portname
61
\li \c {serial:/dev/ttyUSB0}
62
\li {1, 3} Use \b {serial:} keyword to specify that you want to get the nmea
63
data from the serial port. The plugin will try to establish a connection
64
to port \c portname with a default baudrate = 4800 Bd (the baudrate
65
value can be specified using \b {nmea.baudrate} parameter). Upon
66
successful connection
67
a text NMEA stream is expected to be received from the serial port.
68
If you use \b {serial:} without any port name, the plugin will try to
69
find one of the well known serial devices using vendor identifier. Note
70
however that this is not a recommended way of using the serial port
71
connection, as the list of well-known devices is small and most probably
72
does not include your hardware.
73
\row
74
\li \c {serial:COM1}
75
\row
76
\li \c {serial:}
77
\row
78
\li filepath
79
\li \c {/home/user/nmealog.txt}
80
\li {1, 2} Use \b {file:///} or just full file path to specify a path to a
81
local file.
82
\row
83
\li file:///filepath
84
\li \c {file:///home/user/nmealog.txt}
85
\row
86
\li qrc:///filepath
87
\li \c {qrc:///nmealog.txt}
88
\li Use \b {qrc:///} prefix to specify a path to a file in the application
89
resources.
90
\endtable
91
92
\note If \c {nmea.source} parameter is not specified, the plugin will try to
93
locate one of the well-known serial devices (as if \c {nmea.source = serial:}
94
was specified).
95
96
\warning The \c {socket://} scheme supports only unencrypted connection.
97
Therefore it is only suitable for use within a host or over a trusted network.
98
99
\section1 Position source usage example
100
101
The following examples show how to create a \b nmea PositionSource
102
using different data sources.
103
104
\section2 QML
105
106
\code
107
// text file
108
PositionSource {
109
name: "nmea"
110
PluginParameter { name: "nmea.source"; value: "qrc:///nmealog.txt" }
111
}
112
113
// socket
114
PositionSource {
115
name: "nmea"
116
PluginParameter { name: "nmea.source"; value: "socket://localhost:22222" }
117
}
118
119
// serial port
120
PositionSource {
121
name: "nmea"
122
PluginParameter { name: "nmea.source"; value: "serial:/dev/ttyACM0" }
123
PluginParameter { name: "nmea.baudrate"; value: 4800 }
124
}
125
\endcode
126
127
\section2 C++
128
129
\code
130
// text file
131
QVariantMap params;
132
params["nmea.source"] = "qrc:///nmealog.txt";
133
QGeoPositionInfoSource *textPositionSource = QGeoPositionInfoSource::createSource("nmea", params, this);
134
135
// socket
136
params["nmea.source"] = "socket://localhost:22222";
137
QGeoPositionInfoSource *socketPositionSource = QGeoPositionInfoSource::createSource("nmea", params, this);
138
139
// serial port
140
params["nmea.source"] = "serial:/dev/ttyACM0";
141
params["nmea.baudrate"] = 4800;
142
QGeoPositionInfoSource *serialPositionSource = QGeoPositionInfoSource::createSource("nmea", params, this);
143
\endcode
144
145
\note Once a PositionSource is created, it can't be reconfigured to use other
146
type of source data.
147
148
\section1 Satellite information source usage example
149
150
Apart from the position information, \b nmea plugin is also capable of providing
151
satellite information.
152
153
\section2 QML
154
155
\code
156
// serial port
157
SatelliteSource {
158
name: "nmea"
159
PluginParameter { name: "nmea.source"; value: "serial:/dev/ttyUSB0" }
160
PluginParameter { name: "nmea.baudrate"; value: 9600 }
161
}
162
163
// socket
164
SatelliteSource {
165
name: "nmea"
166
PluginParameter { name: "nmea.source"; value: "socket://localhost:22222" }
167
}
168
\endcode
169
170
\section2 C++
171
172
\code
173
// serial port
174
QVariantMap parameters;
175
parameters["nmea.source"] = "serial:/dev/ttyUSB0";
176
params["nmea.baudrate"] = 9600;
177
QGeoSatelliteInfoSource *serialSource = QGeoSatelliteInfoSource::createSource("nmea", parameters, this);
178
179
// socket
180
parameters["nmea.source"] = "socket://localhost:22222";
181
QGeoSatelliteInfoSource *socketSource = QGeoSatelliteInfoSource::createSource("nmea", parameters, this);
182
\endcode
183
184
\section2 Settings custom simulation speed
185
186
If you want to use \l QGeoSatelliteInfoSource to read file with NMEA stream, you
187
can also use additional parameter \c "nmea.satellite_info_simulation_interval".
188
This parameter is used to specify the playback rate (in milliseconds) for the
189
satellite info messages. The minimum allowed frequency is specified by
190
\l {QGeoSatelliteInfoSource::}{minimumUpdateInterval()}. If you specify a
191
smaller value, it will be ignored. If no value is specified, the default value
192
is \c {qMax(100, minimumUpdateInterval())}.
193
At runtime \l {QNmeaSatelliteInfoSource::setBackendProperty()} method can be
194
used to update this parameter.
195
196
\code
197
// file
198
QVariantMap parameters;
199
parameters["nmea.source"] = "qrc:///nmealog.txt";
200
parameters["nmea.satellite_info_simulation_interval"] = 1000;
201
QGeoSatelliteInfoSource *fileSource = QGeoSatelliteInfoSource::createSource("nmea", parameters, this);
202
\endcode
203
204
This parameter is not applicable to position source because NMEA protocol
205
already has timestamps in position messages. These timestamps are used to
206
simulate the correct message rate while using \l QGeoPositionInfoSource with
207
file as a data source.
208
209
\note Once a \l QGeoSatelliteInfoSource is created, it can't be reconfigured to
210
use other type of source data.
211
212
*/
qtpositioning
src
positioning
doc
src
plugins
nmea.qdoc
Generated on
for Qt by
1.16.1