mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
[hal] Add RobotController.getSerialNumber() (#4783)
This commit is contained in:
@@ -4,6 +4,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
|
||||
#include <wpi/spinlock.h>
|
||||
|
||||
#include "hal/simulation/RoboRioData.h"
|
||||
#include "hal/simulation/SimDataValue.h"
|
||||
|
||||
@@ -26,6 +31,8 @@ class RoboRioData {
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(UserFaults3V3)
|
||||
HAL_SIMDATAVALUE_DEFINE_NAME(BrownoutVoltage)
|
||||
|
||||
HAL_SIMCALLBACKREGISTRY_DEFINE_NAME(SerialNumber)
|
||||
|
||||
public:
|
||||
SimDataValue<HAL_Bool, HAL_MakeBoolean, GetFPGAButtonName> fpgaButton{false};
|
||||
SimDataValue<double, HAL_MakeDouble, GetVInVoltageName> vInVoltage{12.0};
|
||||
@@ -50,7 +57,20 @@ class RoboRioData {
|
||||
SimDataValue<double, HAL_MakeDouble, GetBrownoutVoltageName> brownoutVoltage{
|
||||
6.75};
|
||||
|
||||
int32_t RegisterSerialNumberCallback(HAL_RoboRioStringCallback callback,
|
||||
void* param, HAL_Bool initialNotify);
|
||||
void CancelSerialNumberCallback(int32_t uid);
|
||||
size_t GetSerialNumber(char* buffer, size_t size);
|
||||
void SetSerialNumber(const char* serialNumber, size_t size);
|
||||
|
||||
virtual void ResetData();
|
||||
|
||||
private:
|
||||
wpi::spinlock m_serialNumberMutex;
|
||||
std::string m_serialNumber;
|
||||
|
||||
SimCallbackRegistry<HAL_RoboRioStringCallback, GetSerialNumberName>
|
||||
m_serialNumberCallbacks;
|
||||
};
|
||||
extern RoboRioData* SimRoboRioData;
|
||||
} // namespace hal
|
||||
|
||||
Reference in New Issue
Block a user