mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[hal] Add low level support for Motioncore CAN buses (#8707)
This way vendors can easily access them.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user