NOTE: TGL (hx20) does not have this host command
(ec: &CrosEc)
| 1027 | |
| 1028 | // NOTE: TGL (hx20) does not have this host command |
| 1029 | pub 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 | |
| 1061 | pub fn standalone_mode(ec: &CrosEc) -> bool { |
| 1062 | // TODO: Figure out how to get that information |
no test coverage detected