Display device info

This commit is contained in:
2024-12-21 14:27:34 +01:00
parent 859e5b5163
commit ff7338df6d
2 changed files with 58 additions and 4 deletions

View File

@@ -88,6 +88,23 @@ fn to_ascii_debug(bytes: &Vec<u8>) -> String {
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;
}
fn find_begin_of_improv_packet(buffer: &Vec<u8>) -> Result<usize, String> {
let mut improv_header_char: usize = 0;
@@ -186,9 +203,10 @@ async fn main() -> Result<()>{
let improv_packet_end = improv_packet_offset + 10 + <u8 as Into<usize>>::into(buffer[improv_packet_offset+8]);
let raw_packet = RawPacket::try_from_bytes(&buffer[improv_packet_offset..improv_packet_end].to_vec()).unwrap();
if let ImprovPacket::RPCResult(rpc_result) = ImprovPacket::try_from_raw_packet(&raw_packet).unwrap() {
println!("Received RPCResult");
for r in rpc_result.results {
println!("{}", &r);
}
}
},
};