Skip to content
Merged
25 changes: 19 additions & 6 deletions cmd/manifest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ fn manifestcmd(context: &mut ExecutionContext) -> Result<()> {
}
}

const REFDES_HDR: &str = "REFDES";
const NO_REFDES: &str = "-";
let refdes_len = manifest
.fmt_meta
.max_refdes_len
.max(NO_REFDES.len())
.max(REFDES_HDR.len());

if !manifest.i2c_devices.is_empty() {
println!(
"{:>12} => {} device{}",
Expand All @@ -170,8 +178,8 @@ fn manifestcmd(context: &mut ExecutionContext) -> Result<()> {
);

println!(
"{:>19} {:2} {:2} {} {} {:13} {}",
"ID", "C", "P", "MUX", "ADDR", "DEVICE", "DESCRIPTION"
"{:>19} {:2} {:2} {} {} {:refdes_len$} {:13} {}",
"ID", "C", "P", "MUX", "ADDR", REFDES_HDR, "DEVICE", "DESCRIPTION"
);

for (ndx, device) in manifest.i2c_devices.iter().enumerate() {
Expand All @@ -182,12 +190,13 @@ fn manifestcmd(context: &mut ExecutionContext) -> Result<()> {
};

println!(
"{:>19} {:2} {:2} {:3} 0x{:02x} {:13} {}",
"{:>19} {:2} {:2} {:3} 0x{:02x} {:refdes_len$} {:13} {}",
ndx,
device.controller,
device.port.name,
mux,
device.address,
device.refdes.as_deref().unwrap_or(NO_REFDES),
device.device,
device.description
);
Expand Down Expand Up @@ -220,16 +229,20 @@ fn manifestcmd(context: &mut ExecutionContext) -> Result<()> {
manifest.sensors.len(),
if manifest.sensors.len() > 1 { "s" } else { "" }
);
println!("{:>19} {:23} {:11} {}", "ID", "NAME", "DEVICE", "KIND");
println!(
"{:>19} {:23} {:11} {:refdes_len$} {}",
"ID", "NAME", "DEVICE", REFDES_HDR, "KIND"
);

for (ndx, s) in manifest.sensors.iter().enumerate() {
let device = match &s.device {
HubrisSensorDevice::I2c(ndx) => format!("i2c id={}", ndx),
HubrisSensorDevice::Other(dev, _) => dev.to_string(),
};
let refdes = s.refdes.as_deref().unwrap_or(NO_REFDES);
println!(
" {:3} {:23} {:11} {}",
ndx, s.name, device, s.kind,
" {:3} {:23} {:11} {:refdes_len$} {}",
ndx, s.name, device, refdes, s.kind,
);
}
}
Expand Down
29 changes: 23 additions & 6 deletions cmd/validate/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,19 @@ struct ValidateArgs {
id: Option<usize>,
}

const REFDES_HDR: &str = "REFDES";
const NO_REFDES: &str = "-";

fn list(hubris: &HubrisArchive, hargs: &Option<I2cArgs>) -> Result<()> {
let refdes_len = hubris
.manifest
.fmt_meta
.max_refdes_len
.max(REFDES_HDR.len())
.max(NO_REFDES.len());
println!(
"{:2} {:>2} {:2} {:3} {:4} {:13} DESCRIPTION",
"ID", "C", "P", "MUX", "ADDR", "DEVICE"
"{:2} {:refdes_len$} {:>2} {:2} {:3} {:4} {:13} DESCRIPTION",
"ID", REFDES_HDR, "C", "P", "MUX", "ADDR", "DEVICE"
);

for (ndx, device) in hubris.manifest.i2c_devices.iter().enumerate() {
Expand All @@ -118,8 +127,9 @@ fn list(hubris: &HubrisArchive, hargs: &Option<I2cArgs>) -> Result<()> {
};

println!(
"{:2} {:2} {:2} {:3} 0x{:02x} {:13} {}",
"{:2} {:refdes_len$} {:2} {:2} {:3} 0x{:02x} {:13} {}",
ndx,
device.refdes.as_deref().unwrap_or(NO_REFDES),
device.controller,
device.port.name,
mux,
Expand All @@ -135,6 +145,12 @@ fn validate(context: &mut ExecutionContext) -> Result<()> {
let subargs = ValidateArgs::try_parse_from(&context.cli.cmd)?;
let hubris = &context.cli.archive()?;
let core = &mut *context.cli.attach_live_booted(hubris)?;
let refdes_len = hubris
.manifest
.fmt_meta
.max_refdes_len
.max(REFDES_HDR.len())
.max(NO_REFDES.len());

let hargs = if subargs.bus.is_some() || subargs.controller.is_some() {
Some(I2cArgs::parse(
Expand Down Expand Up @@ -196,8 +212,8 @@ fn validate(context: &mut ExecutionContext) -> Result<()> {
};

println!(
"{:2} {:11} {:>2} {:2} {:3} {:4} {:13} DESCRIPTION",
"ID", "VALIDATION", "C", "P", "MUX", "ADDR", "DEVICE"
"{:2} {:refdes_len$} {:11} {:>2} {:2} {:3} {:4} {:13} DESCRIPTION",
"ID", REFDES_HDR, "VALIDATION", "C", "P", "MUX", "ADDR", "DEVICE"
);

let ok = hubris.lookup_enum(op.ok)?;
Expand Down Expand Up @@ -258,8 +274,9 @@ fn validate(context: &mut ExecutionContext) -> Result<()> {
};

println!(
"{:2} {:11} {:2} {:2} {:3} 0x{:02x} {:13} {}",
"{:2} {:refdes_len$} {:11} {:2} {:2} {:3} 0x{:02x} {:13} {}",
ndx,
device.refdes.as_deref().unwrap_or(NO_REFDES),
result,
device.controller,
device.port.name,
Expand Down
Loading
Loading