v2.1.0 #3
6 changed files with 364 additions and 85 deletions
43
.forgejo/workflows/buildcheck.yaml
Normal file
43
.forgejo/workflows/buildcheck.yaml
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
name: Basic Cargo Checks
|
||||||
|
run-name: ${{ github.actor }} is testing
|
||||||
|
on: [push]
|
||||||
|
jobs:
|
||||||
|
docker-check:
|
||||||
|
runs-on: docker
|
||||||
|
steps:
|
||||||
|
- name: Grab misc. dependencies
|
||||||
|
run: |
|
||||||
|
apt update && apt install -y librust-libudev-sys-dev build-essential
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Grab Rust toolchain
|
||||||
|
uses: https://github.com/actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
profile: minimal
|
||||||
|
toolchain: stable
|
||||||
|
target: aarch64-unknown-linux-gnu
|
||||||
|
override: true
|
||||||
|
- name: Run check
|
||||||
|
uses: https://github.com/actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: check
|
||||||
|
docker-build:
|
||||||
|
runs-on: docker
|
||||||
|
steps:
|
||||||
|
- name: Grab misc. dependencies
|
||||||
|
run: |
|
||||||
|
apt update && apt install -y librust-libudev-sys-dev build-essential
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Grab Rust toolchain
|
||||||
|
uses: https://github.com/actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
profile: minimal
|
||||||
|
toolchain: stable
|
||||||
|
target: aarch64-unknown-linux-gnu
|
||||||
|
override: true
|
||||||
|
- name: Run check
|
||||||
|
uses: https://github.com/actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: build
|
||||||
|
args: --release
|
195
Cargo.lock
generated
195
Cargo.lock
generated
|
@ -41,6 +41,55 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anstream"
|
||||||
|
version = "0.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163"
|
||||||
|
dependencies = [
|
||||||
|
"anstyle",
|
||||||
|
"anstyle-parse",
|
||||||
|
"anstyle-query",
|
||||||
|
"anstyle-wincon",
|
||||||
|
"colorchoice",
|
||||||
|
"is-terminal",
|
||||||
|
"utf8parse",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anstyle"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anstyle-parse"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee"
|
||||||
|
dependencies = [
|
||||||
|
"utf8parse",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anstyle-query"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b"
|
||||||
|
dependencies = [
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anstyle-wincon"
|
||||||
|
version = "1.0.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188"
|
||||||
|
dependencies = [
|
||||||
|
"anstyle",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
@ -92,6 +141,48 @@ dependencies = [
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap"
|
||||||
|
version = "4.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "401a4694d2bf92537b6867d94de48c4842089645fdcdf6c71865b175d836e9c2"
|
||||||
|
dependencies = [
|
||||||
|
"clap_builder",
|
||||||
|
"clap_derive",
|
||||||
|
"once_cell",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap_builder"
|
||||||
|
version = "4.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "72394f3339a76daf211e57d4bcb374410f3965dcc606dd0e03738c7888766980"
|
||||||
|
dependencies = [
|
||||||
|
"anstream",
|
||||||
|
"anstyle",
|
||||||
|
"bitflags",
|
||||||
|
"clap_lex",
|
||||||
|
"strsim",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap_derive"
|
||||||
|
version = "4.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b8cd2b2a819ad6eec39e8f1d6b53001af1e5469f8c177579cdaeb313115b825f"
|
||||||
|
dependencies = [
|
||||||
|
"heck",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.15",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap_lex"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "codespan-reporting"
|
name = "codespan-reporting"
|
||||||
version = "0.11.1"
|
version = "0.11.1"
|
||||||
|
@ -102,6 +193,12 @@ dependencies = [
|
||||||
"unicode-width",
|
"unicode-width",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "colorchoice"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "const_fn"
|
name = "const_fn"
|
||||||
version = "0.4.9"
|
version = "0.4.9"
|
||||||
|
@ -175,6 +272,27 @@ version = "1.0.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0"
|
checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "errno"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a"
|
||||||
|
dependencies = [
|
||||||
|
"errno-dragonfly",
|
||||||
|
"libc",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "errno-dragonfly"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fern"
|
name = "fern"
|
||||||
version = "0.6.2"
|
version = "0.6.2"
|
||||||
|
@ -184,6 +302,18 @@ dependencies = [
|
||||||
"log",
|
"log",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "heck"
|
||||||
|
version = "0.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hermit-abi"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iana-time-zone"
|
name = "iana-time-zone"
|
||||||
version = "0.1.56"
|
version = "0.1.56"
|
||||||
|
@ -208,6 +338,29 @@ dependencies = [
|
||||||
"cxx-build",
|
"cxx-build",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "io-lifetimes"
|
||||||
|
version = "1.0.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2"
|
||||||
|
dependencies = [
|
||||||
|
"hermit-abi",
|
||||||
|
"libc",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "is-terminal"
|
||||||
|
version = "0.4.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f"
|
||||||
|
dependencies = [
|
||||||
|
"hermit-abi",
|
||||||
|
"io-lifetimes",
|
||||||
|
"rustix",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itoa"
|
name = "itoa"
|
||||||
version = "1.0.6"
|
version = "1.0.6"
|
||||||
|
@ -258,6 +411,12 @@ dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "linux-raw-sys"
|
||||||
|
version = "0.3.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "log"
|
name = "log"
|
||||||
version = "0.4.17"
|
version = "0.4.17"
|
||||||
|
@ -392,6 +551,20 @@ dependencies = [
|
||||||
"semver",
|
"semver",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustix"
|
||||||
|
version = "0.37.19"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"errno",
|
||||||
|
"io-lifetimes",
|
||||||
|
"libc",
|
||||||
|
"linux-raw-sys",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ryu"
|
name = "ryu"
|
||||||
version = "1.0.13"
|
version = "1.0.13"
|
||||||
|
@ -469,6 +642,7 @@ name = "seymour_poc_rust"
|
||||||
version = "2.0.1"
|
version = "2.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
|
"clap",
|
||||||
"derivative",
|
"derivative",
|
||||||
"fern",
|
"fern",
|
||||||
"log",
|
"log",
|
||||||
|
@ -551,6 +725,12 @@ version = "0.1.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0"
|
checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "strsim"
|
||||||
|
version = "0.10.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "1.0.109"
|
version = "1.0.109"
|
||||||
|
@ -643,6 +823,12 @@ version = "0.1.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
|
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "utf8parse"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "version_check"
|
name = "version_check"
|
||||||
version = "0.9.4"
|
version = "0.9.4"
|
||||||
|
@ -749,6 +935,15 @@ dependencies = [
|
||||||
"windows-targets",
|
"windows-targets",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-sys"
|
||||||
|
version = "0.48.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
|
||||||
|
dependencies = [
|
||||||
|
"windows-targets",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-targets"
|
name = "windows-targets"
|
||||||
version = "0.48.0"
|
version = "0.48.0"
|
||||||
|
|
|
@ -16,6 +16,7 @@ chrono = "0.4.24"
|
||||||
once_cell = "1.17.1"
|
once_cell = "1.17.1"
|
||||||
derivative = "2.2.0"
|
derivative = "2.2.0"
|
||||||
time = "0.2.23"
|
time = "0.2.23"
|
||||||
|
clap = { version = "4.3.2", features = ["derive"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
time = "0.2.23"
|
time = "0.2.23"
|
||||||
|
|
2
build_requirements.md
Normal file
2
build_requirements.md
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
librust-udev-sys-dev
|
||||||
|
pkg-config
|
|
@ -284,6 +284,9 @@ impl Device{
|
||||||
pub fn get_serial(&mut self) -> &str{
|
pub fn get_serial(&mut self) -> &str{
|
||||||
&self.serial
|
&self.serial
|
||||||
}
|
}
|
||||||
|
pub fn get_location(&mut self) -> String{
|
||||||
|
std::format!("{:?}",self.usb_tty)
|
||||||
|
}
|
||||||
pub fn set_pin_address(&mut self, address:u8) -> &mut Self{
|
pub fn set_pin_address(&mut self, address:u8) -> &mut Self{
|
||||||
self.address = Some(address.clone());
|
self.address = Some(address.clone());
|
||||||
let temp = self.gpio.get(address);
|
let temp = self.gpio.get(address);
|
||||||
|
|
205
src/main.rs
205
src/main.rs
|
@ -1,8 +1,21 @@
|
||||||
use seymour_poc_rust::{device::Device, tty::{self,TTY,Response},gpio_facade::GpioPins};
|
use seymour_poc_rust::{device::Device,
|
||||||
use std::{io::{stdin,stdout,Write},thread::{self, JoinHandle},path::Path,fs};
|
tty::{self,TTY,Response},
|
||||||
|
gpio_facade::GpioPins};
|
||||||
|
use std::{io::{stdin,stdout,Write},
|
||||||
|
thread::{self, JoinHandle},
|
||||||
|
path::Path,
|
||||||
|
fs};
|
||||||
use chrono::{DateTime,Local};
|
use chrono::{DateTime,Local};
|
||||||
|
use clap::Parser;
|
||||||
|
|
||||||
const VERSION:&str="2.0.1";
|
#[derive(Parser,Debug)]
|
||||||
|
#[command(author,version,about)]
|
||||||
|
struct Args{
|
||||||
|
#[arg(short,long,action)]
|
||||||
|
debug:bool
|
||||||
|
}
|
||||||
|
|
||||||
|
const VERSION:&str="2.1.0";
|
||||||
|
|
||||||
fn int_input_filtering(prompt:Option<&str>) -> u64{
|
fn int_input_filtering(prompt:Option<&str>) -> u64{
|
||||||
let internal_prompt = prompt.unwrap_or(">>>");
|
let internal_prompt = prompt.unwrap_or(">>>");
|
||||||
|
@ -37,107 +50,129 @@ fn input_filtering(prompt:Option<&str>) -> String{
|
||||||
|
|
||||||
fn main(){
|
fn main(){
|
||||||
setup_logs();
|
setup_logs();
|
||||||
|
let args = Args::parse();
|
||||||
log::info!("Seymour Life Testing version: {}",VERSION);
|
log::info!("Seymour Life Testing version: {}",VERSION);
|
||||||
let gpio = &mut GpioPins::new();
|
if args.debug{
|
||||||
match std::fs::read_dir("/dev/serial/by-path"){
|
log::debug!("Debug enabled!");
|
||||||
Ok(available_ttys)=>{
|
}
|
||||||
let mut possible_devices:Vec<Option<Device>> = Vec::new();
|
loop{
|
||||||
let mut tty_test_threads:Vec<JoinHandle<Option<Device>>> = Vec::new();
|
let gpio = &mut GpioPins::new();
|
||||||
for possible_tty in available_ttys.into_iter(){
|
match std::fs::read_dir("/dev/serial/by-path"){
|
||||||
tty_test_threads.push(
|
Ok(available_ttys)=>{
|
||||||
thread::spawn(move ||{
|
let mut possible_devices:Vec<Option<Device>> = Vec::new();
|
||||||
let tty_ref = possible_tty.as_ref();
|
let mut tty_test_threads:Vec<JoinHandle<Option<Device>>> = Vec::new();
|
||||||
match tty_ref{
|
for possible_tty in available_ttys.into_iter(){
|
||||||
Ok(tty_real_ref)=>{
|
tty_test_threads.push(
|
||||||
let tty_path = tty_real_ref.path();
|
thread::spawn(move ||{
|
||||||
let tty_name = tty_path.to_string_lossy();
|
let tty_ref = possible_tty.as_ref();
|
||||||
log::info!("Testing port {}. This may take a moment...",&tty_name);
|
match tty_ref{
|
||||||
let possible_port = TTY::new(&tty_name);
|
Ok(tty_real_ref)=>{
|
||||||
match possible_port{
|
let tty_path = tty_real_ref.path();
|
||||||
Some(mut port) =>{
|
let tty_name = tty_path.to_string_lossy();
|
||||||
port.write_to_device(tty::Command::Newline);
|
log::info!("Testing port {}. This may take a moment...",&tty_name);
|
||||||
let response = port.read_from_device(Some(":"));
|
let possible_port = TTY::new(&tty_name);
|
||||||
if response != Response::Empty{
|
match possible_port{
|
||||||
log::debug!("{} is valid port!",tty_name);
|
Some(mut port) =>{
|
||||||
let new_device = Device::new(port,Some(response));
|
port.write_to_device(tty::Command::Newline);
|
||||||
match new_device{
|
let response = port.read_from_device(Some(":"));
|
||||||
Ok(device) => Some(device),
|
if response != Response::Empty{
|
||||||
Err(_) => None
|
log::debug!("{} is valid port!",tty_name);
|
||||||
|
let new_device = Device::new(port,Some(response));
|
||||||
|
match new_device{
|
||||||
|
Ok(mut device) => {
|
||||||
|
device.darken_screen();
|
||||||
|
Some(device)
|
||||||
|
},
|
||||||
|
Err(_) => None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
else { None }
|
||||||
else { None }
|
},
|
||||||
},
|
None=>{None}
|
||||||
None=>{None}
|
}
|
||||||
|
},
|
||||||
|
Err(error)=>{
|
||||||
|
log::debug!("{}",error);
|
||||||
|
None
|
||||||
}
|
}
|
||||||
},
|
|
||||||
Err(error)=>{
|
|
||||||
//log::warn!("Invalid TTY location");
|
|
||||||
log::debug!("{}",error);
|
|
||||||
None
|
|
||||||
}
|
}
|
||||||
}
|
}));
|
||||||
}));
|
}
|
||||||
}
|
for thread in tty_test_threads{
|
||||||
for thread in tty_test_threads{
|
let output = thread.join().unwrap_or_else(|x|{log::trace!("{:?}",x); None});
|
||||||
let output = thread.join().unwrap_or_else(|x|{log::trace!("{:?}",x); None});
|
possible_devices.push(output);
|
||||||
possible_devices.push(output);
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut devices:Vec<Device> = Vec::new();
|
|
||||||
for possible_device in possible_devices.into_iter(){
|
|
||||||
if let Some(device) = possible_device{
|
|
||||||
devices.push(device);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
log::info!("Number of devices detected: {}",devices.len());
|
let mut devices:Vec<Device> = Vec::new();
|
||||||
|
for possible_device in possible_devices.into_iter(){
|
||||||
|
if let Some(device) = possible_device{
|
||||||
|
devices.push(device);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
log::info!("Dimming all screens...");
|
log::info!("\n\n--------------------------------------");
|
||||||
for device in devices.iter_mut(){
|
log::info!("Number of devices detected: {}",devices.len());
|
||||||
device.darken_screen();
|
log::info!("--------------------------------------\n\n");
|
||||||
}
|
|
||||||
|
|
||||||
for device in devices.iter_mut(){
|
for device in devices.iter_mut(){
|
||||||
device.brighten_screen()
|
device.brighten_screen();
|
||||||
.set_serial(&input_filtering(Some("Enter the serial of the device with the bright screen: ")).to_string())
|
if args.debug{
|
||||||
.darken_screen();
|
let location = device.get_location();
|
||||||
log::debug!("Number of unassigned addresses: {}",gpio.get_unassigned_addresses().len());
|
device.set_serial(&location);
|
||||||
for &address in gpio.get_unassigned_addresses(){
|
|
||||||
device.set_pin_address(address).start_temp();
|
|
||||||
if device.is_temp_running(){
|
|
||||||
device.stop_temp();
|
|
||||||
gpio.remove_address(address);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
device.stop_temp();
|
device.set_serial(&input_filtering(Some("Enter the serial of the device with the bright screen: ")).to_string());
|
||||||
|
}
|
||||||
|
device.darken_screen();
|
||||||
|
log::debug!("Number of unassigned addresses: {}",gpio.get_unassigned_addresses().len());
|
||||||
|
if !find_gpio(device, gpio){
|
||||||
|
device.set_pin_address(21);
|
||||||
|
log::error!("Unable to find GPIO for device {}. Please ensure that the probe well is installed properly, and the calibration key is plugged in.",device.get_location());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let mut iteration_count:u64 = 0;
|
let mut iteration_count:u64 = 0;
|
||||||
while iteration_count < 1{
|
while iteration_count < 1{
|
||||||
iteration_count = int_input_filtering(Some("Enter the number of iterations to complete: "));
|
iteration_count = int_input_filtering(Some("Enter the number of iterations to complete: "));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut iteration_threads = Vec::new();
|
let mut iteration_threads = Vec::new();
|
||||||
while let Some(mut device) = devices.pop(){
|
while let Some(mut device) = devices.pop(){
|
||||||
iteration_threads.push(thread::spawn(move||{
|
iteration_threads.push(thread::spawn(move||{
|
||||||
for i in 1..=iteration_count{
|
for i in 1..=iteration_count{
|
||||||
log::info!("Starting iteration {} of {} for device {}...",
|
log::info!("Starting iteration {} of {} for device {}...",
|
||||||
i,iteration_count,device.get_serial());
|
i,iteration_count,device.get_serial());
|
||||||
device.test_cycle(None, None);
|
device.test_cycle(None, None);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
}
|
||||||
|
for thread in iteration_threads{
|
||||||
|
thread.join().unwrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for thread in iteration_threads{
|
Err(_)=>{
|
||||||
thread.join().unwrap();
|
log::error!("Invalid serial location! Please make sure that /dev/serial/by-path exists.");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(_)=>{
|
if input_filtering(Some("Would you like to run the tests again? (y/N): ")).to_string().contains("y") {}
|
||||||
log::error!("Invalid serial location! Please make sure that /dev/serial/by-path exists.");
|
else { break; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn find_gpio(device:&mut Device,gpio:&mut GpioPins) -> bool{
|
||||||
|
for &address in gpio.get_unassigned_addresses(){
|
||||||
|
device.set_pin_address(address).start_temp();
|
||||||
|
if device.is_temp_running(){
|
||||||
|
device.stop_temp();
|
||||||
|
gpio.remove_address(address);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
device.stop_temp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setup_logs(){
|
pub fn setup_logs(){
|
||||||
|
|
Loading…
Add table
Reference in a new issue