MCPcopy Index your code
hub / github.com/FrameworkComputer/framework-system / read_pd_version

Function read_pd_version

framework_lib/src/power.rs:1029–1059  ·  view source on GitHub ↗

NOTE: TGL (hx20) does not have this host command

(ec: &CrosEc)

Source from the content-addressed store, hash-verified

1027
1028// NOTE: TGL (hx20) does not have this host command
1029pub fn read_pd_version(ec: &CrosEc) -> EcResult<MainPdVersions> {
1030 let info = EcRequestReadPdVersionV1 {}.send_command_vec(ec);
1031
1032 // If v1 not available, fall back
1033 if let Err(EcError::Response(EcResponseStatus::InvalidVersion)) = info {
1034 let info = EcRequestReadPdVersionV0 {}.send_command(ec)?;
1035
1036 return Ok(if info.controller23 == [0, 0, 0, 0, 0, 0, 0, 0] {
1037 MainPdVersions::Single(parse_pd_ver(&info.controller01))
1038 } else {
1039 MainPdVersions::RightLeft((
1040 parse_pd_ver(&info.controller01),
1041 parse_pd_ver(&info.controller23),
1042 ))
1043 });
1044 }
1045 // If any other error, exit
1046 let info = info?;
1047
1048 let mut versions = vec![];
1049 let pd_count = info[0] as usize;
1050 for i in 0..pd_count {
1051 // TODO: Is there a safer way to check the range?
1052 if info.len() < 1 + 8 * (i + 1) {
1053 return Err(EcError::DeviceError("Not enough data returned".to_string()));
1054 }
1055 versions.push(parse_pd_ver_slice(&info[1 + 8 * i..1 + 8 * (i + 1)]));
1056 }
1057
1058 Ok(MainPdVersions::Many(versions))
1059}
1060
1061pub fn standalone_mode(ec: &CrosEc) -> bool {
1062 // TODO: Figure out how to get that information

Callers 2

print_versionsFunction · 0.85
selftestFunction · 0.85

Calls 4

parse_pd_verFunction · 0.85
parse_pd_ver_sliceFunction · 0.85
send_command_vecMethod · 0.80
send_commandMethod · 0.45

Tested by

no test coverage detected