BradenEverson / driem

Embedded RL with modular rewards based on peripherals and a simulation server for deciding best actions
2 stars 1 forks source link

Input and Output implementations for Raspberry Pi #6

Closed BradenEverson closed 1 week ago

BradenEverson commented 1 week ago

This PR introduces new functionality to support both Jetson Orin Nano and Raspberry Pi hardware in the achiever project. It includes updated traits for input and output peripherals and error handling for hardware-specific implementations. The addition of feature flags ensures compatibility with different target systems. Changes:

✨ [Cargo.toml]: Added new feature flags (jetson, rpi) to conditionally compile hardware-specific code for either Jetson Orin Nano or Raspberry Pi.
πŸ”§ [body.rs]: Improved error handling for Peripheral enum by making Input and Output variants handle dynamic errors (Box<dyn Error>).
✨ [inputs.rs, outputs.rs]: Added implementations of Input and Output traits for Raspberry Pi using the rppal crate, and for Jetson with future extensibility.
πŸ”§ [agent.rs]: Updated act method to propagate errors from output peripherals via the newly introduced Result type.
πŸ“ [lib.rs]: Introduced a compile-time error if both jetson and rpi features are enabled simultaneously.

Features:

πŸš€ Jetson and Raspberry Pi Support: Enables interaction with GPIO, I2C, SPI, and UART peripherals on both platforms.
⚠️ Enhanced Error Handling: Ensures that read/write operations on peripherals return meaningful error types, improving system robustness.
🧩 Configurable via Features: Users can now target either Jetson or Raspberry Pi by setting the appropriate feature flag (rpi or jetson).

Additional Notes:

πŸ› A safeguard has been added to prevent compiling for both Jetson and Raspberry Pi at the same time (compile_error! in lib.rs).