Skip to content

Commit 29d9554

Browse files
committed
docs: add CRATE_USAGE.md, fix CONTRIBUTING.md code fence, update .gitignore for crate doc inclusion
- Added CRATE_USAGE.md for crate-specific usage and examples - CONTRIBUTING.md: use bash code fence for pre-commit hook setup instructions - .gitignore: allow CRATE_USAGE.md to be tracked - OVERVIEW.md: minor formatting and code block language tweaks All changes maintain documentation compliance and improve developer experience.
1 parent 3c197e6 commit 29d9554

4 files changed

Lines changed: 100 additions & 3 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
!LICENSE
1212
!LICENSE_COMMERCIAL
1313
!CONTRIBUTING.md
14+
!CRATE_USAGE.md
1415

1516
# Whitelist src directory and all Rust files within it
1617
!src/

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ By submitting a pull request or otherwise contributing code to this project, you
3434
- Add comments for complex or non-obvious code sections.
3535
- Enable the pre-commit formatting hook (recommended):
3636

37-
```
37+
```bash
3838
cp .github/pre-commit-hook.sh .git/hooks/pre-commit
3939
chmod +x .git/hooks/pre-commit
4040
```

CRATE_USAGE.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Crate Usage: bbl_parser
2+
3+
Focused guidance for using the bbl_parser Rust crate.
4+
5+
## Table of Contents
6+
- [Installation](#installation)
7+
- [Cargo features](#cargo-features)
8+
- [Basic usage](#basic-usage)
9+
- [Multi-log processing](#multi-log-processing)
10+
- [Parsing from memory](#parsing-from-memory)
11+
- [Examples](#examples)
12+
- [Notes](#notes)
13+
14+
## Installation
15+
16+
Add the dependency to your Cargo.toml:
17+
18+
```toml
19+
[dependencies]
20+
# Local path while developing; use a version when published
21+
bbl_parser = { path = "path/to/bbl_parser" }
22+
```
23+
24+
## Cargo features
25+
26+
- `csv` (default): CSV export helpers
27+
- `cli` (default): Command-line entry points
28+
- `json`: JSON-related helpers (requires `serde`)
29+
- `serde`: Enable serialization for data structures
30+
31+
If you only need the parser types and functions, the defaults are fine.
32+
33+
## Basic usage
34+
35+
```rust
36+
use bbl_parser::{parse_bbl_file, ExportOptions};
37+
use std::path::Path;
38+
39+
fn main() -> anyhow::Result<()> {
40+
let log = parse_bbl_file(Path::new("flight.BBL"), ExportOptions::default(), false)?;
41+
println!("firmware: {}", log.header.firmware_revision);
42+
println!("frames: {}", log.sample_frames.len());
43+
Ok(())
44+
}
45+
```
46+
47+
Key outputs on the BBLLog:
48+
- `header`: configuration and metadata
49+
- `sample_frames`: decoded I/P/S/G/H/E frames
50+
- `event_frames`: flight events (when present)
51+
- `gps_track`: GPS coordinates (when present)
52+
53+
## Multi-log processing
54+
55+
```rust
56+
use bbl_parser::{parse_bbl_file_all_logs, ExportOptions};
57+
use std::path::Path;
58+
59+
fn main() -> anyhow::Result<()> {
60+
let logs = parse_bbl_file_all_logs(Path::new("multi_flight.BBL"), ExportOptions::default(), false)?;
61+
for log in logs {
62+
println!("log {} of {} -> frames {}", log.log_number, log.total_logs, log.sample_frames.len());
63+
}
64+
Ok(())
65+
}
66+
```
67+
68+
## Parsing from memory
69+
70+
```rust
71+
use bbl_parser::{parse_bbl_bytes, ExportOptions};
72+
73+
fn main() -> anyhow::Result<()> {
74+
let bytes = std::fs::read("flight.BBL")?;
75+
let log = parse_bbl_bytes(&bytes, ExportOptions::default(), false)?;
76+
println!("frames: {}", log.sample_frames.len());
77+
Ok(())
78+
}
79+
```
80+
81+
## Examples
82+
83+
Run the crate example that demonstrates multi-firmware support and PID extraction:
84+
85+
```bash
86+
cargo build --example bbl_crate_test
87+
cargo run --example bbl_crate_test -- flight.BBL
88+
```
89+
90+
More details: [examples/README.md](./examples/README.md)
91+
92+
## Notes
93+
94+
- API is evolving while the project is WIP; names and structures may change.
95+
- CSV field order and naming follow blackbox-tools to maximize compatibility.
96+
- For CLI usage and high-level overview, see the main [README](./README.md).

OVERVIEW.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ The BBL parser implements a streaming architecture designed for memory efficienc
8787
BBL encoding compatibility: `SIGNED_VB`, `UNSIGNED_VB`, `NEG_14BIT`, `TAG8_8SVB`, `TAG2_3S32`, `TAG8_4S16`
8888

8989
### **Project Structure**
90-
```
90+
```text
9191
src/
9292
├── main.rs # CLI interface, file handling, statistics, CSV export
9393
├── lib.rs # Library API exports and documentation
@@ -119,7 +119,7 @@ src/
119119
- **Firmware Compatibility:** Betaflight, EmuFlight, INAV support
120120
- **Multi-log Processing:** Automatic detection of multiple flight sessions in single files
121121
- **Smart Export Filtering:** Automatically skips short test flights (<5s) while preserving high-quality short logs
122-
122+
stub
123123
### **Library API**
124124
- **Complete Data Access:** Programmatic access to all BBL data structures
125125
- **Memory-Based Parsing:** Parse from file paths or memory buffers (`parse_bbl_file`, `parse_bbl_bytes`)

0 commit comments

Comments
 (0)