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 examples/ublox-cli subfolder of this project. More examples are available in the examples subfolder.

Constructing Packets

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

use ublox::{CfgPrtUartBuilder, UartPortId, UartMode, DataBits, Parity, StopBits, InProtoMask, OutProtoMask};

let packet: [u8; 28] = CfgPrtUartBuilder {
   portid: UartPortId::Uart1,
   reserved0: 0,
   tx_ready: 0,
   mode: UartMode::new(DataBits::Eight, Parity::None, StopBits::One),
   baud_rate: 9600,
   in_proto_mask: InProtoMask::all(),
   out_proto_mask: OutProtoMask::UBLOX,
   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.

Modules

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.
  • Configure Jamming interference monitoring
  • Configure Jamming interference monitoring Struct that is used to construct packets, see the crate-level documentation for more information
  • Configure Jamming interference monitoring Contains a reference to an underlying buffer, contains accessor methods to retrieve data.
  • A mask describing where configuration is applied.
  • 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
  • Time MODE2 Config Frame (32.10.36.1) only available on timing receivers
  • Time MODE2 Config Frame (32.10.36.1) only available on timing receivers Struct that is used to construct packets, see the crate-level documentation for more information
  • Time MODE2 Config Frame (32.10.36.1) only available on timing receivers Contains a reference to an underlying buffer, contains accessor methods to retrieve data.
  • Time MODE3 Config Frame (32.10.37.1) only available on timing receivers
  • Time MODE3 Config Frame (32.10.37.1) only available on timing receivers Struct that is used to construct packets, see the crate-level documentation for more information
  • Time MODE3 Config Frame (32.10.37.1) only available on timing receivers Contains a reference to an underlying buffer, contains accessor methods to retrieve data.
  • TP5: “Time Pulse” Config frame (32.10.38.4)
  • TP5: “Time Pulse” Config frame (32.10.38.4) Struct that is used to construct packets, see the crate-level documentation for more information
  • TP5: “Time Pulse” Config frame (32.10.38.4) 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
  • 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.
  • Fix Status 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.
  • Fix status flags for HnrPvt
  • Contains a reference to an underlying buffer, contains accessor methods to retrieve data.
  • 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.
  • 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 status monitoring, gives currently selected constellations
  • Selected / available Constellation Mask
  • GNSS status monitoring, gives currently selected constellations 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.
  • Contains a reference to an underlying buffer, contains accessor methods to retrieve data.
  • Battery backed RAM sections to clear
  • Predefined values for NavBbrMask
  • Contains a reference to an underlying buffer, contains accessor methods to retrieve data.
  • Dilution of precision
  • Dilution of precision Contains a reference to an underlying buffer, contains accessor methods to retrieve data.
  • End of Epoch Marker
  • End of Epoch Marker Contains a reference to an underlying buffer, contains accessor methods to retrieve data.
  • High Precision Geodetic Position Solution (ECEF)
  • High Precision Geodetic Position Solution (ECEF) Contains a reference to an underlying buffer, contains accessor methods to retrieve data.
  • High Precision Geodetic Position Solution
  • High Precision Geodetic Position Solution 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 NavPvt
  • Additional flags for NavPvt
  • 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.
  • Leap second event information
  • Fix status flags for NavTimeLsFlags
  • Leap second event information 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
  • Contains a reference to an underlying buffer, contains accessor methods to retrieve data.
  • 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 NavPvt packets.
  • Represents a world position in the ECEF coordinate system
  • CfgNavX5Params2 parameters bitmask
  • 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.
  • This message is used to retrieve a unique chip identifier
  • This message is used to retrieve a unique chip identifier Contains a reference to an underlying buffer, contains accessor methods to retrieve data.
  • Time mode survey-in status
  • Time mode survey-in status Contains a reference to an underlying buffer, contains accessor methods to retrieve data.
  • Time mark data
  • Time mark data Contains a reference to an underlying buffer, contains accessor methods to retrieve data.
  • Time pulse time data
  • Time pulse time data Contains a reference to an underlying buffer, contains accessor methods to retrieve data.
  • Request specific packet
  • Packet not supported yet by this crate

Enums

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.