forked from M-Labs/artiq-zynq
satman: log drtio packets, display on connection break
This commit is contained in:
parent
2c633409b8
commit
5969e34e7a
@ -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<Option<Packet>, 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<usize, Error> {
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -61,7 +61,7 @@ impl PayloadStatus {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Debug)]
|
||||
#[derive(PartialEq, Debug, Clone)]
|
||||
pub enum Packet {
|
||||
EchoRequest,
|
||||
EchoReply,
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user