From dddea53d26bb5c1c1b2d38c0c9a2c0c6354c3abb Mon Sep 17 00:00:00 2001 From: morgan Date: Thu, 12 Sep 2024 17:02:36 +0800 Subject: [PATCH] proto fw: add print u32 packet helper function --- src/libboard_artiq/src/cxp_proto.rs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/libboard_artiq/src/cxp_proto.rs b/src/libboard_artiq/src/cxp_proto.rs index 58b82fb..dd39d76 100644 --- a/src/libboard_artiq/src/cxp_proto.rs +++ b/src/libboard_artiq/src/cxp_proto.rs @@ -192,13 +192,30 @@ pub fn print_packet(pak: &[u8]) { 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() { downconn_debug_send(&Packet::CtrlRead { addr: 0x00, length: 0x04, }); - const LEN: usize = 100; + const LEN: usize = 40; let mut pak_arr: [u32; LEN] = [0; LEN]; let mut i: usize = 0; unsafe { @@ -213,9 +230,7 @@ pub fn downconn_debug_main() { } } - // TODO: turn the u32 slice back to u8 - - println!("{:#010X?}", pak_arr) + print_packetu32(&pak_arr) } pub fn downconn_debug_send(packet: &Packet) -> Result<(), Error> {