Crate ublox

source · []
Expand description

ublox

This project aims to build a pure-rust I/O library for ublox GPS devices, specifically using the UBX protocol.

An example of using this library to talk to a device can be seen in the ublox_cli subfolder of this project.

Constructing Packets

Constructing packets happens using the Builder variant of the packet, for example:

use ublox::{CfgPrtUartBuilder, UartPortId};

let packet: [u8; 28] = CfgPrtUartBuilder {
   portid: UartPortId::Uart1,
   reserved0: 0,
   tx_ready: 0,
   mode: 0x8d0,
   baud_rate: 9600,
   in_proto_mask: 0x07,
   out_proto_mask: 0x01,
   flags: 0,
   reserved5: 0,
}.into_packet_bytes();

See the documentation for the individual Builder structs for information on the fields.

Parsing Packets

Parsing packets happens by instantiating a Parser object and then adding data into it using its consume() method. The parser contains an internal buffer of data, and when consume() is called that data is copied into the internal buffer and an iterator-like object is returned to access the packets. For example:

use ublox::Parser;

let mut parser = Parser::default();
let my_raw_data = vec![1, 2, 3, 4]; // From your serial port
let mut it = parser.consume(&my_raw_data);
loop {
    match it.next() {
        Some(Ok(packet)) => {
            // We've received a &PacketRef, we can handle it
        }
        Some(Err(_)) => {
            // Received a malformed packet
        }
        None => {
            // The internal buffer is now empty
            break;
        }
    }
}

no_std Support

This library additionally supports no_std environments with a deterministic-size parser. To use this parser, simply create a FixedLinearBuffer and use it to construct a Parser object:

let mut buf = vec![0; 256];
let buf = ublox::FixedLinearBuffer::new(&mut buf[..]);
let mut parser = ublox::Parser::new(buf);

The resulting parser can be used like normal. The absolute smallest recommended buffer size is 36 bytes, large enough to contain a NavPosLlh packet.

Structs

Messages in this class are sent as a result of a CFG message being received, decoded and processed by thereceiver.

Messages in this class are sent as a result of a CFG message being received, decoded and processed by thereceiver. Contains a reference to an underlying buffer, contains accessor methods to retrieve data.

Message Not-Acknowledge

Message Not-Acknowledge Contains a reference to an underlying buffer, contains accessor methods to retrieve data.

Struct that is used to construct packets, see the crate-level documentation for more information

ALP client requests AlmanacPlus data from server

ALP client requests AlmanacPlus data from server Contains a reference to an underlying buffer, contains accessor methods to retrieve data.

Reset Receiver / Clear Backup Data Structures

Reset Receiver / Clear Backup Data Structures Struct that is used to construct packets, see the crate-level documentation for more information

Reset Receiver / Clear Backup Data Structures Contains a reference to an underlying buffer, contains accessor methods to retrieve data.

Information message conifg

Information message conifg Struct that is used to construct packets, see the crate-level documentation for more information

CfgInfMask parameters bitmask

Information message conifg Contains a reference to an underlying buffer, contains accessor methods to retrieve data.

Set Message rate configuration Send rate is relative to the event a message is registered on. For example, if the rate of a navigation message is set to 2, the message is sent every second navigation solution

Set Message rate configuration Send rate is relative to the event a message is registered on. For example, if the rate of a navigation message is set to 2, the message is sent every second navigation solution Struct that is used to construct packets, see the crate-level documentation for more information

Set Message Rate the current port

Set Message Rate the current port Struct that is used to construct packets, see the crate-level documentation for more information

Navigation Engine Settings

Navigation Engine Settings Struct that is used to construct packets, see the crate-level documentation for more information

CfgNav5 parameters bitmask

Navigation Engine Settings Contains a reference to an underlying buffer, contains accessor methods to retrieve data.

Navigation Engine Expert Settings

Navigation Engine Expert Settings Struct that is used to construct packets, see the crate-level documentation for more information

CfgNavX51 parameters bitmask

CfgNavX5Params2 parameters bitmask

Navigation Engine Expert Settings Contains a reference to an underlying buffer, contains accessor methods to retrieve data.

Configure odometer

Configure odometer Struct that is used to construct packets, see the crate-level documentation for more information

Configure odometer Contains a reference to an underlying buffer, contains accessor methods to retrieve data.

Port Configuration for I2C

Port Configuration for I2C Struct that is used to construct packets, see the crate-level documentation for more information

Port Configuration for I2C Contains a reference to an underlying buffer, contains accessor methods to retrieve data.

