diff --git a/src/libboard_artiq/src/drtioaux.rs b/src/libboard_artiq/src/drtioaux.rs index 9e27ac9..da3aaab 100644 --- a/src/libboard_artiq/src/drtioaux.rs +++ b/src/libboard_artiq/src/drtioaux.rs @@ -5,10 +5,15 @@ use crc; use io::{proto::{ProtoRead, ProtoWrite}, Cursor}; use libboard_zynq::{time::Milliseconds, timer::GlobalTimer}; +use log::info; pub use crate::drtioaux_proto::Packet; use crate::{drtioaux_proto::Error as ProtocolError, mem::mem::DRTIOAUX_MEM, pl::csr::DRTIOAUX}; +const DRTIO_LOG_N: usize = 2048; +static mut DRTIO_LOG: [(bool, u8, Packet); DRTIO_LOG_N] = [(false, 255, Packet::EchoRequest); DRTIO_LOG_N]; +static mut DRTIO_LOG_I: usize = 0; + #[derive(Debug)] pub enum Error { GatewareError, @@ -93,6 +98,10 @@ pub fn recv(linkno: u8) -> Result, Error> { if reader.read_u32()? != checksum { return Err(Error::CorruptedPacket); } + unsafe { + DRTIO_LOG[DRTIO_LOG_I] = (false, linkno, packet.clone()); + DRTIO_LOG_I = (DRTIO_LOG_I + 1) % 2048; + } Ok(packet) }) } @@ -125,7 +134,10 @@ where F: FnOnce(&mut [u8]) -> Result { pub fn send(linkno: u8, packet: &Packet) -> Result<(), Error> { transmit(linkno, |buffer| { let mut writer = Cursor::new(buffer); - + unsafe { + DRTIO_LOG[DRTIO_LOG_I] = (true, linkno, packet.clone()); + DRTIO_LOG_I = (DRTIO_LOG_I + 1) % 2048; + } packet.write_to(&mut writer)?; // Pad till offset 4, insert checksum there @@ -140,3 +152,23 @@ pub fn send(linkno: u8, packet: &Packet) -> Result<(), Error> { Ok(writer.position()) }) } + + +pub fn log_readout() { + unsafe { + DRTIO_LOG_I = 0; + for i in 0..DRTIO_LOG_N { + let (send, linkno, packet) = &DRTIO_LOG[i]; + if *linkno == 255 { + break; + } + if *send { + info!("<-{}- {:?}", *linkno, packet); + } else { + info!("-{}-> {:?}", *linkno, packet); + } + DRTIO_LOG[i] = (false, 255, Packet::EchoRequest); + } + + } +} \ No newline at end of file diff --git a/src/libboard_artiq/src/drtioaux_proto.rs b/src/libboard_artiq/src/drtioaux_proto.rs index acea1d7..e14c9b0 100644 --- a/src/libboard_artiq/src/drtioaux_proto.rs +++ b/src/libboard_artiq/src/drtioaux_proto.rs @@ -61,7 +61,7 @@ impl PayloadStatus { } } -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Debug, Clone)] pub enum Packet { EchoRequest, EchoReply, diff --git a/src/libboard_artiq/src/lib.rs b/src/libboard_artiq/src/lib.rs index 70c4cb6..b326a5a 100644 --- a/src/libboard_artiq/src/lib.rs +++ b/src/libboard_artiq/src/lib.rs @@ -2,6 +2,7 @@ #![feature(never_type)] #![feature(naked_functions)] #![feature(asm)] +#![feature(const_in_array_repeat_expressions)] extern crate core_io; extern crate crc; diff --git a/src/satman/src/main.rs b/src/satman/src/main.rs index 6db698c..2b075ba 100644 --- a/src/satman/src/main.rs +++ b/src/satman/src/main.rs @@ -1408,6 +1408,7 @@ pub extern "C" fn main_core0() -> i32 { si5324::siphaser::select_recovered_clock(&mut i2c, false, &mut timer).expect("failed to switch clocks"); #[cfg(has_wrpll)] si549::wrpll::select_recovered_clock(false, &mut timer); + drtioaux::log_readout(); } }