Add "blinky" main program

Este commit está contenido en:
Leonora Tindall 2019-12-29 11:58:52 -08:00
padre 8e52f10ffc
commit 106a2612bd
Firmado por: nora
ID de clave GPG: 7A8B52EC67E09AAF
Se han modificado 2 ficheros con 15 adiciones y 3 borrados

Ver fichero

@ -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

Ver fichero

@ -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()));
}