Browse Source

Add "blinky" main program

pull/1/head
Leonora Tindall 10 months ago
parent
commit
106a2612bd
Signed by: nora <nora@nora.codes> GPG Key ID: 7A8B52EC67E09AAF
2 changed files with 15 additions and 3 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +14
    -3
      src/main.rs

+ 1
- 0
CHANGELOG.md 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



+ 14
- 3
src/main.rs 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()));
}

Loading…
Cancel
Save