FleaScope RS
A Rust library for configuring triggers and communicating with FleaScope oscilloscope devices.
This library is a complete port of the Python pyFleaScope library to Rust, providing idiomatic Rust APIs for device control, data acquisition, and calibration management.
Features
- Cross-platform device discovery: Uses
serialportfor finding FleaScope devices across Windows, Linux, and macOS - Trigger configuration: Digital and analog triggers with builder patterns and type safety
- Data acquisition: Raw oscilloscope data reading with automatic time indexing
- Probe calibration: Automated zero and 3.3V calibration procedures
- Calibration management: Read/write probe calibrations from/to device flash memory
- DataFrame output: Uses
polarsfor efficient data handling (replacing pandas) - Type safety: Strong typing and comprehensive error handling throughout
- Memory efficiency: Iterator-based device discovery for reduced memory usage
- Comprehensive testing: Full test coverage with both unit tests and documentation tests
Installation
Add this to your Cargo.toml:
[]
= { = "path/to/fleascope-rs" }
Quick Start
Basic Connection and Data Reading
use ;
use Duration;
Device Discovery
use FleaConnector;
Digital Triggers
use ;
use Duration;
Analog Triggers
use ;
use Duration;
Calibration
use FleaScope;
API Reference
Core Types
FleaScope: Main oscilloscope control interfaceFleaConnector: Device discovery and connection managementFleaTerminal: Low-level serial communicationFleaProbe: Probe calibration and voltage conversionDigitalTrigger: Digital pattern triggersAnalogTrigger: Analog level/edge triggers
Data Acquisition Methods
read_x1(): Read with 1x probe and auto triggerread_x10(): Read with 10x probe and auto triggerread_x1_digital(): Read with 1x probe and digital triggerread_x10_digital(): Read with 10x probe and digital triggerread_x1_analog(): Read with 1x probe and analog triggerread_x10_analog(): Read with 10x probe and analog trigger
Trigger Configuration
Digital triggers support 9 bits (bit0-bit8) with states:
BitState::High: Bit must be highBitState::Low: Bit must be lowBitState::DontCare: Ignore this bit
Trigger behaviors:
starts_matching(): Start when pattern first matchesstops_matching(): Start when pattern stops matchingis_matching(): Continuously capture while matching
Analog triggers support:
rising_edge(voltage): Trigger on rising edgefalling_edge(voltage): Trigger on falling edgelevel(voltage): Trigger on level crossing
Error Handling
The library uses thiserror for comprehensive error handling:
use ;
match connect
Data Output
All data acquisition methods return a polars::DataFrame with columns:
time: Time in seconds from triggerbnc: Voltage values (converted from raw ADC values)bitmap: Raw digital bit values (hex string)
For digital data analysis, use FleaScope::extract_bits() to convert the bitmap column into individual bit columns (bit_0, bit_1, etc.).
Platform Support
This library supports Windows, Linux, and macOS through the serialport crate. Device discovery automatically handles platform-specific USB device enumeration.
Dependencies
serialport: Cross-platform serial port communicationpolars: High-performance DataFrame librarycsv: CSV parsing for data acquisitionchrono: Time and duration handlingthiserror: Error handlinglog: Logging support
Differences from Python Version
- Memory efficiency: Iterator-based device discovery
- Type safety: Strong typing prevents many runtime errors
- Performance: Rust's zero-cost abstractions and polars for data handling
- Error handling: Comprehensive error types with context
- Cross-platform: Better cross-platform device discovery
- API consistency: More consistent method naming and parameter ordering
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Run
cargo testandcargo clippy - Submit a pull request
License
This project maintains the same license as the original Python version.
Testing
Run the full test suite:
Run tests with output:
Run clippy for additional code quality checks:
Format code:
Examples
See the examples/ directory for more comprehensive usage examples and real-world scenarios.