[hal] Fix sim not working with automatic PD type and default module (#3707)

This commit is contained in:
Thad House
2021-11-05 23:30:10 -07:00
committed by GitHub
parent e473a00f97
commit 7699a1f827

View File

@@ -30,6 +30,19 @@ extern "C" {
HAL_PowerDistributionHandle HAL_InitializePowerDistribution(
int32_t module, HAL_PowerDistributionType type,
const char* allocationLocation, int32_t* status) {
if (type == HAL_PowerDistributionType_kAutomatic) {
if (module != HAL_DEFAULT_POWER_DISTRIBUTION_MODULE) {
*status = PARAMETER_OUT_OF_RANGE;
hal::SetLastError(
status, "Automatic PowerDistributionType must have default module");
return HAL_kInvalidHandle;
}
// TODO Make this not matter
type = HAL_PowerDistributionType_kCTRE;
module = 0;
}
if (!HAL_CheckPowerDistributionModule(module, type)) {
*status = PARAMETER_OUT_OF_RANGE;
hal::SetLastError(status, fmt::format("Invalid pdp module {}", module));