use std::collections::BTreeMap;
use whatcable::cable::CableInfo;
use whatcable::typec::{TypeCCable, TypeCIdentity};
fn main() {
let args: Vec<u32> = std::env::args()
.skip(1)
.map(|s| {
let s = s
.strip_prefix("0x")
.or_else(|| s.strip_prefix("0X"))
.unwrap_or(&s)
.to_string();
u32::from_str_radix(&s, 16).expect("hex u32")
})
.collect();
if args.is_empty() {
eprintln!("usage: cable_info <id_header> [cert_stat] [product] [product_type_vdo1]");
std::process::exit(2);
}
let cable = TypeCCable {
r#type: "passive".into(),
plug_type: "type-c".into(),
identity: Some(TypeCIdentity {
vendor_id: (args[0] & 0xFFFF) as u16,
product_id: 0,
vdos: args.clone(),
}),
raw_attributes: BTreeMap::new(),
};
let info = CableInfo::from_typec_cable(&cable);
println!(
"Vendor : {} (0x{:04x})",
info.vendor_name, info.vendor_id
);
println!("Type : {}", info.cable_type);
println!("Active : {}", info.is_active);
println!("Speed : {:?}", info.speed);
println!("Current : {:?}", info.current_rating);
println!("Max watts : {}W", info.max_watts);
}