From 106a2612bde889f3a651327f7fc929c0cd8e4362 Mon Sep 17 00:00:00 2001 From: Leonora Tindall Date: Sun, 29 Dec 2019 11:58:52 -0800 Subject: [PATCH] Add "blinky" main program --- CHANGELOG.md | 1 + src/main.rs | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0febaa5..8c7bf03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/main.rs b/src/main.rs index 5db461a..0fdaa9c 100644 --- a/src/main.rs +++ b/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() { - 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())); }