mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-03 03:01:44 +00:00
[hal] Update runtime enum to allow selecting roborio 2 (#3565)
In some cases, knowing roborio 2 might be useful. This also creates a higher level enum that might be usable later for the discussion on more complex runtime types.
This commit is contained in:
@@ -232,7 +232,11 @@ const char* HAL_GetErrorMessage(int32_t code) {
|
||||
}
|
||||
|
||||
HAL_RuntimeType HAL_GetRuntimeType(void) {
|
||||
return HAL_Athena;
|
||||
nLoadOut::tTargetClass targetClass = nLoadOut::getTargetClass();
|
||||
if (targetClass == nLoadOut::kTargetClass_RoboRIO2) {
|
||||
return HAL_Runtime_RoboRIO2;
|
||||
}
|
||||
return HAL_Runtime_RoboRIO;
|
||||
}
|
||||
|
||||
int32_t HAL_GetFPGAVersion(int32_t* status) {
|
||||
|
||||
@@ -30,6 +30,12 @@ using namespace wpi::java;
|
||||
#define kRIOStatusFeatureNotSupported (kRioStatusOffset - 193)
|
||||
#define kRIOStatusResourceNotInitialized -52010
|
||||
|
||||
static_assert(edu_wpi_first_hal_HALUtil_RUNTIME_ROBORIO == HAL_Runtime_RoboRIO);
|
||||
static_assert(edu_wpi_first_hal_HALUtil_RUNTIME_ROBORIO2 ==
|
||||
HAL_Runtime_RoboRIO2);
|
||||
static_assert(edu_wpi_first_hal_HALUtil_RUNTIME_SIMULATION ==
|
||||
HAL_Runtime_Simulation);
|
||||
|
||||
static JavaVM* jvm = nullptr;
|
||||
static JException illegalArgExCls;
|
||||
static JException boundaryExCls;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
// clang-format off
|
||||
HAL_ENUM(HAL_RuntimeType) { HAL_Athena, HAL_Mock };
|
||||
HAL_ENUM(HAL_RuntimeType) { HAL_Runtime_RoboRIO, HAL_Runtime_RoboRIO2, HAL_Runtime_Simulation };
|
||||
// clang-format on
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -64,6 +64,11 @@ int32_t HAL_GetFPGAVersion(int32_t* status);
|
||||
*/
|
||||
int64_t HAL_GetFPGARevision(int32_t* status);
|
||||
|
||||
/**
|
||||
* Returns the runtime type of the HAL.
|
||||
*
|
||||
* @return HAL Runtime Type
|
||||
*/
|
||||
HAL_RuntimeType HAL_GetRuntimeType(void);
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,7 +51,7 @@ class SimPeriodicCallbackRegistry : public impl::SimCallbackRegistryBase {
|
||||
};
|
||||
} // namespace
|
||||
|
||||
static HAL_RuntimeType runtimeType{HAL_Mock};
|
||||
static HAL_RuntimeType runtimeType{HAL_Runtime_Simulation};
|
||||
static wpi::spinlock gOnShutdownMutex;
|
||||
static std::vector<std::pair<void*, void (*)(void*)>> gOnShutdown;
|
||||
static SimPeriodicCallbackRegistry gSimPeriodicBefore;
|
||||
|
||||
Reference in New Issue
Block a user