[hal] Rename HAL_kInvalidHandle to HAL_INVALID_HANDLE (#8698)

This commit is contained in:
Peter Johnson
2026-03-21 00:34:46 -07:00
committed by GitHub
parent 4e4ad9c498
commit b7122f0fda
72 changed files with 160 additions and 160 deletions

View File

@@ -30,7 +30,7 @@ HAL_AddressableLEDHandle HAL_InitializeAddressableLED(
wpi::hal::SetLastErrorIndexOutOfRange(status,
"Invalid Index for AddressableLED", 0,
kNumAddressableLEDs, channel);
return HAL_kInvalidHandle;
return HAL_INVALID_HANDLE;
}
HAL_DigitalHandle handle;
@@ -47,7 +47,7 @@ HAL_AddressableLEDHandle HAL_InitializeAddressableLED(
"Invalid Index for AddressableLED",
0, kNumAddressableLEDs, channel);
}
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
return HAL_INVALID_HANDLE; // failed to allocate. Pass error back.
}
port->channel = static_cast<uint8_t>(channel);

View File

@@ -52,9 +52,9 @@ HAL_AlertHandle HAL_CreateAlert(const WPI_String* group, const WPI_String* text,
std::shared_ptr<Alert> alert = std::make_shared<Alert>(
wpi::util::to_string_view(group), wpi::util::to_string_view(text), level);
HAL_AlertHandle handle = alertHandles->Allocate(alert);
if (handle == HAL_kInvalidHandle) {
if (handle == HAL_INVALID_HANDLE) {
*status = HAL_HANDLE_ERROR;
return HAL_kInvalidHandle;
return HAL_INVALID_HANDLE;
}
return handle;
}

View File

@@ -24,7 +24,7 @@ HAL_AnalogInputHandle HAL_InitializeAnalogInputPort(
*status = RESOURCE_OUT_OF_RANGE;
wpi::hal::SetLastErrorIndexOutOfRange(
status, "Invalid Index for Analog Input", 0, kNumAnalogInputs, channel);
return HAL_kInvalidHandle;
return HAL_INVALID_HANDLE;
}
HAL_AnalogInputHandle handle;
@@ -39,7 +39,7 @@ HAL_AnalogInputHandle HAL_InitializeAnalogInputPort(
"Invalid Index for Analog Input", 0,
kNumAnalogInputs, channel);
}
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
return HAL_INVALID_HANDLE; // failed to allocate. Pass error back.
}
analog_port->channel = static_cast<uint8_t>(channel);

View File

@@ -72,16 +72,16 @@ HAL_CANHandle HAL_InitializeCAN(int32_t busId, HAL_CANManufacturer manufacturer,
if (busId < 0 || busId > wpi::hal::kNumCanBuses) {
*status = PARAMETER_OUT_OF_RANGE;
return HAL_kInvalidHandle;
return HAL_INVALID_HANDLE;
}
auto can = std::make_shared<CANStorage>();
auto handle = canHandles->Allocate(can);
if (handle == HAL_kInvalidHandle) {
if (handle == HAL_INVALID_HANDLE) {
*status = NO_AVAILABLE_RESOURCES;
return HAL_kInvalidHandle;
return HAL_INVALID_HANDLE;
}
can->busId = busId;

View File

@@ -52,7 +52,7 @@ HAL_CTREPCMHandle HAL_InitializeCTREPCM(int32_t busId, int32_t module,
"Invalid Index for CTRE PCM", 0,
kNumCTREPCMModules - 1, module);
}
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
return HAL_INVALID_HANDLE; // failed to allocate. Pass error back.
}
pcm->previousAllocation = allocationLocation ? allocationLocation : "";

View File

