[−][src]Crate ublox
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 supports no_std environments, with two caveats about the Parser
traits:
- You must have a global allocator configured, and
- If your device is "poorly behaved" (i.e. is not a real u-blox GPS device but a maliciously designed device), then the amount of memory allocated can grow up to 64K.
A deterministic-memory Parser
implementation is on the roadmap.
Structs
AckAck | Messages in this class are sent as a result of a CFG message being received, decoded and processed by thereceiver. |
AckAckRef | 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. |
AckNak | Message Not-Acknowledge |
AckNakRef | Message Not-Acknowledge Contains a reference to an underlying buffer, contains accessor methods to retrieve data. |
AidIni | |
AidIniBuilder | Struct that is used to construct packets, see the crate-level documentation for more information |
AlpSrv | ALP client requests AlmanacPlus data from server |
AlpSrvRef | ALP client requests AlmanacPlus data from server Contains a reference to an underlying buffer, contains accessor methods to retrieve data. |
CfgMsgAllPorts | 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 |
CfgMsgAllPortsBuilder | 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 |
CfgMsgSinglePort | Set Message Rate the current port |
CfgMsgSinglePortBuilder | Set Message Rate the current port Struct that is used to construct packets, see the crate-level documentation for more information |
CfgNav5 | Navigation Engine Settings |
CfgNav5Builder | Navigation Engine Settings Struct that is used to construct packets, see the crate-level documentation for more information |
CfgNav5Params |
|
CfgNav5Ref | Navigation Engine Settings Contains a reference to an underlying buffer, contains accessor methods to retrieve data. |
CfgPrtSpi | Port Configuration for SPI Port |
CfgPrtSpiBuilder | Port Configuration for SPI Port Struct that is used to construct packets, see the crate-level documentation for more information |
CfgPrtSpiRef | Port Configuration for SPI Port Contains a reference to an underlying buffer, contains accessor methods to retrieve data. |
CfgPrtUart | Port Configuration for UART |
CfgPrtUartBuilder | Port Configuration for UART Struct that is used to construct packets, see the crate-level documentation for more information |
CfgPrtUartRef | Port Configuration for UART Contains a reference to an underlying buffer, contains accessor methods to retrieve data. |
CfgRate | Navigation/Measurement Rate Settings |
CfgRateBuilder | Navigation/Measurement Rate Settings Struct that is used to construct packets, see the crate-level documentation for more information |
CfgRst | Reset Receiver / Clear Backup Data Structures |
CfgRstBuilder | Reset Receiver / Clear Backup Data Structures Struct that is used to construct packets, see the crate-level documentation for more information |
FixStatusInfo | Fix Status Information |
InProtoMask | A mask describing which input protocolsare active
Each bit of this mask is used for aprotocol.
Through that, multiple protocols can be defined on a single port
Used in |
MonVer | Receiver/Software Version |
MonVerRef | Receiver/Software Version Contains a reference to an underlying buffer, contains accessor methods to retrieve data. |
NavBbrMask | Battery backed RAM sections to clear |
NavBbrPredefinedMask | Predefined values for |
NavDop | Dilution of precision |
NavDopRef | Dilution of precision Contains a reference to an underlying buffer, contains accessor methods to retrieve data. |
NavPosLlh | Geodetic Position Solution |
NavPosLlhRef | Geodetic Position Solution Contains a reference to an underlying buffer, contains accessor methods to retrieve data. |
NavPosVelTime | Navigation Position Velocity Time Solution |
NavPosVelTimeFlags | Fix status flags for |
NavPosVelTimeFlags2 | Additional flags for |
NavPosVelTimeRef | Navigation Position Velocity Time Solution Contains a reference to an underlying buffer, contains accessor methods to retrieve data. |
NavSolution | Navigation Solution Information |
NavSolutionRef | Navigation Solution Information Contains a reference to an underlying buffer, contains accessor methods to retrieve data. |
NavStatus | Receiver Navigation Status |
NavStatusFlags | Navigation Status Flags |
NavStatusRef | Receiver Navigation Status Contains a reference to an underlying buffer, contains accessor methods to retrieve data. |
NavTimeUTC | UTC Time Solution |
NavTimeUTCRef | UTC Time Solution Contains a reference to an underlying buffer, contains accessor methods to retrieve data. |
NavTimeUtcFlags | Validity Flags of |
NavVelNed | Velocity Solution in NED |
NavVelNedRef | Velocity Solution in NED Contains a reference to an underlying buffer, contains accessor methods to retrieve data. |
OutProtoMask | A mask describing which output protocols are active.
Each bit of this mask is used for aprotocol.
Through that, multiple protocols can be defined on a single port
Used in |
Parser | Streaming parser for UBX protocol with buffer |
ParserIter | Iterator over data stored in |
Position | Represents a world position, can be constructed from NavPosLlh and NavPosVelTime packets. |
UbxPacketRequest | Request specific packet |
UbxUnknownPacketRef | Packet not supported yet by this crate |
Velocity |
Enums
AlignmentToReferenceTime | Alignment to reference time |
CfgNav5DynModel | Dynamic platform model |
CfgNav5FixMode | Position Fixing Mode |
CfgNav5UtcStandard | UTC standard to be used |
DateTimeError | |
GpsFix | GPS fix Type |
MapMatchingStatus | |
MemWriterError | |
NavStatusFlags2 | Further information about navigation output Only for FW version >= 7.01; undefined otherwise |
PacketRef | All possible packets enum |
ParserError | Error that possible during packets parsing |
ResetMode | Reset Type |
SpiPortId | Port Identifier Number (= 4 for SPI port) |
UartPortId | Port Identifier Number (= 1 or 2 for UART ports) |
Traits
MemWriter | Abstraction for buffer creation/reallocation to storing packet |
UbxPacketCreator | |
UbxPacketMeta | Information about concrete UBX protocol's packet |