mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-02 02:51:42 +00:00
[hal] Add RobotController.getSerialNumber() (#4783)
This commit is contained in:
@@ -18,6 +18,9 @@
|
||||
#include <FRC_NetworkCommunication/LoadOut.h>
|
||||
#include <FRC_NetworkCommunication/UsageReporting.h>
|
||||
#include <fmt/format.h>
|
||||
#include <wpi/MemoryBuffer.h>
|
||||
#include <wpi/StringExtras.h>
|
||||
#include <wpi/fs.h>
|
||||
#include <wpi/mutex.h>
|
||||
#include <wpi/timestamp.h>
|
||||
|
||||
@@ -270,6 +273,20 @@ int64_t HAL_GetFPGARevision(int32_t* status) {
|
||||
return global->readRevision(status);
|
||||
}
|
||||
|
||||
size_t HAL_GetSerialNumber(char* buffer, size_t size) {
|
||||
const char* serialNum = std::getenv("serialnum");
|
||||
if (serialNum) {
|
||||
std::strncpy(buffer, serialNum, size);
|
||||
buffer[size - 1] = '\0';
|
||||
return std::strlen(buffer);
|
||||
} else {
|
||||
if (size > 0) {
|
||||
buffer[0] = '\0';
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t HAL_GetFPGATime(int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
if (!global) {
|
||||
|
||||
@@ -29,6 +29,19 @@ DEFINE_CAPI(int32_t, UserFaults5V, 0)
|
||||
DEFINE_CAPI(int32_t, UserFaults3V3, 0)
|
||||
DEFINE_CAPI(double, BrownoutVoltage, 6.75)
|
||||
|
||||
int32_t HALSIM_RegisterRoboRioSerialNumberCallback(
|
||||
HAL_RoboRioStringCallback callback, void* param, HAL_Bool initialNotify) {
|
||||
return 0;
|
||||
}
|
||||
void HALSIM_CancelRoboRioSerialNumberCallback(int32_t uid) {}
|
||||
size_t HALSIM_GetRoboRioSerialNumber(char* buffer, size_t size) {
|
||||
if (size > 0) {
|
||||
buffer[0] = '\0';
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
void HALSIM_SetRoboRioSerialNumber(const char* buffer, size_t size) {}
|
||||
|
||||
void HALSIM_RegisterRoboRioAllCallbacks(HAL_NotifyCallback callback,
|
||||
void* param, HAL_Bool initialNotify) {}
|
||||
} // extern "C"
|
||||
|
||||
Reference in New Issue
Block a user