Add debug options for bytes transmission
This commit is contained in:
38
src/main.rs
38
src/main.rs
@@ -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<()>{
|
||||
|
Reference in New Issue
Block a user