Add looping option for main loop, if successful

This commit is contained in:
Blizzard Finnegan 2023-06-01 13:12:02 -04:00
parent 39a5feff0f
commit 7fda440641

View file

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