Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
13Included with Qt Positioning is a position plugin which parses NMEA sentences
14into position updates. This plugin can use serial port, socket or file as a
15source.
16
17This plugin can be loaded by using the provider name \b nmea.
18
19\section1 Parameters
20
21The 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
43Different sources require different ways of providing the data. The following
44table lists different ways of providing \c {nmea.source} parameter for socket,
45serial 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
93locate one of the well-known serial devices (as if \c {nmea.source = serial:}
94was specified).
95
96\section1 Position source usage example
97
98The following examples show how to create a \b nmea PositionSource
99using different data sources.
100
101\section2 QML
102
103\code
104// text file
105PositionSource {
106 name: "nmea"
107 PluginParameter { name: "nmea.source"; value: "qrc:///nmealog.txt" }
108}
109
110// socket
111PositionSource {
112 name: "nmea"
113 PluginParameter { name: "nmea.source"; value: "socket://localhost:22222" }
114}
115
116// serial port
117PositionSource {
118 name: "nmea"
119 PluginParameter { name: "nmea.source"; value: "serial:/dev/ttyACM0" }
120 PluginParameter { name: "nmea.baudrate"; value: 4800 }
121}
122\endcode
123
124\section2 C++
125
126\code
127// text file
128QVariantMap params;
129params["nmea.source"] = "qrc:///nmealog.txt";
130QGeoPositionInfoSource *textPositionSource = QGeoPositionInfoSource::createSource("nmea", params, this);
131
132// socket
133params["nmea.source"] = "socket://localhost:22222";
134QGeoPositionInfoSource *socketPositionSource = QGeoPositionInfoSource::createSource("nmea", params, this);
135
136// serial port
137params["nmea.source"] = "serial:/dev/ttyACM0";
138params["nmea.baudrate"] = 4800;
139QGeoPositionInfoSource *serialPositionSource = QGeoPositionInfoSource::createSource("nmea", params, this);
140\endcode
141
142\note Once a PositionSource is created, it can't be reconfigured to use other
143type of source data.
144
145\section1 Satellite information source usage example
146
147Apart from the position information, \b nmea plugin is also capable of providing
148satellite information.
149
150\section2 QML
151
152\code
153// serial port
154SatelliteSource {
155 name: "nmea"
156 PluginParameter { name: "nmea.source"; value: "serial:/dev/ttyUSB0" }
157 PluginParameter { name: "nmea.baudrate"; value: 9600 }
158}
159
160// socket
161SatelliteSource {
162 name: "nmea"
163 PluginParameter { name: "nmea.source"; value: "socket://localhost:22222" }
164}
165\endcode
166
167\section2 C++
168
169\code
170// serial port
171QVariantMap parameters;
172parameters["nmea.source"] = "serial:/dev/ttyUSB0";
173params["nmea.baudrate"] = 9600;
174QGeoSatelliteInfoSource *serialSource = QGeoSatelliteInfoSource::createSource("nmea", parameters, this);
175
176// socket
177parameters["nmea.source"] = "socket://localhost:22222";
178QGeoSatelliteInfoSource *socketSource = QGeoSatelliteInfoSource::createSource("nmea", parameters, this);
179\endcode
180
181\section2 Settings custom simulation speed
182
183If you want to use \l QGeoSatelliteInfoSource to read file with NMEA stream, you
184can also use additional parameter \c "nmea.satellite_info_simulation_interval".
185This parameter is used to specify the playback rate (in milliseconds) for the
186satellite info messages. The minimum allowed frequency is specified by
187\l {QGeoSatelliteInfoSource::}{minimumUpdateInterval()}. If you specify a
188smaller value, it will be ignored. If no value is specified, the default value
189is \c {qMax(100, minimumUpdateInterval())}.
190At runtime \l {QNmeaSatelliteInfoSource::setBackendProperty()} method can be
191used to update this parameter.
192
193\code
194// file
195QVariantMap parameters;
196parameters["nmea.source"] = "qrc:///nmealog.txt";
197parameters["nmea.satellite_info_simulation_interval"] = 1000;
198QGeoSatelliteInfoSource *fileSource = QGeoSatelliteInfoSource::createSource("nmea", parameters, this);
199\endcode
200
201This parameter is not applicable to position source because NMEA protocol
202already has timestamps in position messages. These timestamps are used to
203simulate the correct message rate while using \l QGeoPositionInfoSource with
204file as a data source.
205
206\note Once a \l QGeoSatelliteInfoSource is created, it can't be reconfigured to
207use other type of source data.
208
209*/