Skip to content

Commit 4256bf1

Browse files
authored
docs: major README.md and CONTRIBUTING.md simplification and compliance (#5)
* docs: major README.md and CONTRIBUTING.md simplification and compliance - README.md: CLI-focused, crate usage moved to CRATE_USAGE.md, TOC and links updated, event export clarified as CLI-only - CONTRIBUTING.md: pre-commit hook setup instructions added Complies with GLOBAL-COPILOT and MARKDOWN instructions for brevity, TOC, and doc structure. * docs: update OVERVIEW.md to reflect current project structure - Updated project structure to include all current source files (lib.rs, conversion.rs, export.rs, gps.rs) - Clarified export functionality status (CLI functional, crate stubs pending migration) - Added smart export filtering feature to file processing - Specified API entry points (parse_bbl_file, parse_bbl_bytes, _all_logs variants) - Enhanced data export capabilities section with file naming details - Removed duplicate sections (Current Data Processing, Development Focus Areas) - Updated documentation references to include CRATE_USAGE.md and examples/README.md - Added development documentation section with pre-commit hooks and setup scripts All information now accurately reflects v0.9.0 WIP codebase structure and capabilities. * 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. * duh
1 parent 5ed9bf1 commit 4256bf1

5 files changed

Lines changed: 198 additions & 566 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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ By submitting a pull request or otherwise contributing code to this project, you
3232
- Write meaningful commit messages.
3333
- Document all public API functions.
3434
- Add comments for complex or non-obvious code sections.
35+
- Enable the pre-commit formatting hook (recommended):
36+
37+
```bash
38+
cp .github/pre-commit-hook.sh .git/hooks/pre-commit
39+
chmod +x .git/hooks/pre-commit
40+
```
3541

3642
## Reporting Issues
3743

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: 41 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -77,55 +77,63 @@ The BBL parser implements a streaming architecture designed for memory efficienc
7777
- **E-frames:** Flight events with official Betaflight FlightLogEvent enum mapping
7878

7979
### **Export Functionality**
80-
- **CSV Export:** blackbox_decode compatible format with proper field ordering
81-
- **GPX Export:** Standard GPS exchange format for mapping applications
82-
- **Event Export:** JSONL format with Betaflight event type descriptions
80+
- **CSV Export:** blackbox_decode compatible format with proper field ordering (CLI functional, crate stub)
81+
- **GPX Export:** Standard GPS exchange format for mapping applications (CLI functional)
82+
- **Event Export:** JSONL format with Betaflight event type descriptions (CLI functional)
83+
84+
**Note:** Export functionality is currently implemented in the CLI (`src/main.rs`). Crate-level export functions in `src/export.rs` are stubs pending systematic migration.
8385

8486
### **Encoding Support**
8587
BBL encoding compatibility: `SIGNED_VB`, `UNSIGNED_VB`, `NEG_14BIT`, `TAG8_8SVB`, `TAG2_3S32`, `TAG8_4S16`
8688

8789
### **Project Structure**
88-
```
90+
```text
8991
src/
90-
├── main.rs # CLI interface, file handling, statistics
92+
├── main.rs # CLI interface, file handling, statistics, CSV export
93+
├── lib.rs # Library API exports and documentation
9194
├── bbl_format.rs # BBL binary format decoding and encoding
95+
├── conversion.rs # Unit conversions (GPS coordinates, altitude, speed)
9296
├── error.rs # Error handling and result types
97+
├── export.rs # Export function stubs (CSV/GPX/Event migration in progress)
9398
├── types/ # Core data structures
94-
│ ├── mod.rs # Module definitions
95-
│ ├── log.rs # Log container types
96-
│ ├── frame.rs # Frame data structures
97-
│ └── header.rs # Header information types
99+
│ ├── mod.rs # Module definitions and re-exports
100+
│ ├── log.rs # BBLLog container type
101+
│ ├── frame.rs # DecodedFrame and FrameDefinition structures
102+
│ ├── header.rs # BBLHeader and field definitions
103+
│ └── gps.rs # GpsCoordinate, GpsHomeCoordinate, EventFrame
98104
└── parser/ # Parsing implementation
99105
├── mod.rs # Parser module definitions
100-
├── decoder.rs # Frame decoding logic
101-
├── frame.rs # Frame parsing implementations
106+
├── main.rs # High-level parsing entry points (parse_bbl_file, parse_bbl_bytes)
107+
├── decoder.rs # Frame decoding logic and predictors
108+
├── frame.rs # Frame parsing implementations (I, P, S, G, H, E frames)
102109
├── header.rs # Header parsing logic
103-
└── stream.rs # Binary stream handling
110+
└── stream.rs # Binary stream handling (BBLDataStream)
104111
```
105112

106113
---
107114

108115
## 🚀 **Current Features**
109116

110-
### **Current Features**
111-
112117
### **File Processing**
113118
- **Universal Format Support:** `.BBL`, `.BFL`, `.TXT` with case-insensitive matching
114119
- **Firmware Compatibility:** Betaflight, EmuFlight, INAV support
115120
- **Multi-log Processing:** Automatic detection of multiple flight sessions in single files
121+
- **Smart Export Filtering:** Automatically skips short test flights (<5s) while preserving high-quality short logs
116122

117123
### **Library API**
118124
- **Complete Data Access:** Programmatic access to all BBL data structures
119-
- **Memory-Based Parsing:** Parse from file paths or memory buffers
120-
- **Multi-Log Support:** Handle files containing multiple flight sessions
125+
- **Memory-Based Parsing:** Parse from file paths or memory buffers (`parse_bbl_file`, `parse_bbl_bytes`)
126+
- **Multi-Log Support:** Handle files containing multiple flight sessions (`parse_bbl_file_all_logs`, `parse_bbl_bytes_all_logs`)
121127
- **Serde Integration:** Optional serialization support for data structures
122128
- **Rust Crate:** Available as library dependency for 3rd party projects
123129

124-
### **Data Export Capabilities**
130+
### **Data Export Capabilities (CLI)**
125131
- **CSV Export:** blackbox_decode compatible field ordering and formatting
126-
- **GPS Export:** GPX format generation for mapping applications
127-
- **Event Export:** Flight event data in JSONL format with Betaflight event type mapping
128-
- **Multi-log Support:** Individual files for each flight session
132+
- Main flight data `[.XX].csv` with proper field order and "time (us)" column
133+
- Headers `[.XX].headers.csv` with complete configuration
134+
- **GPS Export:** GPX format generation for mapping applications (`[.XX].gps.gpx`)
135+
- **Event Export:** Flight event data in JSONL format (`[.XX].event`)
136+
- **Multi-log Support:** Individual numbered files for each flight session (`.01.`, `.02.`, etc.)
129137
- **Metadata Export:** Complete header and configuration information
130138

131139
### **Architecture Benefits**
@@ -165,35 +173,9 @@ src/
165173

166174
---
167175

168-
## 🔍 **Current Data Processing**
169-
170-
### **Frame Processing**
171-
- **Frame Parsing:** Basic parsing of all major frame types
172-
- **Temporal Resolution:** Maintains flight sequence timing
173-
- **Error Detection:** Basic validation with diagnostic output
174-
- **Memory Management:** Streaming architecture for large files
175-
176-
### **Export Quality**
177-
- **CSV Compatibility:** Basic blackbox_decode format compatibility
178-
- **GPS Accuracy:** Coordinate conversion with firmware-specific scaling
179-
- **Event Mapping:** Official Betaflight FlightLogEvent enum compliance
180-
181-
---
182-
183-
## 📈 **Development Focus Areas**
184-
185-
### **Current Priorities**
186-
- **Testing:** Comprehensive validation across firmware versions
187-
- **Performance:** Optimization for large file processing
188-
- **Error Handling:** Improved diagnostic and recovery capabilities
189-
- **Documentation:** Complete API documentation and usage examples
190-
- **Compatibility:** Enhanced support for edge cases and unusual file formats
191-
192-
---
193-
194176
## 📋 **Usage Examples**
195177

196-
### **Basic Processing**
178+
### **Command-Line Interface**
197179
```bash
198180
# Single file analysis
199181
./target/release/bbl_parser flight.BBL
@@ -213,11 +195,14 @@ src/
213195
# All export formats
214196
./target/release/bbl_parser --csv --gpx --event logs/*.BBL
215197

198+
# Force export all logs (bypasses smart filtering)
199+
./target/release/bbl_parser --csv --force-export logs/*.BBL
200+
216201
# Debug mode for development analysis
217202
./target/release/bbl_parser --debug problematic_file.BBL
218203
```
219204

220-
### **Typical Output**
205+
### **Typical CLI Output**
221206
```
222207
Processing: BTFL_BLACKBOX_LOG_20250601_121852.BBL
223208
@@ -243,21 +228,6 @@ Exported event data to: BTFL_BLACKBOX_LOG_20250601_121852.event
243228

244229
---
245230

246-
## 🔍 **Current Data Processing**
247-
248-
### **Frame Processing**
249-
- **Frame Parsing:** Basic parsing of all major frame types
250-
- **Temporal Resolution:** Maintains flight sequence timing
251-
- **Error Detection:** Basic validation with diagnostic output
252-
- **Memory Management:** Streaming architecture for large files
253-
254-
### **Export Quality**
255-
- **CSV Compatibility:** Basic blackbox_decode format compatibility
256-
- **GPS Accuracy:** Coordinate conversion with firmware-specific scaling
257-
- **Event Mapping:** Official Betaflight FlightLogEvent enum compliance
258-
259-
---
260-
261231
## 🎯 **Use Cases & Applications**
262232

263233
### **Current Applications**
@@ -280,13 +250,18 @@ Exported event data to: BTFL_BLACKBOX_LOG_20250601_121852.event
280250
## 📝 **Documentation**
281251

282252
### **Available Documentation**
283-
- **README.md** - User guide, installation, usage examples, and complete library API documentation
284-
- **OVERVIEW.md** - Technical architecture and feature overview
253+
- **README.md** - CLI-focused user guide with installation and quick start
254+
- **CRATE_USAGE.md** - Rust crate API usage guide with code examples
255+
- **OVERVIEW.md** - Technical architecture and feature overview (this document)
285256
- **FRAMES.md** - Frame format specifications and encoding details
286257
- **GOALS.md** - Project objectives and design principles
258+
- **examples/README.md** - Example programs demonstrating crate usage
287259

288260
### **Development Documentation**
289-
API documentation available via `cargo doc` and comprehensive usage examples in README.md for library integration.
261+
- API documentation available via `cargo doc`
262+
- Comprehensive crate usage examples in `CRATE_USAGE.md` and `examples/`
263+
- Pre-commit hooks for automatic code formatting (`.github/pre-commit-hook.sh`)
264+
- Development environment setup script (`.github/setup-dev.sh`)
290265

291266
---
292267

0 commit comments

Comments
 (0)