mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +00:00
SCRIPT namespace replacements
This commit is contained in:
committed by
Peter Johnson
parent
ae6c043632
commit
9aca8e0fd6
@@ -25,7 +25,7 @@
|
||||
#include "wpi/nt/NetworkTableInstance.hpp"
|
||||
#include "wpi/nt/RawTopic.hpp"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
#define IO_PREFIX "/io/"
|
||||
|
||||
@@ -34,11 +34,11 @@ namespace {
|
||||
constexpr const char* kLedsKey = IO_PREFIX "leds";
|
||||
|
||||
struct AddressableLEDs {
|
||||
explicit AddressableLEDs(nt::NetworkTableInstance inst)
|
||||
explicit AddressableLEDs(wpi::nt::NetworkTableInstance inst)
|
||||
: rawPub{inst.GetRawTopic(kLedsKey).Publish(
|
||||
"raw", {.periodic = 0.005, .sendAll = true})} {}
|
||||
|
||||
nt::RawPublisher rawPub;
|
||||
wpi::nt::RawPublisher rawPub;
|
||||
uint8_t s_buffer[HAL_kAddressableLEDMaxLength * 3];
|
||||
};
|
||||
|
||||
@@ -46,7 +46,7 @@ static AddressableLEDs* leds;
|
||||
|
||||
void ConvertAndCopyLEDData(void* dst, const struct HAL_AddressableLEDData* src,
|
||||
int32_t len, HAL_AddressableLEDColorOrder order) {
|
||||
using namespace hal::detail;
|
||||
using namespace wpi::hal::detail;
|
||||
switch (order) {
|
||||
case HAL_ALED_RGB:
|
||||
std::memcpy(dst, src, len * sizeof(HAL_AddressableLEDData));
|
||||
@@ -75,22 +75,22 @@ void ConvertAndCopyLEDData(void* dst, const struct HAL_AddressableLEDData* src,
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeAddressableLED() {
|
||||
static AddressableLEDs leds_static{hal::GetSystemServer()};
|
||||
static AddressableLEDs leds_static{wpi::hal::GetSystemServer()};
|
||||
leds = &leds_static;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
extern "C" {
|
||||
|
||||
HAL_AddressableLEDHandle HAL_InitializeAddressableLED(
|
||||
int32_t channel, const char* allocationLocation, int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
|
||||
if (channel < 0 || channel >= kNumSmartIo) {
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for AddressableLED",
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for AddressableLED",
|
||||
0, kNumSmartIo, channel);
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
@@ -102,10 +102,10 @@ HAL_AddressableLEDHandle HAL_InitializeAddressableLED(
|
||||
|
||||
if (*status != 0) {
|
||||
if (port) {
|
||||
hal::SetLastErrorPreviouslyAllocated(status, "SmartIo", channel,
|
||||
wpi::hal::SetLastErrorPreviouslyAllocated(status, "SmartIo", channel,
|
||||
port->previousAllocation);
|
||||
} else {
|
||||
hal::SetLastErrorIndexOutOfRange(
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(
|
||||
status, "Invalid Index for AddressableLED", 0, kNumSmartIo, channel);
|
||||
}
|
||||
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
|
||||
@@ -133,9 +133,9 @@ void HAL_FreeAddressableLED(HAL_AddressableLEDHandle handle) {
|
||||
smartIoHandles->Free(handle, HAL_HandleEnum::AddressableLED);
|
||||
|
||||
// Wait for no other object to hold this handle.
|
||||
auto start = hal::fpga_clock::now();
|
||||
auto start = wpi::hal::fpga_clock::now();
|
||||
while (port.use_count() != 1) {
|
||||
auto current = hal::fpga_clock::now();
|
||||
auto current = wpi::hal::fpga_clock::now();
|
||||
if (start + std::chrono::seconds(1) < current) {
|
||||
std::puts("AddressableLED handle free timeout");
|
||||
std::fflush(stdout);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "simd/simd.h"
|
||||
#include "wpi/hal/AddressableLEDTypes.h"
|
||||
|
||||
namespace hal::detail {
|
||||
namespace wpi::hal::detail {
|
||||
|
||||
constexpr size_t kPixelSize = 3;
|
||||
static_assert(sizeof(HAL_AddressableLEDData) == kPixelSize);
|
||||
@@ -221,4 +221,4 @@ void ConvertPixels(const uint8_t* src, uint8_t* dst, size_t len) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace hal::detail
|
||||
} // namespace wpi::hal::detail
|
||||
|
||||
@@ -16,21 +16,21 @@
|
||||
#include "wpi/hal/handles/HandlesInternal.h"
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeAnalogInput() {}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
HAL_AnalogInputHandle HAL_InitializeAnalogInputPort(
|
||||
int32_t channel, const char* allocationLocation, int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
|
||||
if (channel < 0 || channel >= kNumSmartIo) {
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Analog", 0,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Analog", 0,
|
||||
kNumSmartIo, channel);
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
@@ -42,10 +42,10 @@ HAL_AnalogInputHandle HAL_InitializeAnalogInputPort(
|
||||
|
||||
if (*status != 0) {
|
||||
if (port) {
|
||||
hal::SetLastErrorPreviouslyAllocated(status, "SmartIo", channel,
|
||||
wpi::hal::SetLastErrorPreviouslyAllocated(status, "SmartIo", channel,
|
||||
port->previousAllocation);
|
||||
} else {
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Analog", 0,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Analog", 0,
|
||||
kNumSmartIo, channel);
|
||||
}
|
||||
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
|
||||
@@ -74,9 +74,9 @@ void HAL_FreeAnalogInputPort(HAL_AnalogInputHandle analogPortHandle) {
|
||||
smartIoHandles->Free(analogPortHandle, HAL_HandleEnum::AnalogInput);
|
||||
|
||||
// Wait for no other object to hold this handle.
|
||||
auto start = hal::fpga_clock::now();
|
||||
auto start = wpi::hal::fpga_clock::now();
|
||||
while (port.use_count() != 1) {
|
||||
auto current = hal::fpga_clock::now();
|
||||
auto current = wpi::hal::fpga_clock::now();
|
||||
if (start + std::chrono::seconds(1) < current) {
|
||||
std::puts("DIO handle free timeout");
|
||||
std::fflush(stdout);
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "wpi/util/print.hpp"
|
||||
#include "wpi/util/timestamp.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -72,7 +72,7 @@ struct CANStreamStorage {
|
||||
canMask{mask},
|
||||
canFilter{filter} {}
|
||||
|
||||
wpi::circular_buffer<struct HAL_CANStreamMessage> receivedMessages;
|
||||
wpi::util::circular_buffer<struct HAL_CANStreamMessage> receivedMessages;
|
||||
bool didOverflow{false};
|
||||
uint32_t allowedMessages;
|
||||
uint8_t canBusId;
|
||||
@@ -83,31 +83,31 @@ struct CANStreamStorage {
|
||||
};
|
||||
|
||||
struct SocketCanState {
|
||||
wpi::EventLoopRunner readLoopRunner;
|
||||
wpi::EventLoopRunner writeLoopRunner;
|
||||
wpi::mutex writeMutex[hal::kNumCanBuses];
|
||||
int socketHandle[hal::kNumCanBuses];
|
||||
wpi::net::EventLoopRunner readLoopRunner;
|
||||
wpi::net::EventLoopRunner writeLoopRunner;
|
||||
wpi::util::mutex writeMutex[wpi::hal::kNumCanBuses];
|
||||
int socketHandle[wpi::hal::kNumCanBuses];
|
||||
// ms to count/timer map
|
||||
wpi::DenseMap<uint16_t, std::pair<size_t, std::weak_ptr<wpi::uv::Timer>>>
|
||||
wpi::util::DenseMap<uint16_t, std::pair<size_t, std::weak_ptr<wpi::net::uv::Timer>>>
|
||||
timers;
|
||||
// ms to bus mask/packet
|
||||
wpi::DenseMap<uint16_t,
|
||||
std::array<std::optional<canfd_frame>, hal::kNumCanBuses>>
|
||||
wpi::util::DenseMap<uint16_t,
|
||||
std::array<std::optional<canfd_frame>, wpi::hal::kNumCanBuses>>
|
||||
timedFrames;
|
||||
// packet to time
|
||||
wpi::DenseMap<uint32_t, std::array<uint16_t, hal::kNumCanBuses>> packetToTime;
|
||||
wpi::util::DenseMap<uint32_t, std::array<uint16_t, wpi::hal::kNumCanBuses>> packetToTime;
|
||||
|
||||
wpi::mutex readMutex[hal::kNumCanBuses];
|
||||
wpi::util::mutex readMutex[wpi::hal::kNumCanBuses];
|
||||
// TODO(thadhouse) we need a MUCH better way of doing this masking
|
||||
wpi::DenseMap<uint32_t, HAL_CANStreamMessage> readFrames[hal::kNumCanBuses];
|
||||
std::vector<CANStreamStorage*> canStreams[hal::kNumCanBuses];
|
||||
wpi::util::DenseMap<uint32_t, HAL_CANStreamMessage> readFrames[wpi::hal::kNumCanBuses];
|
||||
std::vector<CANStreamStorage*> canStreams[wpi::hal::kNumCanBuses];
|
||||
|
||||
bool InitializeBuses();
|
||||
|
||||
void TimerCallback(uint16_t time);
|
||||
|
||||
void RemovePeriodic(uint8_t busMask, uint32_t messageId);
|
||||
void AddPeriodic(wpi::uv::Loop& loop, uint8_t busMask, uint16_t time,
|
||||
void AddPeriodic(wpi::net::uv::Loop& loop, uint8_t busMask, uint16_t time,
|
||||
const canfd_frame& frame);
|
||||
};
|
||||
|
||||
@@ -118,7 +118,7 @@ static UnlimitedHandleResource<HAL_CANStreamHandle, CANStreamStorage,
|
||||
|
||||
static SocketCanState* canState;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeCAN() {
|
||||
canState = new SocketCanState{};
|
||||
static UnlimitedHandleResource<HAL_CANStreamHandle, CANStreamStorage,
|
||||
@@ -126,7 +126,7 @@ void InitializeCAN() {
|
||||
cSH;
|
||||
canStreamHandles = &cSH;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
void CANStreamStorage::CheckFrame(const HAL_CANStreamMessage& message) {
|
||||
if ((message.messageId & canMask) != canFilter) {
|
||||
@@ -145,18 +145,18 @@ void CANStreamStorage::CheckFrame(const HAL_CANStreamMessage& message) {
|
||||
|
||||
bool SocketCanState::InitializeBuses() {
|
||||
bool success = true;
|
||||
readLoopRunner.ExecSync([this, &success](wpi::uv::Loop& loop) {
|
||||
readLoopRunner.ExecSync([this, &success](wpi::net::uv::Loop& loop) {
|
||||
int32_t status = 0;
|
||||
HAL_SetCurrentThreadPriority(true, 50, &status);
|
||||
if (status != 0) {
|
||||
wpi::print("Failed to set CAN thread priority\n");
|
||||
wpi::util::print("Failed to set CAN thread priority\n");
|
||||
}
|
||||
|
||||
for (int i = 0; i < hal::kNumCanBuses; i++) {
|
||||
for (int i = 0; i < wpi::hal::kNumCanBuses; i++) {
|
||||
std::scoped_lock lock{writeMutex[i]};
|
||||
socketHandle[i] = socket(PF_CAN, SOCK_RAW, CAN_RAW);
|
||||
if (socketHandle[i] == -1) {
|
||||
wpi::print("socket() for CAN {} failed with {}\n", i,
|
||||
wpi::util::print("socket() for CAN {} failed with {}\n", i,
|
||||
std::strerror(errno));
|
||||
success = false;
|
||||
return;
|
||||
@@ -166,7 +166,7 @@ bool SocketCanState::InitializeBuses() {
|
||||
std::snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "can_s%d", i);
|
||||
|
||||
if (ioctl(socketHandle[i], SIOCGIFINDEX, &ifr) == -1) {
|
||||
wpi::print("ioctl(SIOCGIFINDEX) for CAN {} failed with {}\n",
|
||||
wpi::util::print("ioctl(SIOCGIFINDEX) for CAN {} failed with {}\n",
|
||||
ifr.ifr_name, std::strerror(errno));
|
||||
success = false;
|
||||
return;
|
||||
@@ -179,14 +179,14 @@ bool SocketCanState::InitializeBuses() {
|
||||
|
||||
if (bind(socketHandle[i], reinterpret_cast<const sockaddr*>(&addr),
|
||||
sizeof(addr)) == -1) {
|
||||
wpi::print("bind() for CAN {} failed with {}\n", ifr.ifr_name,
|
||||
wpi::util::print("bind() for CAN {} failed with {}\n", ifr.ifr_name,
|
||||
std::strerror(errno));
|
||||
success = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (ioctl(socketHandle[i], SIOCGIFMTU, &ifr) == -1) {
|
||||
wpi::print("ioctl(SIOCGIFMTU) for CAN {} failed with {}\n",
|
||||
wpi::util::print("ioctl(SIOCGIFMTU) for CAN {} failed with {}\n",
|
||||
ifr.ifr_name, std::strerror(errno));
|
||||
success = false;
|
||||
return;
|
||||
@@ -196,7 +196,7 @@ bool SocketCanState::InitializeBuses() {
|
||||
int fdSet = 1;
|
||||
if (setsockopt(socketHandle[i], SOL_CAN_RAW, CAN_RAW_FD_FRAMES, &fdSet,
|
||||
sizeof(fdSet)) != 0) {
|
||||
wpi::print(
|
||||
wpi::util::print(
|
||||
"setsockopt(CAN_RAW_FD_FRAMES) for CAN {} failed with {}\n",
|
||||
ifr.ifr_name, std::strerror(errno));
|
||||
success = false;
|
||||
@@ -204,9 +204,9 @@ bool SocketCanState::InitializeBuses() {
|
||||
}
|
||||
}
|
||||
|
||||
auto poll = wpi::uv::Poll::Create(loop, socketHandle[i]);
|
||||
auto poll = wpi::net::uv::Poll::Create(loop, socketHandle[i]);
|
||||
if (!poll) {
|
||||
wpi::print("wpi::uv::Poll::Create for CAN {} failed\n", ifr.ifr_name);
|
||||
wpi::util::print("wpi::net::uv::Poll::Create for CAN {} failed\n", ifr.ifr_name);
|
||||
success = false;
|
||||
return;
|
||||
}
|
||||
@@ -226,7 +226,7 @@ bool SocketCanState::InitializeBuses() {
|
||||
}
|
||||
|
||||
uint32_t messageId = MapSocketCanToMessageId(frame.can_id);
|
||||
uint64_t timestamp = wpi::Now();
|
||||
uint64_t timestamp = wpi::util::Now();
|
||||
// Ensure FDF flag is set for the read later.
|
||||
if (rVal == CANFD_MTU) {
|
||||
frame.flags = CANFD_FDF;
|
||||
@@ -300,24 +300,24 @@ void SocketCanState::RemovePeriodic(uint8_t busId, uint32_t messageId) {
|
||||
}
|
||||
}
|
||||
|
||||
void SocketCanState::AddPeriodic(wpi::uv::Loop& loop, uint8_t busId,
|
||||
void SocketCanState::AddPeriodic(wpi::net::uv::Loop& loop, uint8_t busId,
|
||||
uint16_t time, const canfd_frame& frame) {
|
||||
packetToTime[frame.can_id][busId] = time;
|
||||
timedFrames[time][busId] = frame;
|
||||
auto& timer = timers[time];
|
||||
timer.first++;
|
||||
if (timer.first == 1) {
|
||||
auto newTimer = wpi::uv::Timer::Create(loop);
|
||||
auto newTimer = wpi::net::uv::Timer::Create(loop);
|
||||
newTimer->timeout.connect([this, time] { TimerCallback(time); });
|
||||
newTimer->Start(wpi::uv::Timer::Time{time}, wpi::uv::Timer::Time{time});
|
||||
newTimer->Start(wpi::net::uv::Timer::Time{time}, wpi::net::uv::Timer::Time{time});
|
||||
}
|
||||
}
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
bool InitializeCanBuses() {
|
||||
return canState->InitializeBuses();
|
||||
}
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
namespace {} // namespace
|
||||
|
||||
@@ -326,7 +326,7 @@ extern "C" {
|
||||
void HAL_CAN_SendMessage(int32_t busId, uint32_t messageId,
|
||||
const struct HAL_CANMessage* message, int32_t periodMs,
|
||||
int32_t* status) {
|
||||
if (busId < 0 || busId >= hal::kNumCanBuses) {
|
||||
if (busId < 0 || busId >= wpi::hal::kNumCanBuses) {
|
||||
*status = PARAMETER_OUT_OF_RANGE;
|
||||
return;
|
||||
}
|
||||
@@ -336,7 +336,7 @@ void HAL_CAN_SendMessage(int32_t busId, uint32_t messageId,
|
||||
// TODO determine on the real roborio is a non periodic send removes any
|
||||
// periodic send.
|
||||
if (periodMs == HAL_CAN_SEND_PERIOD_STOP_REPEATING) {
|
||||
canState->writeLoopRunner.ExecSync([messageId, busId](wpi::uv::Loop&) {
|
||||
canState->writeLoopRunner.ExecSync([messageId, busId](wpi::net::uv::Loop&) {
|
||||
canState->RemovePeriodic(busId, messageId);
|
||||
});
|
||||
|
||||
@@ -385,7 +385,7 @@ void HAL_CAN_SendMessage(int32_t busId, uint32_t messageId,
|
||||
|
||||
if (periodMs > 0) {
|
||||
canState->writeLoopRunner.ExecAsync(
|
||||
[busId, periodMs, frame](wpi::uv::Loop& loop) {
|
||||
[busId, periodMs, frame](wpi::net::uv::Loop& loop) {
|
||||
canState->AddPeriodic(loop, busId, periodMs, frame);
|
||||
});
|
||||
}
|
||||
@@ -393,7 +393,7 @@ void HAL_CAN_SendMessage(int32_t busId, uint32_t messageId,
|
||||
void HAL_CAN_ReceiveMessage(int32_t busId, uint32_t messageId,
|
||||
struct HAL_CANReceiveMessage* message,
|
||||
int32_t* status) {
|
||||
if (busId < 0 || busId >= hal::kNumCanBuses) {
|
||||
if (busId < 0 || busId >= wpi::hal::kNumCanBuses) {
|
||||
message->message.dataSize = 0;
|
||||
message->timeStamp = 0;
|
||||
*status = PARAMETER_OUT_OF_RANGE;
|
||||
@@ -421,7 +421,7 @@ HAL_CANStreamHandle HAL_CAN_OpenStreamSession(int32_t busId, uint32_t messageId,
|
||||
uint32_t messageIdMask,
|
||||
uint32_t maxMessages,
|
||||
int32_t* status) {
|
||||
if (busId < 0 || busId >= hal::kNumCanBuses) {
|
||||
if (busId < 0 || busId >= wpi::hal::kNumCanBuses) {
|
||||
*status = PARAMETER_OUT_OF_RANGE;
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "wpi/util/mutex.hpp"
|
||||
#include "wpi/util/timestamp.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace {
|
||||
struct CANStorage {
|
||||
@@ -24,23 +24,23 @@ struct CANStorage {
|
||||
HAL_CANDeviceType deviceType;
|
||||
int32_t busId;
|
||||
uint8_t deviceId;
|
||||
wpi::mutex periodicSendsMutex;
|
||||
wpi::SmallDenseMap<int32_t, int32_t> periodicSends;
|
||||
wpi::mutex receivesMutex;
|
||||
wpi::SmallDenseMap<int32_t, HAL_CANReceiveMessage> receives;
|
||||
wpi::util::mutex periodicSendsMutex;
|
||||
wpi::util::SmallDenseMap<int32_t, int32_t> periodicSends;
|
||||
wpi::util::mutex receivesMutex;
|
||||
wpi::util::SmallDenseMap<int32_t, HAL_CANReceiveMessage> receives;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
static UnlimitedHandleResource<HAL_CANHandle, CANStorage, HAL_HandleEnum::CAN>*
|
||||
canHandles;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeCANAPI() {
|
||||
static UnlimitedHandleResource<HAL_CANHandle, CANStorage, HAL_HandleEnum::CAN>
|
||||
cH;
|
||||
canHandles = &cH;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
static int32_t CreateCANId(CANStorage* storage, int32_t apiId) {
|
||||
int32_t createdId = 0;
|
||||
@@ -56,9 +56,9 @@ extern "C" {
|
||||
HAL_CANHandle HAL_InitializeCAN(int32_t busId, HAL_CANManufacturer manufacturer,
|
||||
int32_t deviceId, HAL_CANDeviceType deviceType,
|
||||
int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
|
||||
if (busId < 0 || busId > hal::kNumCanBuses) {
|
||||
if (busId < 0 || busId > wpi::hal::kNumCanBuses) {
|
||||
*status = PARAMETER_OUT_OF_RANGE;
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
@@ -231,7 +231,7 @@ void HAL_ReadCANPacketTimeout(HAL_CANHandle handle, int32_t apiId,
|
||||
auto i = can->receives.find(messageId);
|
||||
if (i != can->receives.end()) {
|
||||
// Found, check if new enough
|
||||
uint64_t now = wpi::Now();
|
||||
uint64_t now = wpi::util::Now();
|
||||
if (now - i->second.timeStamp >
|
||||
(static_cast<uint64_t>(timeoutMs) * 1000)) {
|
||||
// Timeout, return bad status
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
bool InitializeCanBuses();
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "wpi/hal/Errors.h"
|
||||
#include "wpi/hal/handles/IndexedHandleResource.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
static constexpr HAL_CANManufacturer manufacturer =
|
||||
HAL_CANManufacturer::HAL_CAN_Man_kCTRE;
|
||||
@@ -126,7 +126,7 @@ union PcmDebug {
|
||||
namespace {
|
||||
struct PCM {
|
||||
HAL_CANHandle canHandle;
|
||||
wpi::mutex lock;
|
||||
wpi::util::mutex lock;
|
||||
std::string previousAllocation;
|
||||
PcmControl control;
|
||||
PcmControlSetOneShotDur oneShot;
|
||||
@@ -136,14 +136,14 @@ struct PCM {
|
||||
static IndexedHandleResource<HAL_CTREPCMHandle, PCM, kNumCTREPCMModules,
|
||||
HAL_HandleEnum::CTREPCM>* pcmHandles;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeCTREPCM() {
|
||||
static IndexedHandleResource<HAL_CTREPCMHandle, PCM, kNumCTREPCMModules,
|
||||
HAL_HandleEnum::CTREPCM>
|
||||
pH;
|
||||
pcmHandles = &pH;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
#define READ_PACKET(type, frame, failureValue) \
|
||||
auto pcm = pcmHandles->Get(handle); \
|
||||
@@ -178,17 +178,17 @@ extern "C" {
|
||||
HAL_CTREPCMHandle HAL_InitializeCTREPCM(int32_t busId, int32_t module,
|
||||
const char* allocationLocation,
|
||||
int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
|
||||
HAL_CTREPCMHandle handle;
|
||||
auto pcm = pcmHandles->Allocate(module, &handle, status);
|
||||
|
||||
if (*status != 0) {
|
||||
if (pcm) {
|
||||
hal::SetLastErrorPreviouslyAllocated(status, "CTRE PCM", module,
|
||||
wpi::hal::SetLastErrorPreviouslyAllocated(status, "CTRE PCM", module,
|
||||
pcm->previousAllocation);
|
||||
} else {
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for CTRE PCM", 0,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for CTRE PCM", 0,
|
||||
kNumCTREPCMModules - 1, module);
|
||||
}
|
||||
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
|
||||
@@ -360,7 +360,7 @@ void HAL_FireCTREPCMOneShot(HAL_CTREPCMHandle handle, int32_t index,
|
||||
int32_t* status) {
|
||||
if (index > 7 || index < 0) {
|
||||
*status = PARAMETER_OUT_OF_RANGE;
|
||||
hal::SetLastError(
|
||||
wpi::hal::SetLastError(
|
||||
status,
|
||||
fmt::format("Only [0-7] are valid index values. Requested {}", index));
|
||||
return;
|
||||
@@ -392,7 +392,7 @@ void HAL_SetCTREPCMOneShotDuration(HAL_CTREPCMHandle handle, int32_t index,
|
||||
int32_t durMs, int32_t* status) {
|
||||
if (index > 7 || index < 0) {
|
||||
*status = PARAMETER_OUT_OF_RANGE;
|
||||
hal::SetLastError(
|
||||
wpi::hal::SetLastError(
|
||||
status,
|
||||
fmt::format("Only [0-7] are valid index values. Requested {}", index));
|
||||
return;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "wpi/hal/handles/IndexedHandleResource.h"
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
static constexpr HAL_CANManufacturer manufacturer =
|
||||
HAL_CANManufacturer::HAL_CAN_Man_kCTRE;
|
||||
@@ -118,24 +118,24 @@ struct PDP {
|
||||
static IndexedHandleResource<HAL_PDPHandle, PDP, kNumCTREPDPModules,
|
||||
HAL_HandleEnum::CTREPDP>* pdpHandles;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeCTREPDP() {
|
||||
static IndexedHandleResource<HAL_PDPHandle, PDP, kNumCTREPDPModules,
|
||||
HAL_HandleEnum::CTREPDP>
|
||||
pH;
|
||||
pdpHandles = &pH;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
extern "C" {
|
||||
|
||||
HAL_PDPHandle HAL_InitializePDP(int32_t busId, int32_t module,
|
||||
const char* allocationLocation,
|
||||
int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
if (!HAL_CheckPDPModule(module)) {
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for CTRE PDP", 0,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for CTRE PDP", 0,
|
||||
kNumCTREPDPModules - 1, module);
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
@@ -145,10 +145,10 @@ HAL_PDPHandle HAL_InitializePDP(int32_t busId, int32_t module,
|
||||
|
||||
if (*status != 0) {
|
||||
if (pdp) {
|
||||
hal::SetLastErrorPreviouslyAllocated(status, "CTRE PDP", module,
|
||||
wpi::hal::SetLastErrorPreviouslyAllocated(status, "CTRE PDP", module,
|
||||
pdp->previousAllocation);
|
||||
} else {
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for CTRE PDP", 0,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for CTRE PDP", 0,
|
||||
kNumCTREPDPModules - 1, module);
|
||||
}
|
||||
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
|
||||
@@ -175,7 +175,7 @@ void HAL_CleanPDP(HAL_PDPHandle handle) {
|
||||
}
|
||||
|
||||
int32_t HAL_GetPDPModuleNumber(HAL_PDPHandle handle, int32_t* status) {
|
||||
return hal::getHandleIndex(handle);
|
||||
return wpi::hal::getHandleIndex(handle);
|
||||
}
|
||||
|
||||
HAL_Bool HAL_CheckPDPModule(int32_t module) {
|
||||
@@ -232,7 +232,7 @@ double HAL_GetPDPChannelCurrent(HAL_PDPHandle handle, int32_t channel,
|
||||
int32_t* status) {
|
||||
if (!HAL_CheckPDPChannel(channel)) {
|
||||
*status = PARAMETER_OUT_OF_RANGE;
|
||||
hal::SetLastError(status, fmt::format("Invalid pdp channel {}", channel));
|
||||
wpi::hal::SetLastError(status, fmt::format("Invalid pdp channel {}", channel));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
|
||||
#include "ConstantsInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeConstants() {}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
extern "C" {
|
||||
int32_t HAL_GetSystemClockTicksPerMicrosecond(void) {
|
||||
|
||||
@@ -6,6 +6,6 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
constexpr int32_t kSystemClockTicksPerMicrosecond = 40;
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -19,21 +19,21 @@
|
||||
#include "wpi/hal/cpp/fpga_clock.h"
|
||||
#include "wpi/hal/handles/LimitedHandleResource.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeCounter() {}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
extern "C" {
|
||||
|
||||
HAL_CounterHandle HAL_InitializeCounter(int channel, HAL_Bool risingEdge,
|
||||
const char* allocationLocation,
|
||||
int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
if (channel == InvalidHandleIndex || channel >= kNumSmartIo) {
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Counter", 0,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Counter", 0,
|
||||
kNumSmartIo, channel);
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
@@ -45,10 +45,10 @@ HAL_CounterHandle HAL_InitializeCounter(int channel, HAL_Bool risingEdge,
|
||||
|
||||
if (*status != 0) {
|
||||
if (port) {
|
||||
hal::SetLastErrorPreviouslyAllocated(status, "SmartIo", channel,
|
||||
wpi::hal::SetLastErrorPreviouslyAllocated(status, "SmartIo", channel,
|
||||
port->previousAllocation);
|
||||
} else {
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Counter", 0,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for Counter", 0,
|
||||
kNumSmartIo, channel);
|
||||
}
|
||||
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
|
||||
@@ -78,9 +78,9 @@ void HAL_FreeCounter(HAL_CounterHandle counterHandle) {
|
||||
smartIoHandles->Free(counterHandle, HAL_HandleEnum::Counter);
|
||||
|
||||
// Wait for no other object to hold this handle.
|
||||
auto start = hal::fpga_clock::now();
|
||||
auto start = wpi::hal::fpga_clock::now();
|
||||
while (port.use_count() != 1) {
|
||||
auto current = hal::fpga_clock::now();
|
||||
auto current = wpi::hal::fpga_clock::now();
|
||||
if (start + std::chrono::seconds(1) < current) {
|
||||
std::puts("DIO handle free timeout");
|
||||
std::fflush(stdout);
|
||||
|
||||
@@ -17,22 +17,22 @@
|
||||
#include "wpi/hal/handles/HandlesInternal.h"
|
||||
#include "wpi/hal/handles/LimitedHandleResource.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeDIO() {}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
extern "C" {
|
||||
|
||||
HAL_DigitalHandle HAL_InitializeDIOPort(int32_t channel, HAL_Bool input,
|
||||
const char* allocationLocation,
|
||||
int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
|
||||
if (channel < 0 || channel >= kNumSmartIo) {
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for DIO", 0,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for DIO", 0,
|
||||
kNumSmartIo, channel);
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
@@ -44,10 +44,10 @@ HAL_DigitalHandle HAL_InitializeDIOPort(int32_t channel, HAL_Bool input,
|
||||
|
||||
if (*status != 0) {
|
||||
if (port) {
|
||||
hal::SetLastErrorPreviouslyAllocated(status, "SmartIo", channel,
|
||||
wpi::hal::SetLastErrorPreviouslyAllocated(status, "SmartIo", channel,
|
||||
port->previousAllocation);
|
||||
} else {
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for DIO", 0,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for DIO", 0,
|
||||
kNumSmartIo, channel);
|
||||
}
|
||||
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
|
||||
@@ -80,9 +80,9 @@ void HAL_FreeDIOPort(HAL_DigitalHandle dioPortHandle) {
|
||||
smartIoHandles->Free(dioPortHandle, HAL_HandleEnum::DIO);
|
||||
|
||||
// Wait for no other object to hold this handle.
|
||||
auto start = hal::fpga_clock::now();
|
||||
auto start = wpi::hal::fpga_clock::now();
|
||||
while (port.use_count() != 1) {
|
||||
auto current = hal::fpga_clock::now();
|
||||
auto current = wpi::hal::fpga_clock::now();
|
||||
if (start + std::chrono::seconds(1) < current) {
|
||||
std::puts("DIO handle free timeout");
|
||||
std::fflush(stdout);
|
||||
|
||||
@@ -17,21 +17,21 @@
|
||||
#include "wpi/hal/handles/HandlesInternal.h"
|
||||
#include "wpi/hal/handles/LimitedHandleResource.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeDutyCycle() {}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
extern "C" {
|
||||
HAL_DutyCycleHandle HAL_InitializeDutyCycle(int32_t channel,
|
||||
const char* allocationLocation,
|
||||
int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
|
||||
if (channel < 0 || channel >= kNumSmartIo) {
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for DutyCycle", 0,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for DutyCycle", 0,
|
||||
kNumSmartIo, channel);
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
@@ -43,10 +43,10 @@ HAL_DutyCycleHandle HAL_InitializeDutyCycle(int32_t channel,
|
||||
|
||||
if (*status != 0) {
|
||||
if (port) {
|
||||
hal::SetLastErrorPreviouslyAllocated(status, "SmartIo", channel,
|
||||
wpi::hal::SetLastErrorPreviouslyAllocated(status, "SmartIo", channel,
|
||||
port->previousAllocation);
|
||||
} else {
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for DutyCycle", 0,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for DutyCycle", 0,
|
||||
kNumSmartIo, channel);
|
||||
}
|
||||
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
|
||||
@@ -73,9 +73,9 @@ void HAL_FreeDutyCycle(HAL_DutyCycleHandle dutyCycleHandle) {
|
||||
smartIoHandles->Free(dutyCycleHandle, HAL_HandleEnum::DutyCycle);
|
||||
|
||||
// Wait for no other object to hold this handle.
|
||||
auto start = hal::fpga_clock::now();
|
||||
auto start = wpi::hal::fpga_clock::now();
|
||||
while (port.use_count() != 1) {
|
||||
auto current = hal::fpga_clock::now();
|
||||
auto current = wpi::hal::fpga_clock::now();
|
||||
if (start + std::chrono::seconds(1) < current) {
|
||||
std::puts("DIO handle free timeout");
|
||||
std::fflush(stdout);
|
||||
|
||||
@@ -15,18 +15,18 @@
|
||||
#include "wpi/hal/Errors.h"
|
||||
#include "wpi/hal/handles/LimitedClassedHandleResource.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeEncoder() {}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
extern "C" {
|
||||
HAL_EncoderHandle HAL_InitializeEncoder(int32_t aChannel, int32_t bChannel,
|
||||
HAL_Bool reverseDirection,
|
||||
HAL_EncoderEncodingType encodingType,
|
||||
int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
@@ -62,43 +62,43 @@ static_assert(std::is_standard_layout_v<JoystickDataCache>);
|
||||
// static_assert(std::is_trivial_v<JoystickDataCache>);
|
||||
|
||||
struct SystemServerDriverStation {
|
||||
nt::NetworkTableInstance ntInst;
|
||||
nt::BooleanPublisher hasUserCodePublisher;
|
||||
nt::BooleanPublisher hasUserCodeReadyPublisher;
|
||||
wpi::nt::NetworkTableInstance ntInst;
|
||||
wpi::nt::BooleanPublisher hasUserCodePublisher;
|
||||
wpi::nt::BooleanPublisher hasUserCodeReadyPublisher;
|
||||
|
||||
nt::BooleanSubscriber hasSetWallClockSubscriber;
|
||||
wpi::nt::BooleanSubscriber hasSetWallClockSubscriber;
|
||||
|
||||
nt::ProtobufSubscriber<mrc::ControlData> controlDataSubscriber;
|
||||
nt::ProtobufSubscriber<mrc::MatchInfo> matchInfoSubscriber;
|
||||
nt::StringSubscriber gameSpecificMessageSubscriber;
|
||||
wpi::nt::ProtobufSubscriber<mrc::ControlData> controlDataSubscriber;
|
||||
wpi::nt::ProtobufSubscriber<mrc::MatchInfo> matchInfoSubscriber;
|
||||
wpi::nt::StringSubscriber gameSpecificMessageSubscriber;
|
||||
|
||||
std::array<nt::ProtobufSubscriber<mrc::JoystickDescriptor>,
|
||||
std::array<wpi::nt::ProtobufSubscriber<mrc::JoystickDescriptor>,
|
||||
MRC_MAX_NUM_JOYSTICKS>
|
||||
joystickDescriptorTopics;
|
||||
|
||||
nt::StringPublisher versionPublisher;
|
||||
nt::StringPublisher consoleLinePublisher;
|
||||
nt::ProtobufPublisher<mrc::ErrorInfo> errorInfoPublisher;
|
||||
wpi::nt::StringPublisher versionPublisher;
|
||||
wpi::nt::StringPublisher consoleLinePublisher;
|
||||
wpi::nt::ProtobufPublisher<mrc::ErrorInfo> errorInfoPublisher;
|
||||
|
||||
std::array<nt::ProtobufPublisher<mrc::JoystickRumbleData>,
|
||||
std::array<wpi::nt::ProtobufPublisher<mrc::JoystickRumbleData>,
|
||||
MRC_MAX_NUM_JOYSTICKS>
|
||||
joystickRumbleTopics;
|
||||
|
||||
nt::ProtobufPublisher<std::vector<mrc::OpMode>> teleopOpModes;
|
||||
nt::ProtobufPublisher<std::vector<mrc::OpMode>> autoOpModes;
|
||||
nt::ProtobufPublisher<std::vector<mrc::OpMode>> testOpModes;
|
||||
nt::IntegerPublisher traceOpModePublisher;
|
||||
wpi::nt::ProtobufPublisher<std::vector<mrc::OpMode>> teleopOpModes;
|
||||
wpi::nt::ProtobufPublisher<std::vector<mrc::OpMode>> autoOpModes;
|
||||
wpi::nt::ProtobufPublisher<std::vector<mrc::OpMode>> testOpModes;
|
||||
wpi::nt::IntegerPublisher traceOpModePublisher;
|
||||
|
||||
NT_Listener controlDataListener;
|
||||
|
||||
wpi::mutex controlDataMutex;
|
||||
wpi::ProtobufMessage<mrc::ControlData> controlDataMsg;
|
||||
nt::Value lastValue;
|
||||
wpi::util::mutex controlDataMutex;
|
||||
wpi::util::ProtobufMessage<mrc::ControlData> controlDataMsg;
|
||||
wpi::nt::Value lastValue;
|
||||
|
||||
explicit SystemServerDriverStation(nt::NetworkTableInstance inst) {
|
||||
explicit SystemServerDriverStation(wpi::nt::NetworkTableInstance inst) {
|
||||
ntInst = inst;
|
||||
|
||||
nt::PubSubOptions options;
|
||||
wpi::nt::PubSubOptions options;
|
||||
options.sendAll = true;
|
||||
options.keepDuplicates = true;
|
||||
options.periodic = 0.005;
|
||||
@@ -179,7 +179,7 @@ struct SystemServerDriverStation {
|
||||
|
||||
ntInst.AddListener(
|
||||
controlDataSubscriber, NT_EVENT_VALUE_REMOTE | NT_EVENT_UNPUBLISH,
|
||||
[this](const nt::Event& event) { HandleListener(event); });
|
||||
[this](const wpi::nt::Event& event) { HandleListener(event); });
|
||||
|
||||
traceOpModePublisher =
|
||||
ntInst.GetIntegerTopic(ROBOT_CURRENT_OPMODE_TRACE_PATH)
|
||||
@@ -187,7 +187,7 @@ struct SystemServerDriverStation {
|
||||
traceOpModePublisher.GetTopic().SetCached(false);
|
||||
}
|
||||
|
||||
void HandleListener(const nt::Event& event);
|
||||
void HandleListener(const wpi::nt::Event& event);
|
||||
|
||||
bool GetLastControlData(mrc::ControlData* data, int64_t* time) {
|
||||
std::scoped_lock lock{controlDataMutex};
|
||||
@@ -205,14 +205,14 @@ struct SystemServerDriverStation {
|
||||
};
|
||||
|
||||
struct FRCDriverStation {
|
||||
wpi::EventVector newDataEvents;
|
||||
wpi::util::EventVector newDataEvents;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
static ::SystemServerDriverStation* systemServerDs;
|
||||
static ::FRCDriverStation* driverStation;
|
||||
|
||||
void SystemServerDriverStation::HandleListener(const nt::Event& event) {
|
||||
void SystemServerDriverStation::HandleListener(const wpi::nt::Event& event) {
|
||||
auto valueEvent = event.GetValueEventData();
|
||||
|
||||
bool isValid = valueEvent && valueEvent->value.IsRaw();
|
||||
@@ -224,7 +224,7 @@ void SystemServerDriverStation::HandleListener(const nt::Event& event) {
|
||||
} else {
|
||||
// We've either been unpublished, or type changed.
|
||||
// Treat either as a disconnect.
|
||||
lastValue = nt::Value{};
|
||||
lastValue = wpi::nt::Value{};
|
||||
}
|
||||
}
|
||||
if (isValid) {
|
||||
@@ -233,7 +233,7 @@ void SystemServerDriverStation::HandleListener(const nt::Event& event) {
|
||||
}
|
||||
|
||||
// Message and Data variables
|
||||
static wpi::mutex msgMutex;
|
||||
static wpi::util::mutex msgMutex;
|
||||
|
||||
void JoystickDataCache::Update(const mrc::ControlData& data) {
|
||||
matchTime = data.MatchTime;
|
||||
@@ -288,7 +288,7 @@ static JoystickDataCache caches[2];
|
||||
static JoystickDataCache* currentRead = &caches[0];
|
||||
static JoystickDataCache* cacheToUpdate = &caches[1];
|
||||
|
||||
static wpi::mutex cacheMutex;
|
||||
static wpi::util::mutex cacheMutex;
|
||||
|
||||
namespace {
|
||||
struct TcpCache {
|
||||
@@ -306,7 +306,7 @@ static TcpCache tcpCaches[2];
|
||||
static TcpCache* tcpCurrentRead = &tcpCaches[0];
|
||||
static TcpCache* tcpCacheToUpdate = &tcpCaches[1];
|
||||
|
||||
static wpi::mutex tcpCacheMutex;
|
||||
static wpi::util::mutex tcpCacheMutex;
|
||||
|
||||
void TcpCache::Update() {
|
||||
auto newMatchInfo = systemServerDs->matchInfoSubscriber.Get();
|
||||
@@ -353,22 +353,22 @@ void TcpCache::Update() {
|
||||
}
|
||||
}
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeFRCDriverStation() {
|
||||
std::memset(&newestControlWord, 0, sizeof(newestControlWord));
|
||||
static FRCDriverStation ds;
|
||||
driverStation = &ds;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
static void DefaultPrintErrorImpl(const char* line, size_t size) {
|
||||
std::fwrite(line, size, 1, stderr);
|
||||
}
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
static std::atomic<void (*)(const char* line, size_t size)> gPrintErrorImpl{
|
||||
hal::DefaultPrintErrorImpl};
|
||||
wpi::hal::DefaultPrintErrorImpl};
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -446,7 +446,7 @@ int32_t HAL_SendError(HAL_Bool isError, int32_t errorCode, HAL_Bool isLVCode,
|
||||
}
|
||||
|
||||
void HAL_SetPrintErrorImpl(void (*func)(const char* line, size_t size)) {
|
||||
gPrintErrorImpl.store(func ? func : hal::DefaultPrintErrorImpl);
|
||||
gPrintErrorImpl.store(func ? func : wpi::hal::DefaultPrintErrorImpl);
|
||||
}
|
||||
|
||||
int32_t HAL_SendConsoleLine(const char* line) {
|
||||
@@ -592,7 +592,7 @@ HAL_Bool HAL_RefreshDSData(void) {
|
||||
int64_t dataTime{0};
|
||||
bool dataValid = systemServerDs->GetLastControlData(&newestData, &dataTime);
|
||||
|
||||
// auto now = wpi::Now();
|
||||
// auto now = wpi::util::Now();
|
||||
// auto delta = now - dataTime;
|
||||
|
||||
bool updatedData = false;
|
||||
@@ -622,7 +622,7 @@ HAL_Bool HAL_RefreshDSData(void) {
|
||||
}
|
||||
|
||||
void HAL_ProvideNewDataEventHandle(WPI_EventHandle handle) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
driverStation->newDataEvents.Add(handle);
|
||||
}
|
||||
|
||||
@@ -640,17 +640,17 @@ HAL_Bool HAL_GetSystemTimeValid(int32_t* status) {
|
||||
|
||||
} // extern "C"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
void InitializeDriverStation() {
|
||||
systemServerDs = new ::SystemServerDriverStation{hal::GetSystemServer()};
|
||||
systemServerDs = new ::SystemServerDriverStation{wpi::hal::GetSystemServer()};
|
||||
}
|
||||
|
||||
void WaitForInitialPacket() {
|
||||
wpi::Event waitForInitEvent;
|
||||
wpi::util::Event waitForInitEvent;
|
||||
driverStation->newDataEvents.Add(waitForInitEvent.GetHandle());
|
||||
bool timed_out = false;
|
||||
wpi::WaitForObject(waitForInitEvent.GetHandle(), 0.1, &timed_out);
|
||||
wpi::util::WaitForObject(waitForInitEvent.GetHandle(), 0.1, &timed_out);
|
||||
// Don't care what the result is, just want to give it a chance.
|
||||
driverStation->newDataEvents.Remove(waitForInitEvent.GetHandle());
|
||||
}
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -32,15 +32,15 @@
|
||||
#include "wpi/util/print.hpp"
|
||||
#include "wpi/util/timestamp.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
static uint64_t dsStartTime;
|
||||
|
||||
static int32_t teamNumber = -1;
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
void InitializeDriverStation();
|
||||
void WaitForInitialPacket();
|
||||
namespace init {
|
||||
@@ -77,7 +77,7 @@ uint64_t GetDSInitializeTime() {
|
||||
return dsStartTime;
|
||||
}
|
||||
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -199,9 +199,9 @@ void InitializeTeamNumber(void) {
|
||||
// Split string around '-' (max of 2 splits), take the second element
|
||||
teamNumber = 0;
|
||||
int i = 0;
|
||||
wpi::split(hostname, '-', 2, false, [&](auto part) {
|
||||
wpi::util::split(hostname, '-', 2, false, [&](auto part) {
|
||||
if (i == 1) {
|
||||
teamNumber = wpi::parse_integer<int32_t>(part, 10).value_or(0);
|
||||
teamNumber = wpi::util::parse_integer<int32_t>(part, 10).value_or(0);
|
||||
}
|
||||
++i;
|
||||
});
|
||||
@@ -215,8 +215,8 @@ int32_t HAL_GetTeamNumber(void) {
|
||||
}
|
||||
|
||||
uint64_t HAL_GetFPGATime(int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
return wpi::NowDefault();
|
||||
wpi::hal::init::CheckInit();
|
||||
return wpi::util::NowDefault();
|
||||
}
|
||||
|
||||
uint64_t HAL_ExpandFPGATime(uint32_t unexpandedLower, int32_t* status) {
|
||||
@@ -244,32 +244,32 @@ uint64_t HAL_ExpandFPGATime(uint32_t unexpandedLower, int32_t* status) {
|
||||
}
|
||||
|
||||
HAL_Bool HAL_GetSystemActive(int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
||||
HAL_Bool HAL_GetBrownedOut(int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t HAL_GetCommsDisableCount(int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
HAL_Bool HAL_GetRSLState(int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
||||
HAL_Bool HAL_Initialize(int32_t timeout, int32_t mode) {
|
||||
static std::atomic_bool initialized{false};
|
||||
static wpi::mutex initializeMutex;
|
||||
static wpi::util::mutex initializeMutex;
|
||||
// Initial check, as if it's true initialization has finished
|
||||
if (initialized) {
|
||||
return true;
|
||||
@@ -282,18 +282,18 @@ HAL_Bool HAL_Initialize(int32_t timeout, int32_t mode) {
|
||||
}
|
||||
|
||||
// Initialize system server first, other things might use it
|
||||
hal::InitializeSystemServer();
|
||||
wpi::hal::InitializeSystemServer();
|
||||
|
||||
hal::init::InitializeHAL();
|
||||
wpi::hal::init::InitializeHAL();
|
||||
|
||||
hal::init::HAL_IsInitialized.store(true);
|
||||
wpi::hal::init::HAL_IsInitialized.store(true);
|
||||
|
||||
setlinebuf(stdin);
|
||||
setlinebuf(stdout);
|
||||
|
||||
prctl(PR_SET_PDEATHSIG, SIGTERM);
|
||||
|
||||
if (!hal::InitializeCanBuses()) {
|
||||
if (!wpi::hal::InitializeCanBuses()) {
|
||||
std::printf("Failed to initialize can buses\n");
|
||||
return false;
|
||||
}
|
||||
@@ -307,14 +307,14 @@ HAL_Bool HAL_Initialize(int32_t timeout, int32_t mode) {
|
||||
|
||||
int32_t status = 0;
|
||||
|
||||
hal::InitializeDriverStation();
|
||||
wpi::hal::InitializeDriverStation();
|
||||
|
||||
dsStartTime = HAL_GetFPGATime(&status);
|
||||
if (status != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
hal::WaitForInitialPacket();
|
||||
wpi::hal::WaitForInitialPacket();
|
||||
|
||||
initialized = true;
|
||||
return true;
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
#include "wpi/hal/HALBase.h"
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
std::atomic_bool HAL_IsInitialized{false};
|
||||
void RunInitialize() {
|
||||
HAL_Initialize(500, 0);
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <atomic>
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
extern std::atomic_bool HAL_IsInitialized;
|
||||
extern void RunInitialize();
|
||||
inline void CheckInit() {
|
||||
@@ -44,4 +44,4 @@ extern void InitializeSerialPort();
|
||||
extern void InitializeSmartIo();
|
||||
extern void InitializeThreads();
|
||||
extern void InitializeUsageReporting();
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <string_view>
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
void SetLastError(int32_t* status, std::string_view value);
|
||||
void SetLastErrorIndexOutOfRange(int32_t* status, std::string_view message,
|
||||
int32_t minimum, int32_t maximum,
|
||||
@@ -17,4 +17,4 @@ void SetLastErrorPreviouslyAllocated(int32_t* status, std::string_view message,
|
||||
int32_t channel,
|
||||
std::string_view previousAllocation);
|
||||
uint64_t GetDSInitializeTime();
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -22,14 +22,14 @@
|
||||
#include "wpi/util/mutex.hpp"
|
||||
#include "wpi/util/print.hpp"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace {
|
||||
constexpr const char* physicalPorts[kNumI2cBuses] = {"/dev/i2c-10",
|
||||
"/dev/i2c-1"};
|
||||
|
||||
struct I2C {
|
||||
wpi::mutex initMutex;
|
||||
wpi::util::mutex initMutex;
|
||||
int objCount = 0;
|
||||
int fd = -1;
|
||||
};
|
||||
@@ -37,17 +37,17 @@ struct I2C {
|
||||
static I2C i2cObjs[kNumI2cBuses];
|
||||
} // namespace
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeI2C() {}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
extern "C" {
|
||||
void HAL_InitializeI2C(HAL_I2CPort port, int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
|
||||
if (port < 0 || port > 2) {
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for I2C", 0, 1,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for I2C", 0, 1,
|
||||
port);
|
||||
return;
|
||||
}
|
||||
@@ -61,9 +61,9 @@ void HAL_InitializeI2C(HAL_I2CPort port, int32_t* status) {
|
||||
if (handle < 0) {
|
||||
int err = errno;
|
||||
*status = NO_AVAILABLE_RESOURCES;
|
||||
hal::SetLastError(status, fmt::format("Failed to open onboard i2c bus: {}",
|
||||
wpi::hal::SetLastError(status, fmt::format("Failed to open onboard i2c bus: {}",
|
||||
std::strerror(err)));
|
||||
wpi::print("Failed to open onboard i2c bus: {}\n", std::strerror(err));
|
||||
wpi::util::print("Failed to open onboard i2c bus: {}\n", std::strerror(err));
|
||||
handle = -1;
|
||||
i2cObjs[port].objCount--;
|
||||
return;
|
||||
@@ -76,7 +76,7 @@ int32_t HAL_TransactionI2C(HAL_I2CPort port, int32_t deviceAddress,
|
||||
uint8_t* dataReceived, int32_t receiveSize) {
|
||||
if (port < 0 || port > 2) {
|
||||
int32_t status = 0;
|
||||
hal::SetLastErrorIndexOutOfRange(&status, "Invalid Index for I2C", 0, 1,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(&status, "Invalid Index for I2C", 0, 1,
|
||||
port);
|
||||
return -1;
|
||||
}
|
||||
@@ -103,7 +103,7 @@ int32_t HAL_WriteI2C(HAL_I2CPort port, int32_t deviceAddress,
|
||||
const uint8_t* dataToSend, int32_t sendSize) {
|
||||
if (port < 0 || port > 2) {
|
||||
int32_t status = 0;
|
||||
hal::SetLastErrorIndexOutOfRange(&status, "Invalid Index for I2C", 0, 2,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(&status, "Invalid Index for I2C", 0, 2,
|
||||
port);
|
||||
return -1;
|
||||
}
|
||||
@@ -126,7 +126,7 @@ int32_t HAL_ReadI2C(HAL_I2CPort port, int32_t deviceAddress, uint8_t* buffer,
|
||||
int32_t count) {
|
||||
if (port < 0 || port > 2) {
|
||||
int32_t status = 0;
|
||||
hal::SetLastErrorIndexOutOfRange(&status, "Invalid Index for I2C", 0, 1,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(&status, "Invalid Index for I2C", 0, 1,
|
||||
port);
|
||||
return -1;
|
||||
}
|
||||
@@ -148,7 +148,7 @@ int32_t HAL_ReadI2C(HAL_I2CPort port, int32_t deviceAddress, uint8_t* buffer,
|
||||
void HAL_CloseI2C(HAL_I2CPort port) {
|
||||
if (port < 0 || port > 2) {
|
||||
int32_t status = 0;
|
||||
hal::SetLastErrorIndexOutOfRange(&status, "Invalid Index for I2C", 0, 1,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(&status, "Invalid Index for I2C", 0, 1,
|
||||
port);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ constexpr const char* kYawLandscapeKey = IMU_PREFIX "yaw_landscape";
|
||||
constexpr const char* kYawPortraitKey = IMU_PREFIX "yaw_portrait";
|
||||
|
||||
struct IMU {
|
||||
explicit IMU(nt::NetworkTableInstance inst)
|
||||
explicit IMU(wpi::nt::NetworkTableInstance inst)
|
||||
: rawAccelSub{inst.GetDoubleArrayTopic(kRawAccelKey).Subscribe({})},
|
||||
rawGyroSub{inst.GetDoubleArrayTopic(kRawGyroKey).Subscribe({})},
|
||||
quatSub{inst.GetDoubleArrayTopic(kQuaternionKey).Subscribe({})},
|
||||
@@ -42,15 +42,15 @@ struct IMU {
|
||||
yawLandscapeSub{inst.GetDoubleTopic(kYawLandscapeKey).Subscribe(0)},
|
||||
yawPortraitSub{inst.GetDoubleTopic(kYawPortraitKey).Subscribe(0)} {}
|
||||
|
||||
nt::DoubleArraySubscriber rawAccelSub;
|
||||
nt::DoubleArraySubscriber rawGyroSub;
|
||||
nt::DoubleArraySubscriber quatSub;
|
||||
nt::DoubleArraySubscriber eulerFlatSub;
|
||||
nt::DoubleArraySubscriber eulerLandscapeSub;
|
||||
nt::DoubleArraySubscriber eulerPortraitSub;
|
||||
nt::DoubleSubscriber yawFlatSub;
|
||||
nt::DoubleSubscriber yawLandscapeSub;
|
||||
nt::DoubleSubscriber yawPortraitSub;
|
||||
wpi::nt::DoubleArraySubscriber rawAccelSub;
|
||||
wpi::nt::DoubleArraySubscriber rawGyroSub;
|
||||
wpi::nt::DoubleArraySubscriber quatSub;
|
||||
wpi::nt::DoubleArraySubscriber eulerFlatSub;
|
||||
wpi::nt::DoubleArraySubscriber eulerLandscapeSub;
|
||||
wpi::nt::DoubleArraySubscriber eulerPortraitSub;
|
||||
wpi::nt::DoubleSubscriber yawFlatSub;
|
||||
wpi::nt::DoubleSubscriber yawLandscapeSub;
|
||||
wpi::nt::DoubleSubscriber yawPortraitSub;
|
||||
};
|
||||
|
||||
static IMU* imu;
|
||||
@@ -59,12 +59,12 @@ constexpr double kDegreesToRadians = std::numbers::pi / 180.0;
|
||||
constexpr double kGToMetersPerSecondSquared = 9.80665;
|
||||
} // namespace
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeIMU() {
|
||||
static IMU imu_static{hal::GetSystemServer()};
|
||||
static IMU imu_static{wpi::hal::GetSystemServer()};
|
||||
imu = &imu_static;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
extern "C" {
|
||||
void HAL_GetIMUAcceleration(HAL_Acceleration3d* accel, int32_t* status) {
|
||||
|
||||
@@ -29,15 +29,15 @@ struct Notifier {
|
||||
uint64_t waitTime = UINT64_MAX;
|
||||
bool active = true;
|
||||
bool waitTimeValid = false; // True if waitTime is set and in the future
|
||||
wpi::mutex mutex;
|
||||
wpi::condition_variable cond;
|
||||
wpi::util::mutex mutex;
|
||||
wpi::util::condition_variable cond;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
static wpi::mutex notifiersWaiterMutex;
|
||||
static wpi::condition_variable notifiersWaiterCond;
|
||||
static wpi::util::mutex notifiersWaiterMutex;
|
||||
static wpi::util::condition_variable notifiersWaiterCond;
|
||||
|
||||
class NotifierHandleContainer
|
||||
: public UnlimitedHandleResource<HAL_NotifierHandle, Notifier,
|
||||
@@ -58,17 +58,17 @@ class NotifierHandleContainer
|
||||
|
||||
static NotifierHandleContainer* notifierHandles;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeNotifier() {
|
||||
static NotifierHandleContainer nH;
|
||||
notifierHandles = &nH;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
extern "C" {
|
||||
|
||||
HAL_NotifierHandle HAL_InitializeNotifier(int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
std::shared_ptr<Notifier> notifier = std::make_shared<Notifier>();
|
||||
HAL_NotifierHandle handle = notifierHandles->Allocate(notifier);
|
||||
if (handle == HAL_kInvalidHandle) {
|
||||
|
||||
@@ -20,22 +20,22 @@
|
||||
#include "wpi/hal/handles/HandlesInternal.h"
|
||||
#include "wpi/util/print.hpp"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializePWM() {}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
extern "C" {
|
||||
|
||||
HAL_DigitalHandle HAL_InitializePWMPort(int32_t channel,
|
||||
const char* allocationLocation,
|
||||
int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
|
||||
if (channel < 0 || channel >= kNumSmartIo) {
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for PWM", 0,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for PWM", 0,
|
||||
kNumSmartIo, channel);
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
@@ -47,10 +47,10 @@ HAL_DigitalHandle HAL_InitializePWMPort(int32_t channel,
|
||||
|
||||
if (*status != 0) {
|
||||
if (port) {
|
||||
hal::SetLastErrorPreviouslyAllocated(status, "SmartIo", channel,
|
||||
wpi::hal::SetLastErrorPreviouslyAllocated(status, "SmartIo", channel,
|
||||
port->previousAllocation);
|
||||
} else {
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for PWM", 0,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for PWM", 0,
|
||||
kNumSmartIo, channel);
|
||||
}
|
||||
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
|
||||
@@ -85,9 +85,9 @@ void HAL_FreePWMPort(HAL_DigitalHandle pwmPortHandle) {
|
||||
smartIoHandles->Free(pwmPortHandle, HAL_HandleEnum::PWM);
|
||||
|
||||
// Wait for no other object to hold this handle.
|
||||
auto start = hal::fpga_clock::now();
|
||||
auto start = wpi::hal::fpga_clock::now();
|
||||
while (port.use_count() != 1) {
|
||||
auto current = hal::fpga_clock::now();
|
||||
auto current = wpi::hal::fpga_clock::now();
|
||||
if (start + std::chrono::seconds(1) < current) {
|
||||
std::puts("PWM handle free timeout");
|
||||
std::fflush(stdout);
|
||||
@@ -116,7 +116,7 @@ void HAL_SetPWMPulseTimeMicroseconds(HAL_DigitalHandle pwmPortHandle,
|
||||
if (microsecondPulseTime < 0 ||
|
||||
(microsecondPulseTime != 0xFFFF && microsecondPulseTime >= 4096)) {
|
||||
*status = PARAMETER_OUT_OF_RANGE;
|
||||
hal::SetLastError(
|
||||
wpi::hal::SetLastError(
|
||||
status,
|
||||
fmt::format("Pulse time {} out of range. Expect [0-4096) or 0xFFFF",
|
||||
microsecondPulseTime));
|
||||
@@ -149,14 +149,14 @@ void HAL_SetPWMOutputPeriod(HAL_DigitalHandle pwmPortHandle, int32_t period,
|
||||
|
||||
switch (period) {
|
||||
case 0:
|
||||
*status = port->SetPwmOutputPeriod(hal::PwmOutputPeriod::k5ms);
|
||||
*status = port->SetPwmOutputPeriod(wpi::hal::PwmOutputPeriod::k5ms);
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
*status = port->SetPwmOutputPeriod(hal::PwmOutputPeriod::k10ms);
|
||||
*status = port->SetPwmOutputPeriod(wpi::hal::PwmOutputPeriod::k10ms);
|
||||
break;
|
||||
case 3:
|
||||
*status = port->SetPwmOutputPeriod(hal::PwmOutputPeriod::k20ms);
|
||||
*status = port->SetPwmOutputPeriod(wpi::hal::PwmOutputPeriod::k20ms);
|
||||
break;
|
||||
default:
|
||||
*status = PARAMETER_OUT_OF_RANGE;
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
|
||||
#include "PortsInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializePorts() {}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
extern "C" {
|
||||
int32_t HAL_GetNumCanBuses(void) {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
|
||||
constexpr int32_t kNumCanBuses = 5;
|
||||
constexpr int32_t kNumSmartIo = 6;
|
||||
@@ -33,4 +33,4 @@ constexpr int32_t kNumAddressableLEDs = 6;
|
||||
constexpr int32_t kNumREVPHModules = 63;
|
||||
constexpr int32_t kNumREVPHChannels = 16;
|
||||
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -12,23 +12,23 @@
|
||||
#include "wpi/hal/Errors.h"
|
||||
#include "wpi/nt/DoubleTopic.hpp"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
|
||||
static void initializePower(int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
}
|
||||
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
namespace {
|
||||
struct SystemServerPower {
|
||||
nt::NetworkTableInstance ntInst;
|
||||
wpi::nt::NetworkTableInstance ntInst;
|
||||
|
||||
nt::DoubleSubscriber batterySubscriber;
|
||||
wpi::nt::DoubleSubscriber batterySubscriber;
|
||||
|
||||
explicit SystemServerPower(nt::NetworkTableInstance inst) {
|
||||
explicit SystemServerPower(wpi::nt::NetworkTableInstance inst) {
|
||||
ntInst = inst;
|
||||
|
||||
batterySubscriber =
|
||||
@@ -39,11 +39,11 @@ struct SystemServerPower {
|
||||
|
||||
static ::SystemServerPower* systemServerPower;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializePower() {
|
||||
systemServerPower = new ::SystemServerPower{hal::GetSystemServer()};
|
||||
systemServerPower = new ::SystemServerPower{wpi::hal::GetSystemServer()};
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "wpi/hal/HALBase.h"
|
||||
#include "wpi/hal/handles/HandlesInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -25,12 +25,12 @@ HAL_PowerDistributionHandle HAL_InitializePowerDistribution(
|
||||
if (type == HAL_PowerDistributionType::HAL_PowerDistributionType_kAutomatic) {
|
||||
if (moduleNumber != HAL_DEFAULT_POWER_DISTRIBUTION_MODULE) {
|
||||
*status = PARAMETER_OUT_OF_RANGE;
|
||||
hal::SetLastError(
|
||||
wpi::hal::SetLastError(
|
||||
status, "Automatic PowerDistributionType must have default module");
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
uint64_t waitTime = hal::GetDSInitializeTime() + 400000;
|
||||
uint64_t waitTime = wpi::hal::GetDSInitializeTime() + 400000;
|
||||
|
||||
// Ensure we have been alive for long enough to receive a few Power packets.
|
||||
do {
|
||||
@@ -75,7 +75,7 @@ HAL_PowerDistributionHandle HAL_InitializePowerDistribution(
|
||||
}
|
||||
}
|
||||
|
||||
#define IsCtre(handle) ::hal::isHandleType(handle, HAL_HandleEnum::CTREPDP)
|
||||
#define IsCtre(handle) ::wpi::hal::isHandleType(handle, HAL_HandleEnum::CTREPDP)
|
||||
|
||||
void HAL_CleanPowerDistribution(HAL_PowerDistributionHandle handle) {
|
||||
if (IsCtre(handle)) {
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "wpi/hal/handles/HandlesInternal.h"
|
||||
#include "wpi/hal/handles/IndexedHandleResource.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
static constexpr HAL_CANManufacturer manufacturer =
|
||||
HAL_CANManufacturer::HAL_CAN_Man_kREV;
|
||||
@@ -77,14 +77,14 @@ static constexpr int32_t kPDHFrameStatus4Timeout = 20;
|
||||
static IndexedHandleResource<HAL_REVPDHHandle, REV_PDHObj, kNumREVPDHModules,
|
||||
HAL_HandleEnum::REVPDH>* REVPDHHandles;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeREVPDH() {
|
||||
static IndexedHandleResource<HAL_REVPDHHandle, REV_PDHObj, kNumREVPDHModules,
|
||||
HAL_HandleEnum::REVPDH>
|
||||
rH;
|
||||
REVPDHHandles = &rH;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -191,10 +191,10 @@ PDH_status_4_t HAL_GetREVPDHStatus4(HAL_REVPDHHandle handle, int32_t* status) {
|
||||
HAL_REVPDHHandle HAL_InitializeREVPDH(int32_t busId, int32_t module,
|
||||
const char* allocationLocation,
|
||||
int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
if (!HAL_CheckREVPDHModuleNumber(module)) {
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for REV PDH", 1,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for REV PDH", 1,
|
||||
kNumREVPDHModules, module);
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
@@ -204,10 +204,10 @@ HAL_REVPDHHandle HAL_InitializeREVPDH(int32_t busId, int32_t module,
|
||||
auto hpdh = REVPDHHandles->Allocate(module - 1, &handle, status);
|
||||
if (*status != 0) {
|
||||
if (hpdh) {
|
||||
hal::SetLastErrorPreviouslyAllocated(status, "REV PDH", module,
|
||||
wpi::hal::SetLastErrorPreviouslyAllocated(status, "REV PDH", module,
|
||||
hpdh->previousAllocation);
|
||||
} else {
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for REV PDH", 1,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for REV PDH", 1,
|
||||
kNumREVPDHModules, module);
|
||||
}
|
||||
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
|
||||
@@ -241,7 +241,7 @@ void HAL_FreeREVPDH(HAL_REVPDHHandle handle) {
|
||||
}
|
||||
|
||||
int32_t HAL_GetREVPDHModuleNumber(HAL_REVPDHHandle handle, int32_t* status) {
|
||||
return hal::getHandleIndex(handle);
|
||||
return wpi::hal::getHandleIndex(handle);
|
||||
}
|
||||
|
||||
HAL_Bool HAL_CheckREVPDHModuleNumber(int32_t module) {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "wpi/hal/Errors.h"
|
||||
#include "wpi/hal/handles/IndexedHandleResource.h"
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
static constexpr HAL_CANManufacturer manufacturer =
|
||||
HAL_CANManufacturer::HAL_CAN_Man_kREV;
|
||||
@@ -63,7 +63,7 @@ namespace {
|
||||
struct REV_PHObj {
|
||||
int32_t controlPeriod;
|
||||
PH_set_all_t desiredSolenoidsState;
|
||||
wpi::mutex solenoidLock;
|
||||
wpi::util::mutex solenoidLock;
|
||||
HAL_CANHandle hcan;
|
||||
std::string previousAllocation;
|
||||
HAL_REVPHVersion versionInfo;
|
||||
@@ -74,14 +74,14 @@ struct REV_PHObj {
|
||||
static IndexedHandleResource<HAL_REVPHHandle, REV_PHObj, 63,
|
||||
HAL_HandleEnum::REVPH>* REVPHHandles;
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeREVPH() {
|
||||
static IndexedHandleResource<HAL_REVPHHandle, REV_PHObj, kNumREVPHModules,
|
||||
HAL_HandleEnum::REVPH>
|
||||
rH;
|
||||
REVPHHandles = &rH;
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
static PH_status_0_t HAL_ReadREVPHStatus0(HAL_CANHandle hcan, int32_t* status) {
|
||||
HAL_CANReceiveMessage message;
|
||||
@@ -194,10 +194,10 @@ static HAL_Bool HAL_CheckREVPHPulseTime(int32_t time) {
|
||||
HAL_REVPHHandle HAL_InitializeREVPH(int32_t busId, int32_t module,
|
||||
const char* allocationLocation,
|
||||
int32_t* status) {
|
||||
hal::init::CheckInit();
|
||||
wpi::hal::init::CheckInit();
|
||||
if (!HAL_CheckREVPHModuleNumber(module)) {
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for REV PH", 1,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for REV PH", 1,
|
||||
kNumREVPHModules, module);
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
@@ -207,10 +207,10 @@ HAL_REVPHHandle HAL_InitializeREVPH(int32_t busId, int32_t module,
|
||||
auto hph = REVPHHandles->Allocate(module - 1, &handle, status);
|
||||
if (*status != 0) {
|
||||
if (hph) {
|
||||
hal::SetLastErrorPreviouslyAllocated(status, "REV PH", module,
|
||||
wpi::hal::SetLastErrorPreviouslyAllocated(status, "REV PH", module,
|
||||
hph->previousAllocation);
|
||||
} else {
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for REV PH", 1,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for REV PH", 1,
|
||||
kNumREVPHModules, module);
|
||||
}
|
||||
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
|
||||
@@ -398,7 +398,7 @@ double HAL_GetREVPHAnalogVoltage(HAL_REVPHHandle handle, int32_t channel,
|
||||
|
||||
if (channel < 0 || channel > 1) {
|
||||
*status = PARAMETER_OUT_OF_RANGE;
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid REV Analog Index", 0, 2,
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status, "Invalid REV Analog Index", 0, 2,
|
||||
channel);
|
||||
return 0;
|
||||
}
|
||||
@@ -601,7 +601,7 @@ void HAL_FireREVPHOneShot(HAL_REVPHHandle handle, int32_t index, int32_t durMs,
|
||||
|
||||
if (index >= kNumREVPHChannels || index < 0) {
|
||||
*status = PARAMETER_OUT_OF_RANGE;
|
||||
hal::SetLastError(
|
||||
wpi::hal::SetLastError(
|
||||
status,
|
||||
fmt::format("Only [0-15] are valid index values. Requested {}", index));
|
||||
return;
|
||||
@@ -609,7 +609,7 @@ void HAL_FireREVPHOneShot(HAL_REVPHHandle handle, int32_t index, int32_t durMs,
|
||||
|
||||
if (!HAL_CheckREVPHPulseTime(durMs)) {
|
||||
*status = PARAMETER_OUT_OF_RANGE;
|
||||
hal::SetLastError(
|
||||
wpi::hal::SetLastError(
|
||||
status,
|
||||
fmt::format("Time not within expected range [0-65534]. Requested {}",
|
||||
durMs));
|
||||
|
||||
@@ -24,16 +24,16 @@
|
||||
#include "wpi/hal/handles/HandlesInternal.h"
|
||||
#include "wpi/hal/handles/IndexedHandleResource.h"
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeSerialPort() {}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
using namespace hal;
|
||||
using namespace wpi::hal;
|
||||
|
||||
extern "C" {
|
||||
HAL_SerialPortHandle HAL_InitializeSerialPort(HAL_SerialPort port,
|
||||
int32_t* status) {
|
||||
// hal::init::CheckInit();
|
||||
// wpi::hal::init::CheckInit();
|
||||
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return HAL_kInvalidHandle;
|
||||
|
||||
@@ -46,8 +46,8 @@ void HAL_SetSimValue(HAL_SimValueHandle handle, const struct HAL_Value* value) {
|
||||
|
||||
void HAL_ResetSimValue(HAL_SimValueHandle handle) {}
|
||||
|
||||
hal::SimDevice::SimDevice(const char* name, int index) {}
|
||||
wpi::hal::SimDevice::SimDevice(const char* name, int index) {}
|
||||
|
||||
hal::SimDevice::SimDevice(const char* name, int index, int channel) {}
|
||||
wpi::hal::SimDevice::SimDevice(const char* name, int index, int channel) {}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
#include "wpi/hal/AddressableLEDTypes.h"
|
||||
#include "wpi/hal/Errors.h"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
|
||||
wpi::mutex smartIoMutex;
|
||||
wpi::util::mutex smartIoMutex;
|
||||
DigitalHandleResource<HAL_DigitalHandle, SmartIo, kNumSmartIo>* smartIoHandles;
|
||||
|
||||
namespace init {
|
||||
@@ -24,9 +24,9 @@ void InitializeSmartIo() {
|
||||
} // namespace init
|
||||
|
||||
int32_t SmartIo::InitializeMode(SmartIoMode mode) {
|
||||
auto inst = hal::GetSystemServer();
|
||||
auto inst = wpi::hal::GetSystemServer();
|
||||
|
||||
nt::PubSubOptions options;
|
||||
wpi::nt::PubSubOptions options;
|
||||
options.sendAll = true;
|
||||
options.keepDuplicates = true;
|
||||
options.periodic = 0.005;
|
||||
@@ -221,4 +221,4 @@ int32_t SmartIo::SetLedLength(int32_t length) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "wpi/hal/handles/HandlesInternal.h"
|
||||
#include "wpi/nt/IntegerTopic.hpp"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
|
||||
constexpr int32_t kPwmDisabled = 0;
|
||||
constexpr int32_t kPwmAlwaysHigh = 0xFFFF;
|
||||
@@ -38,16 +38,16 @@ struct SmartIo {
|
||||
uint8_t channel;
|
||||
std::string previousAllocation;
|
||||
SmartIoMode currentMode{SmartIoMode::DigitalInput};
|
||||
nt::IntegerPublisher modePublisher;
|
||||
wpi::nt::IntegerPublisher modePublisher;
|
||||
|
||||
nt::IntegerPublisher setPublisher;
|
||||
nt::IntegerSubscriber getSubscriber;
|
||||
wpi::nt::IntegerPublisher setPublisher;
|
||||
wpi::nt::IntegerSubscriber getSubscriber;
|
||||
|
||||
nt::IntegerPublisher periodSetPublisher;
|
||||
nt::IntegerSubscriber periodGetSubscriber;
|
||||
wpi::nt::IntegerPublisher periodSetPublisher;
|
||||
wpi::nt::IntegerSubscriber periodGetSubscriber;
|
||||
|
||||
nt::IntegerPublisher ledcountPublisher;
|
||||
nt::IntegerPublisher ledoffsetPublisher;
|
||||
wpi::nt::IntegerPublisher ledcountPublisher;
|
||||
wpi::nt::IntegerPublisher ledoffsetPublisher;
|
||||
|
||||
int32_t InitializeMode(SmartIoMode mode);
|
||||
int32_t SwitchDioDirection(bool input);
|
||||
@@ -74,6 +74,6 @@ struct SmartIo {
|
||||
extern DigitalHandleResource<HAL_DigitalHandle, SmartIo, kNumSmartIo>*
|
||||
smartIoHandles;
|
||||
|
||||
extern wpi::mutex smartIoMutex;
|
||||
extern wpi::util::mutex smartIoMutex;
|
||||
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -7,15 +7,15 @@
|
||||
#include "SystemServerInternal.h"
|
||||
#include "mrc/NtNetComm.h"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
|
||||
static nt::NetworkTableInstance ServerInstance;
|
||||
static wpi::nt::NetworkTableInstance ServerInstance;
|
||||
|
||||
void InitializeSystemServer() {
|
||||
if (ServerInstance) {
|
||||
return;
|
||||
}
|
||||
ServerInstance = nt::NetworkTableInstance::Create();
|
||||
ServerInstance = wpi::nt::NetworkTableInstance::Create();
|
||||
ServerInstance.SetServer("localhost", ROBOT_SYSTEM_SERVER_NT_PORT);
|
||||
ServerInstance.StartClient("RobotProgram");
|
||||
}
|
||||
@@ -26,18 +26,18 @@ void ShutdownSystemServer() {
|
||||
}
|
||||
|
||||
ServerInstance.StopClient();
|
||||
nt::NetworkTableInstance::Destroy(ServerInstance);
|
||||
wpi::nt::NetworkTableInstance::Destroy(ServerInstance);
|
||||
}
|
||||
|
||||
nt::NetworkTableInstance GetSystemServer() {
|
||||
wpi::nt::NetworkTableInstance GetSystemServer() {
|
||||
return ServerInstance;
|
||||
}
|
||||
|
||||
} // namespace hal
|
||||
} // namespace wpi::hal
|
||||
|
||||
extern "C" {
|
||||
|
||||
NT_Inst HAL_GetSystemServerHandle(void) {
|
||||
return hal::ServerInstance.GetHandle();
|
||||
return wpi::hal::ServerInstance.GetHandle();
|
||||
}
|
||||
} // extern "C"
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
#include "wpi/nt/NetworkTableInstance.hpp"
|
||||
|
||||
namespace hal {
|
||||
namespace wpi::hal {
|
||||
void InitializeSystemServer();
|
||||
void ShutdownSystemServer();
|
||||
nt::NetworkTableInstance GetSystemServer();
|
||||
} // namespace hal
|
||||
wpi::nt::NetworkTableInstance GetSystemServer();
|
||||
} // namespace wpi::hal
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
|
||||
#include "wpi/hal/Errors.h"
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeThreads() {}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
|
||||
namespace {
|
||||
struct SystemServerUsageReporting {
|
||||
nt::NetworkTableInstance ntInst;
|
||||
wpi::StringMap<nt::StringPublisher> publishers;
|
||||
wpi::nt::NetworkTableInstance ntInst;
|
||||
wpi::util::StringMap<wpi::nt::StringPublisher> publishers;
|
||||
|
||||
explicit SystemServerUsageReporting(nt::NetworkTableInstance inst)
|
||||
explicit SystemServerUsageReporting(wpi::nt::NetworkTableInstance inst)
|
||||
: ntInst{inst} {}
|
||||
};
|
||||
|
||||
@@ -29,7 +29,7 @@ extern "C" {
|
||||
|
||||
int32_t HAL_ReportUsage(const struct WPI_String* resource,
|
||||
const struct WPI_String* data) {
|
||||
auto resourceStr = wpi::to_string_view(resource);
|
||||
auto resourceStr = wpi::util::to_string_view(resource);
|
||||
auto& publisher = systemServerUsage->publishers[resourceStr];
|
||||
if (!publisher) {
|
||||
publisher =
|
||||
@@ -37,15 +37,15 @@ int32_t HAL_ReportUsage(const struct WPI_String* resource,
|
||||
.GetStringTopic(fmt::format("/UsageReporting/{}", resourceStr))
|
||||
.Publish();
|
||||
}
|
||||
publisher.Set(wpi::to_string_view(data));
|
||||
publisher.Set(wpi::util::to_string_view(data));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
namespace hal::init {
|
||||
namespace wpi::hal::init {
|
||||
void InitializeUsageReporting() {
|
||||
systemServerUsage = new ::SystemServerUsageReporting{hal::GetSystemServer()};
|
||||
systemServerUsage = new ::SystemServerUsageReporting{wpi::hal::GetSystemServer()};
|
||||
}
|
||||
} // namespace hal::init
|
||||
} // namespace wpi::hal::init
|
||||
|
||||
Reference in New Issue
Block a user