Skip to content

Commit

Permalink
Update the README of own version of the fork
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Gherghescu <[email protected]>
  • Loading branch information
andrei-ng committed Dec 23, 2024
1 parent 1d7d9b8 commit 0dae562
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 89 deletions.
92 changes: 4 additions & 88 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,97 +2,13 @@ uBlox for Rust
==============

[![MIT licensed][MIT-badge]][MIT-URL]
![build-ci](https://img.shields.io/github/actions/workflow/status/andrei-ng/ublox-rs/build.yaml?branch=main)
![build-ci](https://img.shields.io/github/actions/workflow/status/andrei-ng/u-blox.rs/build.yaml?branch=main)

[MIT-badge]: https://img.shields.io/badge/license-MIT-blue.svg
[MIT-URL]: https://github.com/andrei-ng/ublox-rs/blob/main/LICENSE.md

==============
[MIT-URL]: https://github.com/andrei-ng/u-blox.rs/blob/main/LICENSE.md

This project is a fork of [lkolbly/ublox](https://github.com/lkolbly/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` sub-folder of this project.

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();
```

For variable-size packet like `CfgValSet`, you can construct it into a new `Vec<u8>`:
```
use ublox::{cfg_val::CfgVal::*, CfgLayer, CfgValSetBuilder};
let packet_vec: Vec<u8> = CfgValSetBuilder {
version: 1,
layers: CfgLayer::RAM,
reserved1: 0,
cfg_data: &[UsbOutProtNmea(true), UsbOutProtRtcm3x(true), UsbOutProtUbx(true)],
}
.into_packet_vec();
let packet: &[u8] = packet_vec.as_slice();
```
Or by extending to an existing one:
```
let mut packet_vec = Vec::new();
CfgValSetBuilder {
version: 1,
layers: CfgLayer::RAM,
reserved1: 0,
cfg_data: &[UsbOutProtNmea(true), UsbOutProtRtcm3x(true), UsbOutProtUbx(true)],
}
.extend_to(&mut packet_vec);
let packet = packet_vec.as_slice();
```
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 a deterministic-size `Parser`. See the documentation for more information.

Minimum Supported Rust Version
==============================
Examples of using this library to interface with uBlox M8* series devices can be found in the `examples` sub-folder of this project.

This crate will always support at least the previous year's worth of Rust compilers. Currently, that means that the MSRV is `1.49.0`. Note that, as we are pre-1.0, breaking the MSRV will not force a minor update - the MSRV can change in a patch update.
This library supports `no_std` environments with a deterministic-size `Parser`.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion ublox/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//!
//! 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.
//! An example of using this library to talk to a device can be seen in the examples subfolder of this project.
//!
//! Constructing Packets
//! ====================
Expand Down

0 comments on commit 0dae562

Please sign in to comment.