diff --git a/artiq/firmware/runtime/main.rs b/artiq/firmware/runtime/main.rs index 95916a8dc..bb18e7dbf 100644 --- a/artiq/firmware/runtime/main.rs +++ b/artiq/firmware/runtime/main.rs @@ -153,13 +153,25 @@ fn startup_ethernet() { let mut net_device = unsafe { ethmac::EthernetDevice::new() }; net_device.reset_phy_if_any(); - // fn _net_trace_writer(timestamp: u64, printer: smoltcp::wire::PrettyPrinter) - // where U: smoltcp::wire::pretty_print::PrettyPrint { - // let seconds = timestamp / 1000; - // let micros = timestamp % 1000 * 1000; - // print!("\x1b[37m[{:6}.{:06}s]\n{}\x1b[0m\n", seconds, micros, printer) - // } - // let net_device = smoltcp::phy::EthernetTracer::new(net_device, _net_trace_writer); + let net_device = { + use smoltcp::wire::PrettyPrinter; + use smoltcp::wire::EthernetFrame; + + fn net_trace_writer(timestamp: u64, printer: PrettyPrinter>) { + let seconds = timestamp / 1000; + let micros = timestamp % 1000 * 1000; + print!("\x1b[37m[{:6}.{:06}s]\n{}\x1b[0m\n", seconds, micros, printer) + } + + fn net_trace_silent(_timestamp: u64, _printer: PrettyPrinter>) {} + + let net_trace_fn: fn(u64, PrettyPrinter>); + match config::read_str("net_trace", |r| r.map(|s| s == "1")) { + Ok(true) => net_trace_fn = net_trace_writer, + _ => net_trace_fn = net_trace_silent + } + smoltcp::phy::EthernetTracer::new(net_device, net_trace_fn) + }; let mut neighbor_map = [None; 8]; let neighbor_cache =