mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11:43 +00:00
SCRIPT: wpiformat
This commit is contained in:
committed by
Peter Johnson
parent
ae6bdc9d25
commit
2109161534
@@ -28,8 +28,9 @@ HAL_AddressableLEDHandle HAL_InitializeAddressableLED(
|
||||
|
||||
if (channel < 0 || channel >= kNumAddressableLEDs) {
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for AddressableLED",
|
||||
0, kNumAddressableLEDs, channel);
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status,
|
||||
"Invalid Index for AddressableLED", 0,
|
||||
kNumAddressableLEDs, channel);
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
@@ -41,11 +42,11 @@ HAL_AddressableLEDHandle HAL_InitializeAddressableLED(
|
||||
if (*status != 0) {
|
||||
if (port) {
|
||||
wpi::hal::SetLastErrorPreviouslyAllocated(status, "PWM or DIO", channel,
|
||||
port->previousAllocation);
|
||||
port->previousAllocation);
|
||||
} else {
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status,
|
||||
"Invalid Index for AddressableLED", 0,
|
||||
kNumAddressableLEDs, channel);
|
||||
"Invalid Index for AddressableLED",
|
||||
0, kNumAddressableLEDs, channel);
|
||||
}
|
||||
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ HAL_AnalogInputHandle HAL_InitializeAnalogInputPort(
|
||||
wpi::hal::init::CheckInit();
|
||||
if (channel < 0 || channel >= kNumAnalogInputs) {
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Analog Input",
|
||||
0, kNumAnalogInputs, channel);
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(
|
||||
status, "Invalid Index for Analog Input", 0, kNumAnalogInputs, channel);
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
@@ -33,11 +33,12 @@ HAL_AnalogInputHandle HAL_InitializeAnalogInputPort(
|
||||
|
||||
if (*status != 0) {
|
||||
if (analog_port) {
|
||||
wpi::hal::SetLastErrorPreviouslyAllocated(status, "Analog Input", channel,
|
||||
analog_port->previousAllocation);
|
||||
wpi::hal::SetLastErrorPreviouslyAllocated(
|
||||
status, "Analog Input", channel, analog_port->previousAllocation);
|
||||
} else {
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Analog Input",
|
||||
0, kNumAnalogInputs, channel);
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status,
|
||||
"Invalid Index for Analog Input", 0,
|
||||
kNumAnalogInputs, channel);
|
||||
}
|
||||
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
|
||||
}
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
#include "wpi/hal/handles/IndexedHandleResource.h"
|
||||
|
||||
namespace wpi::hal {
|
||||
IndexedHandleResource<HAL_AnalogInputHandle, wpi::hal::AnalogPort, kNumAnalogInputs,
|
||||
HAL_HandleEnum::AnalogInput>* analogInputHandles;
|
||||
IndexedHandleResource<HAL_AnalogInputHandle, wpi::hal::AnalogPort,
|
||||
kNumAnalogInputs, HAL_HandleEnum::AnalogInput>*
|
||||
analogInputHandles;
|
||||
} // namespace wpi::hal
|
||||
|
||||
namespace wpi::hal::init {
|
||||
|
||||
@@ -46,10 +46,11 @@ HAL_CTREPCMHandle HAL_InitializeCTREPCM(int32_t busId, int32_t module,
|
||||
if (*status != 0) {
|
||||
if (pcm) {
|
||||
wpi::hal::SetLastErrorPreviouslyAllocated(status, "CTRE PCM", module,
|
||||
pcm->previousAllocation);
|
||||
pcm->previousAllocation);
|
||||
} else {
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for CTRE PCM", 0,
|
||||
kNumCTREPCMModules - 1, module);
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status,
|
||||
"Invalid Index for CTRE PCM", 0,
|
||||
kNumCTREPCMModules - 1, module);
|
||||
}
|
||||
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ HAL_DigitalHandle HAL_InitializeDIOPort(int32_t channel, HAL_Bool input,
|
||||
if (channel < 0 || channel >= kNumDigitalChannels) {
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for DIO", 0,
|
||||
kNumDigitalChannels, channel);
|
||||
kNumDigitalChannels, channel);
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
@@ -51,10 +51,10 @@ HAL_DigitalHandle HAL_InitializeDIOPort(int32_t channel, HAL_Bool input,
|
||||
if (*status != 0) {
|
||||
if (port) {
|
||||
wpi::hal::SetLastErrorPreviouslyAllocated(status, "PWM or DIO", channel,
|
||||
port->previousAllocation);
|
||||
port->previousAllocation);
|
||||
} else {
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for DIO", 0,
|
||||
kNumDigitalChannels, channel);
|
||||
kNumDigitalChannels, channel);
|
||||
}
|
||||
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
|
||||
}
|
||||
|
||||
@@ -48,10 +48,10 @@ HAL_DutyCycleHandle HAL_InitializeDutyCycle(int32_t channel,
|
||||
if (*status != 0) {
|
||||
if (dutyCycle) {
|
||||
wpi::hal::SetLastErrorPreviouslyAllocated(status, "SmartIo", channel,
|
||||
dutyCycle->previousAllocation);
|
||||
dutyCycle->previousAllocation);
|
||||
} else {
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Duty Cycle",
|
||||
0, kNumDutyCycles, channel);
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(
|
||||
status, "Invalid Index for Duty Cycle", 0, kNumDutyCycles, channel);
|
||||
}
|
||||
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ extern "C" {
|
||||
int HAL_LoadOneExtension(const char* library) {
|
||||
int rc = 1; // It is expected and reasonable not to find an extra simulation
|
||||
wpi::util::print("HAL Extensions: Attempting to load: {}\n",
|
||||
fs::path{library}.stem().string());
|
||||
fs::path{library}.stem().string());
|
||||
std::fflush(stdout);
|
||||
HTYPE handle = DLOPEN(library);
|
||||
#if !defined(WIN32) && !defined(_WIN32)
|
||||
@@ -67,8 +67,9 @@ int HAL_LoadOneExtension(const char* library) {
|
||||
#else
|
||||
auto libraryName = fmt::format("lib{}.so", library);
|
||||
#endif
|
||||
wpi::util::print("HAL Extensions: Load failed: {}\nTrying modified name: {}\n",
|
||||
DLERROR, fs::path{libraryName}.stem().string());
|
||||
wpi::util::print(
|
||||
"HAL Extensions: Load failed: {}\nTrying modified name: {}\n", DLERROR,
|
||||
fs::path{libraryName}.stem().string());
|
||||
std::fflush(stdout);
|
||||
handle = DLOPEN(libraryName.c_str());
|
||||
}
|
||||
|
||||
@@ -319,8 +319,8 @@ int32_t HALSIM_GetNotifierInfo(struct HALSIM_NotifierInfo* arr, int32_t size) {
|
||||
arr[num].handle = handle;
|
||||
if (notifier->name.empty()) {
|
||||
wpi::util::format_to_n_c_str(arr[num].name, sizeof(arr[num].name),
|
||||
"Notifier{}",
|
||||
static_cast<int>(getHandleIndex(handle)));
|
||||
"Notifier{}",
|
||||
static_cast<int>(getHandleIndex(handle)));
|
||||
} else {
|
||||
std::strncpy(arr[num].name, notifier->name.c_str(),
|
||||
sizeof(arr[num].name) - 1);
|
||||
|
||||
@@ -31,7 +31,7 @@ HAL_DigitalHandle HAL_InitializePWMPort(int32_t channel,
|
||||
if (channel < 0 || channel >= kNumPWMChannels) {
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for PWM", 0,
|
||||
kNumPWMChannels, channel);
|
||||
kNumPWMChannels, channel);
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
@@ -51,10 +51,10 @@ HAL_DigitalHandle HAL_InitializePWMPort(int32_t channel,
|
||||
if (*status != 0) {
|
||||
if (port) {
|
||||
wpi::hal::SetLastErrorPreviouslyAllocated(status, "PWM or DIO", channel,
|
||||
port->previousAllocation);
|
||||
port->previousAllocation);
|
||||
} else {
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for PWM", 0,
|
||||
kNumPWMChannels, channel);
|
||||
kNumPWMChannels, channel);
|
||||
}
|
||||
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
|
||||
}
|
||||
|
||||
@@ -46,11 +46,12 @@ HAL_PowerDistributionHandle HAL_InitializePowerDistribution(
|
||||
if (!HAL_CheckPowerDistributionModule(module, type)) {
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
if (type == HAL_PowerDistributionType::HAL_PowerDistributionType_kCTRE) {
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for CTRE PDP", 0,
|
||||
kNumCTREPDPModules - 1, module);
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status,
|
||||
"Invalid Index for CTRE PDP", 0,
|
||||
kNumCTREPDPModules - 1, module);
|
||||
} else {
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for REV PDH", 1,
|
||||
kNumREVPDHModules, module);
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for REV PDH",
|
||||
1, kNumREVPDHModules, module);
|
||||
}
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ HAL_REVPHHandle HAL_InitializeREVPH(int32_t busId, int32_t module,
|
||||
if (!HAL_CheckREVPHModuleNumber(module)) {
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for REV PH", 1,
|
||||
kNumREVPHModules, module);
|
||||
kNumREVPHModules, module);
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
@@ -54,10 +54,10 @@ HAL_REVPHHandle HAL_InitializeREVPH(int32_t busId, int32_t module,
|
||||
if (*status != 0) {
|
||||
if (pcm) {
|
||||
wpi::hal::SetLastErrorPreviouslyAllocated(status, "REV PH", module,
|
||||
pcm->previousAllocation);
|
||||
pcm->previousAllocation);
|
||||
} else {
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for REV PH", 1,
|
||||
kNumREVPHModules, module);
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for REV PH",
|
||||
1, kNumREVPHModules, module);
|
||||
}
|
||||
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
|
||||
}
|
||||
|
||||
@@ -532,7 +532,8 @@ void HALSIM_SetJoystickName(int32_t stick, const WPI_String* name) {
|
||||
}
|
||||
|
||||
void HALSIM_SetGameSpecificMessage(const WPI_String* message) {
|
||||
SimDriverStationData->SetGameSpecificMessage(wpi::util::to_string_view(message));
|
||||
SimDriverStationData->SetGameSpecificMessage(
|
||||
wpi::util::to_string_view(message));
|
||||
}
|
||||
|
||||
void HALSIM_SetEventName(const WPI_String* name) {
|
||||
|
||||
@@ -29,7 +29,8 @@ class SimUnnamedCallbackRegistry {
|
||||
using RawFunctor = void (*)();
|
||||
|
||||
protected:
|
||||
using CallbackVector = wpi::util::UidVector<HalCallbackListener<RawFunctor>, 4>;
|
||||
using CallbackVector =
|
||||
wpi::util::UidVector<HalCallbackListener<RawFunctor>, 4>;
|
||||
|
||||
public:
|
||||
void Cancel(int32_t uid) {
|
||||
|
||||
Reference in New Issue
Block a user