Skip to content

Commit

Permalink
Board version command
Browse files Browse the repository at this point in the history
  • Loading branch information
ChocolateLoverRaj committed May 16, 2024
1 parent 75e4fa4 commit beb69e6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions crosec/src/commands/board_version.rs
Original file line number Diff line number Diff line change
@@ -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<u32> {
let mut result = ec_command(CrosEcCmd::GetBoardVersion, 0, Default::default(), EcInterface::Dev(String::from("/dev/cros_ec")))?;
result.resize(size_of::<u32>(), Default::default());
Ok(u32::from_le_bytes(result.try_into().unwrap()))
}
2 changes: 2 additions & 0 deletions crosec/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
5 changes: 5 additions & 0 deletions ectool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> = env::args().collect();
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit beb69e6

Please sign in to comment.