Commit cc2347f5 authored by Trent Begin's avatar Trent Begin Committed by Commit Bot

DeviceStatusCollector: add ProbeError to FanInfo request

Update cros_healthd telemetry handling code to check for and log errors
from FanInfo request.

Bug: chromium:1041153
Change-Id: I929f0dcb0dba53a8c8db7e41782bfab91a675ac9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2147799
Commit-Queue: Trent Begin <tbegin@chromium.org>
Reviewed-by: default avatarJorge Lucangeli Obes <jorgelo@chromium.org>
Reviewed-by: default avatarMaksim Ivanov <emaxx@chromium.org>
Reviewed-by: default avatarPaul Moy <pmoy@chromium.org>
Reviewed-by: default avatarJesse Schettler <jschettler@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758906}
parent 47c09afb
...@@ -929,12 +929,20 @@ class DeviceStatusCollectorState : public StatusCollectorState { ...@@ -929,12 +929,20 @@ class DeviceStatusCollectorState : public StatusCollectorState {
backlight_info_out->set_brightness(backlight->brightness); backlight_info_out->set_brightness(backlight->brightness);
} }
} }
const auto& fan_info = probe_result->fan_info;
if (fan_info.has_value()) { // Process FanResult.
for (const auto& fan : fan_info.value()) { const auto& fan_result = probe_result->fan_result;
em::FanInfo* const fan_info_out = if (!fan_result.is_null()) {
response_params_.device_status->add_fan_info(); if (fan_result->is_error()) {
fan_info_out->set_speed_rpm(fan->speed_rpm); LOG(ERROR) << "cros_healthd: Error getting fan info: "
<< fan_result->get_error()->msg;
} else {
const auto& fan_info = fan_result->get_fan_info();
for (const auto& fan : fan_info) {
em::FanInfo* const fan_info_out =
response_params_.device_status->add_fan_info();
fan_info_out->set_speed_rpm(fan->speed_rpm);
}
} }
} }
......
...@@ -493,11 +493,13 @@ void GetFakeCrosHealthdData( ...@@ -493,11 +493,13 @@ void GetFakeCrosHealthdData(
std::vector<chromeos::cros_healthd::mojom::FanInfoPtr> fan_vector; std::vector<chromeos::cros_healthd::mojom::FanInfoPtr> fan_vector;
chromeos::cros_healthd::mojom::FanInfo fan_info(kFakeSpeedRpm); chromeos::cros_healthd::mojom::FanInfo fan_info(kFakeSpeedRpm);
fan_vector.push_back(fan_info.Clone()); fan_vector.push_back(fan_info.Clone());
auto fan_result = chromeos::cros_healthd::mojom::FanResult::NewFanInfo(
std::move(fan_vector));
chromeos::cros_healthd::mojom::TelemetryInfo fake_info( chromeos::cros_healthd::mojom::TelemetryInfo fake_info(
battery_info.Clone(), std::move(block_device_info), battery_info.Clone(), std::move(block_device_info),
cached_vpd_info.Clone(), std::move(cpu_result), cached_vpd_info.Clone(), std::move(cpu_result),
std::move(timezone_result), memory_info.Clone(), std::move(timezone_result), memory_info.Clone(),
std::move(backlight_vector), std::move(fan_vector)); std::move(backlight_vector), std::move(fan_result));
// Create fake SampledData. // Create fake SampledData.
em::CPUTempInfo fake_cpu_temp_sample; em::CPUTempInfo fake_cpu_temp_sample;
......
...@@ -138,11 +138,11 @@ base::Optional<std::vector<mojom::BacklightInfoPtr>> MakeBacklightInfo() { ...@@ -138,11 +138,11 @@ base::Optional<std::vector<mojom::BacklightInfoPtr>> MakeBacklightInfo() {
return backlight_info; return backlight_info;
} }
base::Optional<std::vector<mojom::FanInfoPtr>> MakeFanInfo() { mojom::FanResultPtr MakeFanResult() {
std::vector<mojom::FanInfoPtr> fan_info; std::vector<mojom::FanInfoPtr> fan_vector;
fan_info.push_back(mojom::FanInfo::New(1200 /* speed_rpm */)); fan_vector.push_back(mojom::FanInfo::New(1200 /* speed_rpm */));
fan_info.push_back(mojom::FanInfo::New(2650 /* speed_rpm */)); fan_vector.push_back(mojom::FanInfo::New(2650 /* speed_rpm */));
return fan_info; return mojom::FanResult::NewFanInfo(std::move(fan_vector));
} }
mojom::TelemetryInfoPtr MakeTelemetryInfo() { mojom::TelemetryInfoPtr MakeTelemetryInfo() {
...@@ -152,7 +152,7 @@ mojom::TelemetryInfoPtr MakeTelemetryInfo() { ...@@ -152,7 +152,7 @@ mojom::TelemetryInfoPtr MakeTelemetryInfo() {
MakeCachedVpdInfo() /* vpd_info */, MakeCpuResult() /* cpu_result */, MakeCachedVpdInfo() /* vpd_info */, MakeCpuResult() /* cpu_result */,
MakeTimezoneResult() /* timezone_result */, MakeTimezoneResult() /* timezone_result */,
MakeMemoryInfo() /* memory_info */, MakeMemoryInfo() /* memory_info */,
MakeBacklightInfo() /* backlight_info */, MakeFanInfo() /* fan_info */ MakeBacklightInfo() /* backlight_info */, MakeFanResult() /* fan_result */
); );
} }
......
...@@ -38,6 +38,8 @@ enum ErrorType { ...@@ -38,6 +38,8 @@ enum ErrorType {
kFileReadError, kFileReadError,
// An error parsing data into a consumable form. // An error parsing data into a consumable form.
kParseError, kParseError,
// An error using a system utility.
kSystemUtilityError,
}; };
// Structure that contains error information for a telemetry probe. // Structure that contains error information for a telemetry probe.
...@@ -171,6 +173,15 @@ struct BacklightInfo { ...@@ -171,6 +173,15 @@ struct BacklightInfo {
uint32 brightness; uint32 brightness;
}; };
// Fan probe result. Can either be populated with the FanInfo or an error
// retrieving the information
union FanResult {
// A list of valid FanInfo.
array<FanInfo> fan_info;
// The error that occurred attempting to retrieve the FanInfo.
ProbeError error;
};
// Fan information. // Fan information.
struct FanInfo { struct FanInfo {
// Fan speed in RPM. // Fan speed in RPM.
...@@ -209,5 +220,5 @@ struct TelemetryInfo { ...@@ -209,5 +220,5 @@ struct TelemetryInfo {
array<BacklightInfo>? backlight_info; array<BacklightInfo>? backlight_info;
// Information about each of the device's fans. Only present when kFan was // Information about each of the device's fans. Only present when kFan was
// included in the categories input to ProbeTelemetryInfo. // included in the categories input to ProbeTelemetryInfo.
array<FanInfo>? fan_info; FanResult? fan_result;
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment