Add debug options for bytes transmission

This commit is contained in:
2024-12-25 16:21:50 +01:00
parent e189d1b37f
commit 9b15774114
4 changed files with 53 additions and 39 deletions

View File

@@ -7,7 +7,6 @@ use clap::{
Subcommand,
};
use env_logger;
use hex;
use improv_setup::improv::{
RawPacket,
ImprovPacket,
@@ -15,12 +14,6 @@ use improv_setup::improv::{
RequestDeviceInformationPacket,
};
use improv_setup::serial;
use log::{
debug,
log_enabled,
info,
Level,
};
use tokio_serial;
#[derive(Subcommand, Clone)]
@@ -69,37 +62,6 @@ struct Cli {
command: Option<Commands>,
}
fn to_ascii_debug(bytes: &Vec<u8>) -> String {
let mut out = String::new();
for b in bytes {
if b.is_ascii_graphic() {
out += &b.escape_ascii().to_string();
}
else {
out.push_str(".");
}
}
return out;
}
fn to_bytewise_debug(bytes: &Vec<u8>) -> String {
let mut out = String::new();
for b in bytes {
out += &hex::encode(&[b.clone()]);
out += " ";
if b.is_ascii_graphic() {
out += &b.escape_ascii().to_string();
}
out += "\n";
}
return out;
}
#[tokio::main]
async fn main() -> Result<()>{