1
0
Fork 0

proto fw: add print u32 packet helper function

This commit is contained in:
morgan 2024-09-12 17:02:36 +08:00
parent a87208effe
commit dddea53d26
1 changed files with 19 additions and 4 deletions

View File

@ -192,13 +192,30 @@ pub fn print_packet(pak: &[u8]) {
println!("============================================"); println!("============================================");
} }
pub fn print_packetu32(pak: &[u32]) {
println!("pak = [");
for i in 0..(pak.len()) {
let data: [u8; 4] = pak[i].to_be_bytes();
println!(
"{:#03} {:#04X} {:#04X} {:#04X} {:#04X},",
i + 1,
data[0],
data[1],
data[2],
data[3]
)
}
println!("]");
println!("============================================");
}
pub fn downconn_debug_main() { pub fn downconn_debug_main() {
downconn_debug_send(&Packet::CtrlRead { downconn_debug_send(&Packet::CtrlRead {
addr: 0x00, addr: 0x00,
length: 0x04, length: 0x04,
}); });
const LEN: usize = 100; const LEN: usize = 40;
let mut pak_arr: [u32; LEN] = [0; LEN]; let mut pak_arr: [u32; LEN] = [0; LEN];
let mut i: usize = 0; let mut i: usize = 0;
unsafe { unsafe {
@ -213,9 +230,7 @@ pub fn downconn_debug_main() {
} }
} }
// TODO: turn the u32 slice back to u8 print_packetu32(&pak_arr)
println!("{:#010X?}", pak_arr)
} }
pub fn downconn_debug_send(packet: &Packet) -> Result<(), Error> { pub fn downconn_debug_send(packet: &Packet) -> Result<(), Error> {