[hal] Add low level support for Motioncore CAN buses (#8707)

This way vendors can easily access them.
This commit is contained in:
Thad House
2026-03-29 20:42:25 -07:00
committed by GitHub
parent db42c6cbba
commit 3e821b9448
2 changed files with 16 additions and 2 deletions

View File

@@ -166,7 +166,14 @@ bool SocketCanState::InitializeBuses() {
}
ifreq ifr;
std::snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "can_s%d", i);
if (i < 5) {
std::snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "can_s%u",
static_cast<unsigned>(i));
} else {
std::snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "can_d%u",
static_cast<unsigned>(i - 5));
}
if (ioctl(socketHandle[i], SIOCGIFINDEX, &ifr) == -1) {
wpi::util::print("ioctl(SIOCGIFINDEX) for CAN {} failed with {}\n",
@@ -336,6 +343,13 @@ void HAL_CAN_SendMessage(int32_t busId, uint32_t messageId,
return;
}
if (busId >= 5 &&
((message->flags & HAL_CANFlags::HAL_CAN_FD_DATALENGTH) ||
(message->flags & HAL_CANFlags::HAL_CAN_FD_BITRATESWITCH))) {
*status = PARAMETER_OUT_OF_RANGE;
return;
}
messageId = MapMessageIdToSocketCan(messageId);
// TODO determine on the real roborio is a non periodic send removes any

View File

@@ -8,7 +8,7 @@
namespace wpi::hal {
constexpr int32_t kNumCanBuses = 5;
constexpr int32_t kNumCanBuses = 25;
constexpr int32_t kNumSmartIo = 6;
constexpr int32_t kNumI2cBuses = 2;
constexpr int32_t kNumAccumulators = 0;