Qt Positioning NMEA plugin
Qt定位NMEA插件
Overview
概述
Included with Qt Positioning is a position plugin which parses NMEA sentences into position updates. This plugin can use serial port, socket or file as a source.
Qt Positioning附带了一个位置插件,可以将NMEA句子解析为位置更新。此插件可以使用串行端口、套接字或文件作为源。
This plugin can be loaded by using the provider name nmea.
可以使用提供者名称nmea加载此插件。
Parameters
参数
The following table lists parameters that can be passed to the nmea plugin.
下表列出了可以传递给nmea插件的参数。
Parameter | Description |
---|---|
nmea.source | The source that will be used to get NMEA data. 将用于获取NMEA数据的源。 |
nmea.baudrate | The baud rate to be used by the serial port connection, expressed with a positive integer number. Typically it should be one of the values from the QSerialPort::BaudRate enum. If the parameter is not specified or does not contain a positive integer, the default value of 串行端口连接使用的波特率,用正整数表示。通常,它应该是QSerialPort::BaudRate枚举中的值之一。如果未指定参数或不包含正整数,则使用默认值4800。 |
nmea.satellite_info_simulation_interval | The interval for reading satellite information data from the file in simulation mode. 在模拟模式下从文件中读取卫星信息数据的间隔。 |
Different sources require different ways of providing the data. The following table lists different ways of providing nmea.source
parameter for socket, serial port and file inputs.
不同的来源需要不同的数据提供方式。下表列出了为套接字、串行端口和文件输入提供nmea.source参数的不同方法。
Scheme | Example | Description |
---|---|---|
socket://hostname:port | socket://localhost:12345 | Use socket: keyword to specify that you want to get the nmea data from the socket. A TCP socket will be created, which will try to connect to host 使用socket:关键字指定要从套接字获取nmea数据。将创建一个TCP套接字,该套接字将尝试使用端口连接到主机主机名。成功连接后,预计将从服务器接收文本NMEA流。 |
serial:portname | serial:/dev/ttyUSB0 | Use serial: keyword to specify that you want to get the nmea data from the serial port. The plugin will try to establish a connection to port 使用serial:关键字指定要从串行端口获取nmea数据。该插件将尝试使用默认波特率=4800 Bd(可以使用nmea.baudrate参数指定波特率值)建立与端口端口名的连接。成功连接后,预计将从串行端口接收文本NMEA流。如果您使用serial:而不使用任何端口名,插件将尝试使用供应商标识符查找一个众所周知的串行设备。但是请注意,这不是使用串行端口连接的推荐方式,因为众所周知的设备列表很小,很可能不包括硬件。 |
serial:COM1 | ||
serial: | ||
filepath | /home/user/nmealog.txt | Use file:/// or just full file path to specify a path to a local file. 使用file:///或仅使用完整文件路径指定本地文件的路径。 |
file:///filepath | file:///home/user/nmealog.txt | |
qrc:///filepath | qrc:///nmealog.txt | Use qrc:/// prefix to specify a path to a file in the application resources. 使用qrc:///前缀指定应用程序资源中文件的路径。 |
Note: If
nmea.source
parameter is not specified, the plugin will try to locate one of the well-known serial devices (as ifnmea.source = serial:
was specified).注意:如果未指定nmea.source参数,插件将尝试定位一个众所周知的串行设备(就像指定了nmea.source=serial:一样)。
Position source usage example
位置源使用示例
The following examples show how to create a nmea PositionSource using different data sources.
以下示例显示了如何使用不同的数据源创建nmea PositionSource。
QML
// text file
PositionSource {
name: "nmea"
PluginParameter { name: "nmea.source"; value: "qrc:///nmealog.txt" }
}
// socket
PositionSource {
name: "nmea"
PluginParameter { name: "nmea.source"; value: "socket://localhost:22222" }
}
// serial port
PositionSource {
name: "nmea"
PluginParameter { name: "nmea.source"; value: "serial:/dev/ttyACM0" }
PluginParameter { name: "nmea.baudrate"; value: 4800 }
}
C++
// text file
QVariantMap params;
params["nmea.source"] = "qrc:///nmealog.txt";
QGeoPositionInfoSource *textPositionSource = QGeoPositionInfoSource::createSource("nmea", params, this);
// socket
params["nmea.source"] = "socket://localhost:22222";
QGeoPositionInfoSource *socketPositionSource = QGeoPositionInfoSource::createSource("nmea", params, this);
// serial port
params["nmea.source"] = "serial:/dev/ttyACM0";
params["nmea.baudrate"] = 4800;
QGeoPositionInfoSource *serialPositionSource = QGeoPositionInfoSource::createSource("nmea", params, this);
Note: Once a PositionSource is created, it can't be reconfigured to use other type of source data.
注意:一旦创建了PositionSource,就无法将其重新配置为使用其他类型的源数据。
Satellite information source usage example
卫星信息源使用示例
Apart from the position information, nmea plugin is also capable of providing satellite information.
除了位置信息,nmea插件还能够提供卫星信息。
QML
// serial port
SatelliteSource {
name: "nmea"
PluginParameter { name: "nmea.source"; value: "serial:/dev/ttyUSB0" }
PluginParameter { name: "nmea.baudrate"; value: 9600 }
}
// socket
SatelliteSource {
name: "nmea"
PluginParameter { name: "nmea.source"; value: "socket://localhost:22222" }
}
C++
// serial port
QVariantMap parameters;
parameters["nmea.source"] = "serial:/dev/ttyUSB0";
params["nmea.baudrate"] = 9600;
QGeoSatelliteInfoSource *serialSource = QGeoSatelliteInfoSource::createSource("nmea", parameters, this);
// socket
parameters["nmea.source"] = "socket://localhost:22222";
QGeoSatelliteInfoSource *socketSource = QGeoSatelliteInfoSource::createSource("nmea", parameters, this);
Settings custom simulation speed
设置自定义模拟速度
If you want to use QGeoSatelliteInfoSource to read file with NMEA stream, you can also use additional parameter "nmea.satellite_info_simulation_interval"
. This parameter is used to specify the playback rate (in milliseconds) for the satellite info messages. The minimum allowed frequency is specified by minimumUpdateInterval(). If you specify a smaller value, it will be ignored. If no value is specified, the default value is qMax(100, minimumUpdateInterval())
. At runtime QNmeaSatelliteInfoSource::setBackendProperty() method can be used to update this parameter.
如果想使用QGeoSatelliteInfoSource读取带有NMEA流的文件,你也可以使用额外的参数“nmea.satellite_info_simulation_interval
”。此参数用于指定卫星信息消息的播放速率(以毫秒为单位)。最小允许频率由minimumUpdateInterval()指定。如果指定了一个较小的值,它将被忽略。如果未指定值,则默认值为qMax(100,minimumUpdateInterval())。在运行时,QNmeaSatelliteInfoSource::setBackendProperty()方法可用于更新此参数。
// file
QVariantMap parameters;
parameters["nmea.source"] = "qrc:///nmealog.txt";
parameters["nmea.satellite_info_simulation_interval"] = 1000;
QGeoSatelliteInfoSource *fileSource = QGeoSatelliteInfoSource::createSource("nmea", parameters, this);
This parameter is not applicable to position source because NMEA protocol already has timestamps in position messages. These timestamps are used to simulate the correct message rate while using QGeoPositionInfoSource with file as a data source.
此参数不适用于位置源,因为NMEA协议在位置消息中已经有时间戳。这些时间戳用于在使用QGeoPositionInfoSource和文件作为数据源时模拟正确的消息速率。
Note: Once a QGeoSatelliteInfoSource is created, it can't be reconfigured to use other type of source data.
注意:一旦创建了QGeoSatelliteInfoSource,就无法将其重新配置为使用其他类型的源数据。
Gypsy pluginUpgrading from Qt 5
© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.