Add "blinky" main program

This commit is contained in:
Leonora Tindall 2019-12-29 11:58:52 -08:00
parent 8e52f10ffc
commit 106a2612bd
Signed by: nora
GPG Key ID: 7A8B52EC67E09AAF
2 changed files with 15 additions and 3 deletions

View File

@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- GNU GPL v3 license
- Cargo metadata
- Basic functionality
- "Blinky" main program
### Changed

View File

@ -1,6 +1,17 @@
use rn2903::Rn2903;
use rn2903::{Rn2903, bytes_to_string};
use std::thread;
use std::time::Duration;
fn main() {
let mut device = 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:"));
let mut txvr = Rn2903::new_at("/dev/ttyUSB0").expect("Could not open 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()));
}