@@ -40,7 +40,7 @@ HAL_DigitalHandle HAL_InitializeDIOPort(int32_t channel, HAL_Bool input,
*status = RESOURCE_OUT_OF_RANGE;
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for DIO", 0,
kNumDigitalChannels, channel);
return HAL_kInvalidHandle;
return HAL_INVALID_HANDLE;
}
HAL_DigitalHandle handle;
@@ -56,7 +56,7 @@ HAL_DigitalHandle HAL_InitializeDIOPort(int32_t channel, HAL_Bool input,
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for DIO", 0,
kNumDigitalChannels, channel);
}
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
return HAL_INVALID_HANDLE; // failed to allocate. Pass error back.
}
port->channel = static_cast<uint8_t>(channel);
@@ -94,15 +94,15 @@ void HAL_SetDIOSimDevice(HAL_DigitalHandle handle, HAL_SimDeviceHandle device) {
HAL_DigitalPWMHandle HAL_AllocateDigitalPWM(int32_t* status) {
auto handle = digitalPWMHandles->Allocate();
if (handle == HAL_kInvalidHandle) {
if (handle == HAL_INVALID_HANDLE) {
*status = NO_AVAILABLE_RESOURCES;
return HAL_kInvalidHandle;
return HAL_INVALID_HANDLE;
}
auto id = digitalPWMHandles->Get(handle);
if (id == nullptr) { // would only occur on thread issue.
*status = HAL_HANDLE_ERROR;
return HAL_kInvalidHandle;
return HAL_INVALID_HANDLE;
}
*id = static_cast<uint8_t>(getHandleIndex(handle));

View File

@@ -42,7 +42,7 @@ HAL_DutyCycleHandle HAL_InitializeDutyCycle(int32_t channel,
int32_t* status) {
wpi::hal::init::CheckInit();
HAL_DutyCycleHandle handle = HAL_kInvalidHandle;
HAL_DutyCycleHandle handle = HAL_INVALID_HANDLE;
auto dutyCycle = dutyCycleHandles->Allocate(channel, &handle, status);
if (*status != 0) {
@@ -53,7 +53,7 @@ HAL_DutyCycleHandle HAL_InitializeDutyCycle(int32_t channel,
wpi::hal::SetLastErrorIndexOutOfRange(
status, "Invalid Index for Duty Cycle", 0, kNumDutyCycles, channel);
}
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
return HAL_INVALID_HANDLE; // failed to allocate. Pass error back.
}
int16_t index = getHandleIndex(handle);

View File

@@ -71,7 +71,7 @@ HAL_EncoderHandle HAL_InitializeEncoder(int32_t aChannel, int32_t bChannel,
HAL_EncoderEncodingType encodingType,
int32_t* status) {
wpi::hal::init::CheckInit();
HAL_Handle nativeHandle = HAL_kInvalidHandle;
HAL_Handle nativeHandle = HAL_INVALID_HANDLE;
if (encodingType == HAL_EncoderEncodingType::HAL_ENCODER_4X_ENCODING) {
// k4x, allocate encoder
nativeHandle = fpgaEncoderHandles->Allocate();
@@ -79,19 +79,19 @@ HAL_EncoderHandle HAL_InitializeEncoder(int32_t aChannel, int32_t bChannel,
// k2x or k1x, allocate counter
nativeHandle = counterHandles->Allocate();
}
if (nativeHandle == HAL_kInvalidHandle) {
if (nativeHandle == HAL_INVALID_HANDLE) {
*status = NO_AVAILABLE_RESOURCES;
return HAL_kInvalidHandle;
return HAL_INVALID_HANDLE;
}
auto handle = encoderHandles->Allocate();
if (handle == HAL_kInvalidHandle) {
if (handle == HAL_INVALID_HANDLE) {
*status = NO_AVAILABLE_RESOURCES;
return HAL_kInvalidHandle;
return HAL_INVALID_HANDLE;
}
auto encoder = encoderHandles->Get(handle);
if (encoder == nullptr) { // would only occur on thread issue
*status = HAL_HANDLE_ERROR;
return HAL_kInvalidHandle;
return HAL_INVALID_HANDLE;
}
int16_t index = getHandleIndex(handle);
SimEncoderData[index].digitalChannelA = aChannel;
@@ -106,9 +106,9 @@ HAL_EncoderHandle HAL_InitializeEncoder(int32_t aChannel, int32_t bChannel,
encoder->distancePerPulse = 1.0;
if (encodingType == HAL_EncoderEncodingType::HAL_ENCODER_4X_ENCODING) {
encoder->fpgaHandle = nativeHandle;
encoder->counterHandle = HAL_kInvalidHandle;
encoder->counterHandle = HAL_INVALID_HANDLE;
} else {
encoder->fpgaHandle = HAL_kInvalidHandle;
encoder->fpgaHandle = HAL_INVALID_HANDLE;
encoder->counterHandle = nativeHandle;
}
return handle;

View File

@@ -216,9 +216,9 @@ HAL_NotifierHandle HAL_CreateNotifier(int32_t* status) {
std::shared_ptr<Notifier> notifier = std::make_shared<Notifier>();
HAL_NotifierHandle handle =
notifierInstance->owner.GetThread()->m_handles.Allocate(notifier);
if (handle == HAL_kInvalidHandle) {
if (handle == HAL_INVALID_HANDLE) {
*status = HAL_HANDLE_ERROR;
return HAL_kInvalidHandle;
return HAL_INVALID_HANDLE;
}
wpi::util::CreateSignalObject(handle);
return handle;

View File

@@ -30,7 +30,7 @@ HAL_DigitalHandle HAL_InitializePWMPort(int32_t channel,
*status = RESOURCE_OUT_OF_RANGE;
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for PWM", 0,
kNumPWMChannels, channel);
return HAL_kInvalidHandle;
return HAL_INVALID_HANDLE;
}
uint8_t origChannel = static_cast<uint8_t>(channel);
@@ -54,7 +54,7 @@ HAL_DigitalHandle HAL_InitializePWMPort(int32_t channel,
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for PWM", 0,
kNumPWMChannels, channel);
}
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
return HAL_INVALID_HANDLE; // failed to allocate. Pass error back.
}
port->channel = origChannel;

View File

@@ -35,7 +35,7 @@ HAL_PowerDistributionHandle HAL_InitializePowerDistribution(
*status = PARAMETER_OUT_OF_RANGE;
wpi::hal::SetLastError(
status, "Automatic PowerDistributionType must have default module");
return HAL_kInvalidHandle;
return HAL_INVALID_HANDLE;
}
// TODO Make this not matter
@@ -53,7 +53,7 @@ HAL_PowerDistributionHandle HAL_InitializePowerDistribution(
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for REV PDH",
1, kNumREVPDHModules, module);
}
return HAL_kInvalidHandle;
return HAL_INVALID_HANDLE;
}
wpi::hal::init::CheckInit();
SimPowerDistributionData[module].initialized = true;
@@ -62,7 +62,7 @@ HAL_PowerDistributionHandle HAL_InitializePowerDistribution(
if (*status != 0) {
HAL_CleanCAN(handle);
return HAL_kInvalidHandle;
return HAL_INVALID_HANDLE;
}
return handle;

View File

@@ -44,7 +44,7 @@ HAL_REVPHHandle HAL_InitializeREVPH(int32_t busId, int32_t module,
*status = RESOURCE_OUT_OF_RANGE;
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for REV PH", 1,
kNumREVPHModules, module);
return HAL_kInvalidHandle;
return HAL_INVALID_HANDLE;
}
HAL_REVPHHandle handle;
@@ -59,7 +59,7 @@ HAL_REVPHHandle HAL_InitializeREVPH(int32_t busId, int32_t module,
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for REV PH",
1, kNumREVPHModules, module);
}
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
return HAL_INVALID_HANDLE; // failed to allocate. Pass error back.
}
pcm->previousAllocation = allocationLocation ? allocationLocation : "";

View File

@@ -14,14 +14,14 @@ extern "C" {
HAL_SerialPortHandle HAL_InitializeSerialPort(HAL_SerialPort port,
int32_t* status) {
wpi::hal::init::CheckInit();
return HAL_kInvalidHandle;
return HAL_INVALID_HANDLE;
}
HAL_SerialPortHandle HAL_InitializeSerialPortDirect(HAL_SerialPort port,
const char* portName,
int32_t* status) {
wpi::hal::init::CheckInit();
return HAL_kInvalidHandle;
return HAL_INVALID_HANDLE;
}
int HAL_GetSerialFD(HAL_SerialPortHandle handle, int32_t* status) {