forked from M-Labs/artiq
firmware: make network tracing runtime switchable.
This commit is contained in:
parent
2adba3ed33
commit
fe50018037
@ -153,13 +153,25 @@ fn startup_ethernet() {
|
|||||||
let mut net_device = unsafe { ethmac::EthernetDevice::new() };
|
let mut net_device = unsafe { ethmac::EthernetDevice::new() };
|
||||||
net_device.reset_phy_if_any();
|
net_device.reset_phy_if_any();
|
||||||
|
|
||||||
// fn _net_trace_writer<U>(timestamp: u64, printer: smoltcp::wire::PrettyPrinter<U>)
|
let net_device = {
|
||||||
// where U: smoltcp::wire::pretty_print::PrettyPrint {
|
use smoltcp::wire::PrettyPrinter;
|
||||||
// let seconds = timestamp / 1000;
|
use smoltcp::wire::EthernetFrame;
|
||||||
// let micros = timestamp % 1000 * 1000;
|
|
||||||
// print!("\x1b[37m[{:6}.{:06}s]\n{}\x1b[0m\n", seconds, micros, printer)
|
fn net_trace_writer(timestamp: u64, printer: PrettyPrinter<EthernetFrame<&[u8]>>) {
|
||||||
// }
|
let seconds = timestamp / 1000;
|
||||||
// let net_device = smoltcp::phy::EthernetTracer::new(net_device, _net_trace_writer);
|
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<EthernetFrame<&[u8]>>) {}
|
||||||
|
|
||||||
|
let net_trace_fn: fn(u64, PrettyPrinter<EthernetFrame<&[u8]>>);
|
||||||
|
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 mut neighbor_map = [None; 8];
|
||||||
let neighbor_cache =
|
let neighbor_cache =
|
||||||
|
Loading…
Reference in New Issue
Block a user