diff --git a/crosec/src/commands/board_version.rs b/crosec/src/commands/board_version.rs new file mode 100644 index 0000000..022f1d0 --- /dev/null +++ b/crosec/src/commands/board_version.rs @@ -0,0 +1,9 @@ +use std::mem::size_of; +use crate::{ec_command, EcCmdResult, EcInterface}; +use crate::commands::CrosEcCmd; + +pub fn ec_cmd_board_version() -> EcCmdResult { + let mut result = ec_command(CrosEcCmd::GetBoardVersion, 0, Default::default(), EcInterface::Dev(String::from("/dev/cros_ec")))?; + result.resize(size_of::(), Default::default()); + Ok(u32::from_le_bytes(result.try_into().unwrap())) +} diff --git a/crosec/src/commands/mod.rs b/crosec/src/commands/mod.rs index b9c4cc2..7ed7455 100644 --- a/crosec/src/commands/mod.rs +++ b/crosec/src/commands/mod.rs @@ -4,8 +4,10 @@ pub enum CrosEcCmd { Version = 0x0002, GetBuildInfo = 0x0004, GetChipInfo = 0x0005, + GetBoardVersion = 0x0006 } pub mod get_chip_info; pub mod hello; pub mod version; +pub mod board_version; diff --git a/ectool/src/main.rs b/ectool/src/main.rs index b0362c3..9ce6b21 100644 --- a/ectool/src/main.rs +++ b/ectool/src/main.rs @@ -3,6 +3,7 @@ use seahorse::{App, Command}; use crosec::commands::{ get_chip_info::ec_cmd_get_chip_info, hello::ec_cmd_hello, version::ec_cmd_version, }; +use crosec::commands::board_version::ec_cmd_board_version; fn main() { let args: Vec = env::args().collect(); @@ -30,6 +31,10 @@ fn main() { println!(" vendor: {vendor}"); println!(" name: {name}"); println!(" revision: {revision}"); + })) + .command(Command::new("boardversion").action(|_c| { + let board_version = ec_cmd_board_version().unwrap(); + println!("Board version: {board_version}"); })); app.run(args);