Skip to content

Commit

Permalink
Merge pull request #53 from FrameworkComputer/prettier-test
Browse files Browse the repository at this point in the history
Prettier --test command
  • Loading branch information
JohnAZoidberg authored Oct 21, 2024
2 parents 6fd13f2 + c3f4b7c commit 96a7608
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
1 change: 1 addition & 0 deletions framework_lib/src/ccgx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ pub struct PdVersions {
}

/// Same as PdVersions but only the main FW
#[derive(Debug)]
pub struct MainPdVersions {
pub controller01: ControllerVersion,
pub controller23: ControllerVersion,
Expand Down
29 changes: 22 additions & 7 deletions framework_lib/src/commandline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use crate::chromium_ec;
use crate::chromium_ec::commands::DeckStateMode;
use crate::chromium_ec::commands::FpLedBrightnessLevel;
use crate::chromium_ec::commands::RebootEcCmd;
use crate::chromium_ec::EcResponseStatus;
use crate::chromium_ec::{print_err, EcFlashType};
use crate::chromium_ec::{EcError, EcResult};
#[cfg(feature = "linux")]
Expand Down Expand Up @@ -1049,14 +1050,16 @@ fn selftest(ec: &CrosEc) -> Option<()> {
println!(" Reading EC Build Version");
print_err(ec.version_info())?;

println!(" Reading EC Flash by EC");
print!(" Reading EC Flash by EC");
ec.flash_version()?;
println!(" - OK");

println!(" Reading EC Flash directly");
println!(" Reading EC Flash directly - See below");
ec.test_ec_flash_read().ok()?;

println!(" Getting power info from EC");
print!(" Getting power info from EC");
power::power_info(ec)?;
println!(" - OK");

println!(" Getting AC info from EC");
// All our laptops have at least 4 PD ports so far
Expand All @@ -1065,19 +1068,31 @@ fn selftest(ec: &CrosEc) -> Option<()> {
return None;
}

// Try to get PD versions through EC
power::read_pd_version(ec).ok()?;
print!("Reading PD Version from EC");
if let Err(err) = power::read_pd_version(ec) {
// TGL does not have this command, so we have to ignore it
if err != EcError::Response(EcResponseStatus::InvalidCommand) {
println!();
println!("Err: {:?}", err);
} else {
println!(" - Skipped");
}
} else {
println!(" - OK");
}

let pd_01 = PdController::new(PdPort::Left01, ec.clone());
let pd_23 = PdController::new(PdPort::Right23, ec.clone());
println!(" Getting PD01 info");
print!(" Getting PD01 info through I2C tunnel");
print_err(pd_01.get_silicon_id())?;
print_err(pd_01.get_device_info())?;
print_err(pd_01.get_fw_versions())?;
println!(" Getting PD23 info");
println!(" - OK");
print!(" Getting PD23 info through I2C tunnel");
print_err(pd_23.get_silicon_id())?;
print_err(pd_23.get_device_info())?;
print_err(pd_23.get_fw_versions())?;
println!(" - OK");

Some(())
}
Expand Down
1 change: 1 addition & 0 deletions framework_lib/src/power.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ pub fn print_memmap_version_info(ec: &CrosEc) {
let _events_ver = ec.read_memory(EC_MEMMAP_EVENTS_VERSION, 2).unwrap();
}

/// Not supported on TGL EC
pub fn get_als_reading(ec: &CrosEc) -> Option<u32> {
let als = ec.read_memory(EC_MEMMAP_ALS, 0x04)?;
Some(u32::from_le_bytes([als[0], als[1], als[2], als[3]]))
Expand Down

0 comments on commit 96a7608

Please sign in to comment.