[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:
Thad House
2021-09-13 22:05:38 -07:00
committed by GitHub
parent 95a12e0ee8
commit 66abb39880
11 changed files with 96 additions and 5 deletions

View File

@@ -25,6 +25,13 @@
#include "frc/livewindow/LiveWindow.h"
#include "frc/smartdashboard/SmartDashboard.h"
static_assert(frc::RuntimeType::kRoboRIO ==
static_cast<frc::RuntimeType>(HAL_Runtime_RoboRIO));
static_assert(frc::RuntimeType::kRoboRIO2 ==
static_cast<frc::RuntimeType>(HAL_Runtime_RoboRIO2));
static_assert(frc::RuntimeType::kSimulation ==
static_cast<frc::RuntimeType>(HAL_Runtime_Simulation));
using SetCameraServerSharedFP = void (*)(frc::CameraServerShared*);
using namespace frc;
@@ -213,6 +220,10 @@ std::thread::id RobotBase::GetThreadId() {
return m_threadId;
}
RuntimeType RobotBase::GetRuntimeType() {
return static_cast<RuntimeType>(HAL_GetRuntimeType());
}
RobotBase::RobotBase() {
m_threadId = std::this_thread::get_id();