mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
Added callbacks for CAN (#757)
Added callback scheme for a pass through to something higher level. Since the ID is embedded into the arbitration ID, and some devices can use different schemes whether it is plugged in through a device or put into the daisy chain (pigeonImu), I made one "internal data object" for max reusability.
This commit is contained in:
committed by
Peter Johnson
parent
0431cf97ff
commit
12c4418bda
@@ -9,29 +9,6 @@
|
||||
|
||||
using namespace hal;
|
||||
|
||||
template <typename VectorType, typename CallbackType>
|
||||
std::shared_ptr<VectorType> RegisterCallbackImpl(
|
||||
std::shared_ptr<VectorType> currentVector, const char* name,
|
||||
CallbackType callback, void* param, int32_t* newUid) {
|
||||
std::shared_ptr<VectorType> newCallbacks;
|
||||
if (currentVector == nullptr) {
|
||||
newCallbacks = std::make_shared<VectorType>(
|
||||
param, callback, reinterpret_cast<unsigned int*>(newUid));
|
||||
} else {
|
||||
newCallbacks = currentVector->emplace_back(
|
||||
param, callback, reinterpret_cast<unsigned int*>(newUid));
|
||||
}
|
||||
return newCallbacks;
|
||||
}
|
||||
|
||||
template <typename VectorType, typename CallbackType>
|
||||
std::shared_ptr<VectorType> CancelCallbackImpl(
|
||||
std::shared_ptr<VectorType> currentVector, int32_t uid) {
|
||||
// Create a copy of the callbacks to erase from
|
||||
auto newCallbacks = currentVector->erase(uid);
|
||||
return newCallbacks;
|
||||
}
|
||||
|
||||
std::shared_ptr<NotifyListenerVector> RegisterCallback(
|
||||
std::shared_ptr<NotifyListenerVector> currentVector, const char* name,
|
||||
HAL_NotifyCallback callback, void* param, int32_t* newUid) {
|
||||
|
||||
Reference in New Issue
Block a user