Add looping option for main loop, if successful
This commit is contained in:
parent
39a5feff0f
commit
7fda440641
1 changed files with 93 additions and 88 deletions
19
src/main.rs
19
src/main.rs
|
@ -1,5 +1,10 @@
|
|||
use seymour_poc_rust::{device::Device, tty::{self,TTY,Response},gpio_facade::GpioPins};
|
||||
use std::{io::{stdin,stdout,Write},thread::{self, JoinHandle},path::Path,fs};
|
||||
use seymour_poc_rust::{device::Device,
|
||||
tty::{self,TTY,Response},
|
||||
gpio_facade::GpioPins};
|
||||
use std::{io::{stdin,stdout,Write},
|
||||
thread::{self, JoinHandle},
|
||||
path::Path,
|
||||
fs};
|
||||
use chrono::{DateTime,Local};
|
||||
|
||||
const VERSION:&str="2.0.1";
|
||||
|
@ -38,6 +43,7 @@ fn input_filtering(prompt:Option<&str>) -> String{
|
|||
fn main(){
|
||||
setup_logs();
|
||||
log::info!("Seymour Life Testing version: {}",VERSION);
|
||||
loop{
|
||||
let gpio = &mut GpioPins::new();
|
||||
match std::fs::read_dir("/dev/serial/by-path"){
|
||||
Ok(available_ttys)=>{
|
||||
|
@ -96,11 +102,6 @@ fn main(){
|
|||
log::info!("Number of devices detected: {}",devices.len());
|
||||
log::info!("--------------------------------------\n\n");
|
||||
|
||||
//log::info!("Dimming all screens...");
|
||||
//for device in devices.iter_mut(){
|
||||
// device.darken_screen();
|
||||
//}
|
||||
|
||||
for device in devices.iter_mut(){
|
||||
device.brighten_screen()
|
||||
.set_serial(&input_filtering(Some("Enter the serial of the device with the bright screen: ")).to_string())
|
||||
|
@ -133,8 +134,12 @@ fn main(){
|
|||
}
|
||||
Err(_)=>{
|
||||
log::error!("Invalid serial location! Please make sure that /dev/serial/by-path exists.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if input_filtering(Some("Would you like to run the tests again? (y/N): ")).to_string().contains("y") {}
|
||||
else { break; }
|
||||
}
|
||||
}
|
||||
|
||||
fn find_gpio(device:&mut Device,gpio:&mut GpioPins) -> bool{
|
||||
|
|
Loading…
Add table
Reference in a new issue