From 980a8432e625d61bf203b6af0079391bfba55be2 Mon Sep 17 00:00:00 2001 From: Blizzard Finnegan Date: Fri, 9 Jun 2023 10:46:00 -0400 Subject: [PATCH] Resolve init file write error Was originally trying to create a text file in the /dev path, which is not possible. Have now used string parsing to resolve this issue. --- Cargo.lock | 2 +- src/tty.rs | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d120f61..475c9f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -639,7 +639,7 @@ dependencies = [ [[package]] name = "seymour_poc_rust" -version = "2.0.1" +version = "2.1.0" dependencies = [ "chrono", "clap", diff --git a/src/tty.rs b/src/tty.rs index 1dba3d3..f28a0c7 100755 --- a/src/tty.rs +++ b/src/tty.rs @@ -78,8 +78,20 @@ pub struct TTY{ } impl std::fmt::Debug for TTY{ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result{ + let absolute_location = self.tty.name(); + let relative_location:String; + match absolute_location{ + Some(abs_location_string) => { + let sectioned_abs_location = abs_location_string.rsplit_once('/'); + match sectioned_abs_location{ + Some((_,serial_device_name)) => relative_location = serial_device_name.to_string(), + None => relative_location = "unknown".to_string() + } + }, + None => relative_location = "unknown".to_string() + }; f.debug_struct("TTY") - .field("Serial port name",&self.tty.name().unwrap_or("Unknown".to_string())) + .field("Serial port name",&relative_location) .finish() } }