#[non_exhaustive]pub enum Cap {
CleanFrame,
CommandProtocol,
Ddr3,
Adio,
Grounding,
TtlIn,
SlotHealth,
FieldUpdate,
RateControl,
}Expand description
A capability bit. Branch on these, NEVER on a version comparison.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
CleanFrame
this build emits the format-2 self-describing frame on the declared stream endpoints
Gates: streams samples, digital; registers quiesce, run_samples, run_digital,
lanes_samples, burst_samples, burst_digital, stream_status_samples,
stream_status_digital.
CommandProtocol
the typed request/response command channel is live (firmware-dependent: it is baked into the same .bit)
Gates: commands sys.hello, power.status, power.up, adio.mode, adio.adc, adio.fb,
adio.dout, gnd.eeprom.read, sys.claim, sys.release, sys.challenge, sys.unlock,
id.boards.
Ddr3
the DDR3 pipe buffer is present and calibrated; without it a stream’s depth is the on-chip FIFO only
Adio
ADIO analog/digital module I/O is present
Gates: commands adio.mode, adio.adc, adio.fb, adio.dout.
Grounding
the grounding/module-ID board is present
Gates: commands gnd.eeprom.read.
TtlIn
TTL inputs are wired to the digital stream’s lanes
SlotHealth
per-slot presence and rail health are readable
Gates: commands power.status.
FieldUpdate
gateware images can be written over the wire and selected at boot (RESERVED — no command implements this yet)
RateControl
the acquisition rate is host-configurable, and rhd_matrix emits NOTHING until it has been
configured (#131). A device with this capability expects rate_md + rate_apply before
acquisition and reports readiness on rate_ready; without it a host cannot know whether the
cadence a frame declares is one the hardware was placed into.
Gates: registers rate_md, rate_apply, rate_ready.
Implementations§
Source§impl Cap
impl Cap
Sourcepub const fn token(self) -> &'static str
pub const fn token(self) -> &'static str
The contract token, 1:1 with contract.yaml.
Examples found in repository?
7fn main() -> std::process::ExitCode {
8 let mut args = std::env::args().skip(1);
9 let serial = args.next().unwrap_or_default();
10 let driver_dir = args.next();
11
12 let opened = kdi::Device::open_usb3(&serial, driver_dir.as_deref().map(std::path::Path::new));
13
14 let mut dev = match opened {
15 Ok(d) => d,
16 Err(e) => {
17 // Naming the failure matters more than the exit code: "no board" and "the driver is
18 // present but a symbol did not resolve" are the two outcomes worth telling apart, and
19 // every entry point resolves by name at dlopen so the second one says which symbol.
20 eprintln!("could not open the board: {e}");
21 return std::process::ExitCode::FAILURE;
22 }
23 };
24
25 let (major, minor) = dev.kdi();
26 let caps = dev.caps();
27 println!("serial {}", dev.info().serial);
28 println!("transport {:?}", dev.info().transport);
29 println!("contract {major}.{minor}");
30 println!("caps 0x{:08x}", caps.0);
31 for c in caps.iter() {
32 println!(" {}", c.token());
33 }
34 println!("gateware_sha {:08x}", dev.gateware_sha());
35 if caps.has(kdi::Cap::CommandProtocol) {
36 match dev.sys_hello() {
37 Ok(h) => println!("fw_sha {}", h.fw),
38 Err(e) => {
39 eprintln!("sys.hello failed: {e}");
40 return std::process::ExitCode::FAILURE;
41 }
42 }
43 } else {
44 println!("fw_sha -");
45 }
46
47 match dev.wait_ready(std::time::Duration::from_millis(kdi::READY_TIMEOUT_MS)) {
48 Ok(()) => println!("contract_ready yes"),
49 Err(e) => {
50 // Not fatal for a handshake read: a board still calibrating is a normal transient, and
51 // the point of this program is to report what the device says.
52 println!("contract_ready NO ({e})");
53 }
54 }
55
56 if let Err(e) = dev.close() {
57 eprintln!("close: {e}");
58 return std::process::ExitCode::FAILURE;
59 }
60 std::process::ExitCode::SUCCESS
61}Sourcepub fn from_token(s: &str) -> Option<Self>
pub fn from_token(s: &str) -> Option<Self>
Parse a token. None is a token this build does not know — from a device on
a newer minor, which is legal and must never be a parse failure.