Merge pull request 'v.2.3.1' (#9) from devel into stable
All checks were successful
Basic Cargo Checks / docker-build (push) Successful in 1m40s
Basic Cargo Checks / docker-check (push) Successful in 1m37s

Reviewed-on: #9
This commit is contained in:
Blizzard Finnegan 2023-06-20 12:24:22 -04:00
commit ed897d6ff7
Signed by: Blizzard Finnegan
GPG key ID: 1513350E4C45A14F
5 changed files with 116 additions and 17 deletions

4
Cargo.lock generated
View file

@ -638,8 +638,8 @@ dependencies = [
]
[[package]]
name = "seymour_life_rust"
version = "2.3.0"
name = "seymour_life"
version = "2.3.1"
dependencies = [
"chrono",
"clap",

View file

@ -1,8 +1,8 @@
#cargo-features = ["per-package-target"]
[package]
name = "seymour_life_rust"
version = "2.3.0"
name = "seymour_life"
version = "2.3.1"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

71
README.md Normal file
View file

@ -0,0 +1,71 @@
# Seymour Life
This is a personal/professional project, which makes use of serial communications (tty over USB via UART) and Raspberry Pi GPIO to simulate long term use of a Seymour device.
Note that this project will ONLY run properly on a Raspberry Pi. It is developed on, and tested for, the Raspberry Pi 400. This should also be compatible with the Raspberry Pi 4, and Raspberry Pi 3, although they have not been explicitly tested. Older models of Raspberry Pi may work properly, however as this project is originally intended for the `aarch64`/`ARM64` architecture, and older compatibility will not be tested.
## Install
### Precompiled Binary
Pre-compiled binaries can be found in the [releases tab](https://git.blizzard.systems/blizzardfinnegan/seymourLifeRust/releases/latest). Download the preferred version to your preferred directory, then run the following command to make the code executable:
```bash
sudo chmod u+x ./seymour_life
```
To run the binary, simply run:
```bash
sudo ./seymour_life
```
Note that this command MUST be run as `sudo`/root, due to the way it interacts with GPIO. For more information, please see [the GPIO documentation](https://github.com/golemparts/rppal).
## Build From Source
Note: *At this time, this project can only reliably be built on Linux. Build instructions for Windows will be written eventually.*
To build this project from source, first, download the repository. This can be done by using the Download ZIP button, or running the following command in a terminal where `git` is installed:
```bash
git clone https://git.blizzard.systems/blizzardfinnegan/seymourLifeRust
```
Once the repository has been downloaded, the project can be built with `cargo`. This can be done using any of the listed install methods on [the Rust install website](https://rustup.rs/).
Once cargo has been installed, run the following to build the project:
```bash
cargo build --release
```
The runnable command can then be run by the following:
```bash
sudo ./target/release/seymour_life
```
You can also build without the `--release` flag, which wil take less time, but will be less optimised for the hardware. If you do this, substitue `./target/release/seymour_life` for `./target/debug/seymour_life` in the above command.
### Build Dependencies
The following dependencies are also necessary for building this project:
- `pkg-config`
- `libudev`
See below for platform specific requirements.
#### Debian-based
This applies for all distributions of Linux using the `apt` package manager, including but not limited to Debian, Ubuntu, Raspbian/Raspberry Pi OS, and Linux Mint.
```bash
sudo apt-get install librust-libudev-sys-dev librust-pkg-config-dev
```
#### Fedora-based
This applies for all distributions of Linux using the `dnf` package manager, including but not limited to CentOS, Redhat Enterprise Linux (RHEL), and Fedora.
```bash
sudo dnf install rust-libudev-sys-devel rust-pkg-config-devel
```
#### Nix
This applies to both NixOS, and any distribution where the [Nix package manager](https://nixos.org/download.html) can be installed.
If you have the Nix package manager installed, this project comes with a `shell.nix` containing the necessary build dependencies. Simply run `nix-shell` to download the necessary dependencies.

View file

@ -346,7 +346,7 @@ impl Device{
}
return true
}
pub fn set_serial(&mut self) -> &mut Self{
pub fn auto_set_serial(&mut self) -> bool{
self.reboot();
self.usb_tty.write_to_device(Command::Login);
while self.usb_tty.read_from_device(None) != Response::ShellPrompt {}
@ -368,7 +368,7 @@ impl Device{
Response::DebugInit | Response::Empty | Response::EmptyNewline => { continue; }
_ => {
log::error!("Bad value: {:?}",return_value);
todo!();
return false
},
}
}
@ -378,9 +378,15 @@ impl Device{
self.reboot();
self.load_values();
self.save_values();
return true
}
pub fn manual_set_serial(&mut self, serial:&str) -> &mut Self{
self.serial = serial.to_string();
self.load_values();
self.save_values();
return self;
}
pub fn get_serial(&mut self) -> &str{
pub fn get_serial(&self) -> &str{
&self.serial
}
pub fn get_location(&mut self) -> String{

View file

@ -1,6 +1,6 @@
use seymour_life_rust::{device::Device,
tty::{self,TTY,Response},
gpio_facade::GpioPins};
use seymour_life::{device::Device,
tty::{self,TTY,Response},
gpio_facade::GpioPins};
use std::{io::{stdin,stdout,Write},
thread::{self, JoinHandle},
path::Path,
@ -11,11 +11,22 @@ use clap::Parser;
#[derive(Parser,Debug)]
#[command(author,version,about)]
struct Args{
/// Print all logs to screen. Sets iteration count to 50000
#[arg(short,long,action)]
debug:bool
debug:bool,
/// Force manually setting serial numbers
#[arg(short,long,action)]
manual:bool,
/// Set iteration count from command line
#[arg(short,long)]
iterations:Option<u64>
}
const VERSION:&str="2.3.0";
const VERSION:&str="2.3.1";
const DEBUG_ITERATION_COUNT:u64=50000;
fn int_input_filtering(prompt:Option<&str>) -> u64{
let internal_prompt = prompt.unwrap_or(">>>");
@ -58,7 +69,10 @@ fn main(){
loop{
let mut iteration_count:u64 = 0;
if args.debug {
iteration_count = 10000;
iteration_count = DEBUG_ITERATION_COUNT;
}
else if let Some(value) = args.iterations{
iteration_count = value;
}
else {
while iteration_count < 1{
@ -91,7 +105,9 @@ fn main(){
match new_device{
Ok(mut device) => {
device.darken_screen();
device.set_serial();
if !args.manual {
device.auto_set_serial();
}
Some(device)
},
Err(_) => None
@ -114,9 +130,13 @@ fn main(){
possible_devices.push(output);
}
let mut serials_set:bool = true;
let mut devices:Vec<Device> = Vec::new();
for possible_device in possible_devices.into_iter(){
if let Some(device) = possible_device{
if device.get_serial().eq("uninitialised"){
serials_set = false;
}
devices.push(device);
}
}
@ -126,9 +146,11 @@ fn main(){
log::info!("--------------------------------------\n\n");
for device in devices.iter_mut(){
//device.brighten_screen();
//device.set_serial();
//device.darken_screen();
if !serials_set || args.manual {
device.brighten_screen();
device.manual_set_serial(&input_filtering(Some("Enter the serial of the device with the bright screen: ")).to_string());
device.darken_screen();
}
log::info!("Checking probe well of device {}",device.get_serial());
log::debug!("Number of unassigned addresses: {}",gpio.get_unassigned_addresses().len());
if !find_gpio(device, gpio){