Add "blinky" main program
This commit is contained in:
parent
8e52f10ffc
commit
106a2612bd
|
@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- GNU GPL v3 license
|
- GNU GPL v3 license
|
||||||
- Cargo metadata
|
- Cargo metadata
|
||||||
- Basic functionality
|
- Basic functionality
|
||||||
|
- "Blinky" main program
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|
17
src/main.rs
17
src/main.rs
|
@ -1,6 +1,17 @@
|
||||||
use rn2903::Rn2903;
|
use rn2903::{Rn2903, bytes_to_string};
|
||||||
|
use std::thread;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut device = Rn2903::new_at("/dev/ttyUSB0").expect("Could not open device. Error");
|
let mut txvr = Rn2903::new_at("/dev/ttyUSB0").expect("Could not open device. Error");
|
||||||
println!("Successfully connected. Version: {}", device.system_version().expect("Could not read from device. Error:"));
|
println!(
|
||||||
|
"Successfully connected. Version: {}",
|
||||||
|
txvr
|
||||||
|
.system_version()
|
||||||
|
.expect("Could not read from device. Error:")
|
||||||
|
);
|
||||||
|
|
||||||
|
dbg!(bytes_to_string(&txvr.transact(b"sys set pindig GPIO10 1").unwrap()));
|
||||||
|
thread::sleep(Duration::from_millis(200));
|
||||||
|
dbg!(bytes_to_string(&txvr.transact(b"sys set pindig GPIO10 0").unwrap()));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue