Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions kocherga/kocherga_can.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,23 @@
#include <algorithm>
#include <variant>


#ifndef DRONECAN_DNA_ENABLE
#define DRONECAN_DNA_ENABLE 1
#endif

#ifndef CYPHAL_CAN_DNA_ENABLE
#define CYPHAL_CAN_DNA_ENABLE 1
#endif

#ifndef VERSION_DETECTION_ENABLE
#define VERSION_DETECTION_ENABLE 1
#endif

#ifndef BITRATE_DETECTION_ENABLE
#define BITRATE_DETECTION_ENABLE 1
#endif

namespace kocherga::can
{
static constexpr std::uint8_t MaxNodeID = 127U;
Expand Down Expand Up @@ -2199,6 +2216,8 @@ class CANNode : public kocherga::INode
static_cast<std::uint8_t>(*local_node_id));
}
}

#if DRONECAN_DNA_ENABLE
if ((activity_ == nullptr) && can_bitrate && protocol_version && (*protocol_version == 0))
{
if (const auto bus_mode = driver.configure(*can_bitrate, false, detail::makeAcceptanceFilter<0>({})))
Expand All @@ -2210,6 +2229,9 @@ class CANNode : public kocherga::INode
*can_bitrate);
}
}
#endif // DRONECAN_DNA_ENABLE

#if CYPHAL_CAN_DNA_ENABLE
if ((activity_ == nullptr) && can_bitrate && protocol_version && (*protocol_version == 1))
{
if (const auto bus_mode = driver.configure(*can_bitrate, false, detail::makeAcceptanceFilter<1>({})))
Expand All @@ -2221,6 +2243,9 @@ class CANNode : public kocherga::INode
*bus_mode);
}
}
#endif // CYPHAL_CAN_DNA_ENABLE

#if VERSION_DETECTION_ENABLE
if ((activity_ == nullptr) && can_bitrate)
{
if (const auto bus_mode =
Expand All @@ -2233,12 +2258,16 @@ class CANNode : public kocherga::INode
*can_bitrate);
}
}
#endif // VERSION_DETECTION_ENABLE

#if BITRATE_DETECTION_ENABLE
if (activity_ == nullptr)
{
activity_ = activity_allocator_.construct<detail::BitrateDetectionActivity>(activity_allocator_,
driver,
local_unique_id);
}
#endif // BITRATE_DETECTION_ENABLE
KOCHERGA_ASSERT(activity_ != nullptr);
}

Expand Down
Loading