Port Configuration for SPI Port

Port Configuration for SPI Port Struct that is used to construct packets, see the crate-level documentation for more information

Port Configuration for SPI Port Contains a reference to an underlying buffer, contains accessor methods to retrieve data.

Port Configuration for UART

Port Configuration for UART Struct that is used to construct packets, see the crate-level documentation for more information

Port Configuration for UART Contains a reference to an underlying buffer, contains accessor methods to retrieve data.

Navigation/Measurement Rate Settings

Navigation/Measurement Rate Settings Struct that is used to construct packets, see the crate-level documentation for more information

Reset Receiver / Clear Backup Data Structures

Reset Receiver / Clear Backup Data Structures Struct that is used to construct packets, see the crate-level documentation for more information

Fix Status Information

A mask describing which input protocols are active Each bit of this mask is used for a protocol. Through that, multiple protocols can be defined on a single port Used in CfgPrtSpi and CfgPrtI2c

Contains a reference to an underlying buffer, contains accessor methods to retrieve data.

Contains a reference to an underlying buffer, contains accessor methods to retrieve data.

Contains a reference to an underlying buffer, contains accessor methods to retrieve data.

Contains a reference to an underlying buffer, contains accessor methods to retrieve data.

Contains a reference to an underlying buffer, contains accessor methods to retrieve data.

GNSS Assistance ACK UBX-MGA-ACK

GNSS Assistance ACK UBX-MGA-ACK Contains a reference to an underlying buffer, contains accessor methods to retrieve data.

Hardware status

Hardware status Contains a reference to an underlying buffer, contains accessor methods to retrieve data.

Receiver/Software Version

Receiver/Software Version Contains a reference to an underlying buffer, contains accessor methods to retrieve data.

Battery backed RAM sections to clear

Predefined values for NavBbrMask

Dilution of precision

Dilution of precision Contains a reference to an underlying buffer, contains accessor methods to retrieve data.

Odometer solution

Odometer solution Contains a reference to an underlying buffer, contains accessor methods to retrieve data.

Geodetic Position Solution

Geodetic Position Solution Contains a reference to an underlying buffer, contains accessor methods to retrieve data.

Navigation Position Velocity Time Solution

Fix status flags for NavPosVelTime

Additional flags for NavPosVelTime

Navigation Position Velocity Time Solution Contains a reference to an underlying buffer, contains accessor methods to retrieve data.

Reset odometer

Reset odometer Struct that is used to construct packets, see the crate-level documentation for more information

Contains a reference to an underlying buffer, contains accessor methods to retrieve data.

Contains a reference to an underlying buffer, contains accessor methods to retrieve data.

Navigation Solution Information

Navigation Solution Information Contains a reference to an underlying buffer, contains accessor methods to retrieve data.

Receiver Navigation Status

Navigation Status Flags

Receiver Navigation Status Contains a reference to an underlying buffer, contains accessor methods to retrieve data.

UTC Time Solution

UTC Time Solution Contains a reference to an underlying buffer, contains accessor methods to retrieve data.

Validity Flags of NavTimeUTC

Velocity Solution in NED

Velocity Solution in NED Contains a reference to an underlying buffer, contains accessor methods to retrieve data.

A mask describing which output protocols are active. Each bit of this mask is used for a protocol. Through that, multiple protocols can be defined on a single port Used in CfgPrtSpi and CfgPrtI2c

Streaming parser for UBX protocol with buffer. The default constructor will build a parser containing a Vec, but you can pass your own underlying buffer by passing it to Parser::new().

Iterator over data stored in Parser buffer

Represents a world position, can be constructed from NavPosLlh and NavPosVelTime packets.

Request specific packet

Packet not supported yet by this crate

Enums

Alignment to reference time

Dynamic platform model

Position Fixing Mode

UTC standard to be used

GPS fix Type

Port Identifier Number (= 0 for I2C ports)

Further information about navigation output Only for FW version >= 7.01; undefined otherwise

Odometer configuration profile

All possible packets enum

Error that possible during packets parsing

Reset Type

Port Identifier Number (= 4 for SPI port)

Port Identifier Number (= 1 or 2 for UART ports)

Traits

Abstraction for buffer creation/reallocation to storing packet

Information about concrete UBX protocol’s packet

This trait represents an underlying buffer used for the Parser. We provide implementations for Vec<u8> and for FixedLinearBuffer, if you want to use your own struct as an underlying buffer you can implement this trait.