Skip to content

Commit 96a7608

Browse files
Merge pull request #53 from FrameworkComputer/prettier-test
Prettier --test command
2 parents 6fd13f2 + c3f4b7c commit 96a7608

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

framework_lib/src/ccgx/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ pub struct PdVersions {
230230
}
231231

232232
/// Same as PdVersions but only the main FW
233+
#[derive(Debug)]
233234
pub struct MainPdVersions {
234235
pub controller01: ControllerVersion,
235236
pub controller23: ControllerVersion,

framework_lib/src/commandline/mod.rs

+22-7
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use crate::chromium_ec;
3535
use crate::chromium_ec::commands::DeckStateMode;
3636
use crate::chromium_ec::commands::FpLedBrightnessLevel;
3737
use crate::chromium_ec::commands::RebootEcCmd;
38+
use crate::chromium_ec::EcResponseStatus;
3839
use crate::chromium_ec::{print_err, EcFlashType};
3940
use crate::chromium_ec::{EcError, EcResult};
4041
#[cfg(feature = "linux")]
@@ -1049,14 +1050,16 @@ fn selftest(ec: &CrosEc) -> Option<()> {
10491050
println!(" Reading EC Build Version");
10501051
print_err(ec.version_info())?;
10511052

1052-
println!(" Reading EC Flash by EC");
1053+
print!(" Reading EC Flash by EC");
10531054
ec.flash_version()?;
1055+
println!(" - OK");
10541056

1055-
println!(" Reading EC Flash directly");
1057+
println!(" Reading EC Flash directly - See below");
10561058
ec.test_ec_flash_read().ok()?;
10571059

1058-
println!(" Getting power info from EC");
1060+
print!(" Getting power info from EC");
10591061
power::power_info(ec)?;
1062+
println!(" - OK");
10601063

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

1068-
// Try to get PD versions through EC
1069-
power::read_pd_version(ec).ok()?;
1071+
print!("Reading PD Version from EC");
1072+
if let Err(err) = power::read_pd_version(ec) {
1073+
// TGL does not have this command, so we have to ignore it
1074+
if err != EcError::Response(EcResponseStatus::InvalidCommand) {
1075+
println!();
1076+
println!("Err: {:?}", err);
1077+
} else {
1078+
println!(" - Skipped");
1079+
}
1080+
} else {
1081+
println!(" - OK");
1082+
}
10701083

10711084
let pd_01 = PdController::new(PdPort::Left01, ec.clone());
10721085
let pd_23 = PdController::new(PdPort::Right23, ec.clone());
1073-
println!(" Getting PD01 info");
1086+
print!(" Getting PD01 info through I2C tunnel");
10741087
print_err(pd_01.get_silicon_id())?;
10751088
print_err(pd_01.get_device_info())?;
10761089
print_err(pd_01.get_fw_versions())?;
1077-
println!(" Getting PD23 info");
1090+
println!(" - OK");
1091+
print!(" Getting PD23 info through I2C tunnel");
10781092
print_err(pd_23.get_silicon_id())?;
10791093
print_err(pd_23.get_device_info())?;
10801094
print_err(pd_23.get_fw_versions())?;
1095+
println!(" - OK");
10811096

10821097
Some(())
10831098
}

framework_lib/src/power.rs

+1
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ pub fn print_memmap_version_info(ec: &CrosEc) {
191191
let _events_ver = ec.read_memory(EC_MEMMAP_EVENTS_VERSION, 2).unwrap();
192192
}
193193

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

0 commit comments

Comments
 (0)