diff --git a/.sonarcloud.properties b/.sonarcloud.properties index 2a0c4e7..be25f71 100644 --- a/.sonarcloud.properties +++ b/.sonarcloud.properties @@ -1 +1 @@ -sonar.sources=Cyphal,Udral,ds015,examples +sonar.sources=Cyphal,Udral,ds015,zubax,examples diff --git a/Udral/actuator.cpp b/Udral/actuator.cpp index 3530d61..ae3fb60 100644 --- a/Udral/actuator.cpp +++ b/Udral/actuator.cpp @@ -75,8 +75,4 @@ void ReadinessSubscriber::callback(const CanardRxTransfer& transfer) { _last_recv_time_ms = HAL_GetTick(); } -void ZubaxCompactFeedbackPublisher::publish(const ZubaxCompactFeedback& msg) { - push(zubax_telega_CompactFeedback_0_1_SERIALIZATION_BUFFER_SIZE_BYTES, (const uint8_t*)&msg); -} - } // namespace cyphal diff --git a/Udral/actuator.hpp b/Udral/actuator.hpp index 67ec035..4163a82 100644 --- a/Udral/actuator.hpp +++ b/Udral/actuator.hpp @@ -37,26 +37,6 @@ struct ReadinessSubscriber: public CyphalSubscriber { uint32_t _last_recv_time_ms{0}; }; - -// https://telega.zubax.com/interfaces/cyphal.html#compact -#pragma pack(push, 1) -struct ZubaxCompactFeedback { - uint32_t dc_voltage : 11; - int32_t dc_current : 12; - int32_t phase_current_amplitude : 12; - int32_t velocity : 13; - int8_t demand_factor_pct : 8; -}; -#pragma pack(pop) - -struct ZubaxCompactFeedbackPublisher: public CyphalPublisher { - ZubaxCompactFeedbackPublisher(Cyphal* driver_, CanardPortID port_id) : CyphalPublisher(driver_, port_id) {}; - void publish(const ZubaxCompactFeedback& msg); - static constexpr float RPM_TO_RAD_PER_SEC = 0.1047198; -private: - static constexpr size_t zubax_telega_CompactFeedback_0_1_SERIALIZATION_BUFFER_SIZE_BYTES = 7; -}; - } // namespace cyphal #endif // UDRAL_ACTUATOR_HPP_ diff --git a/sonar-project.properties b/sonar-project.properties index 86dcee0..7080be4 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,6 +1,6 @@ sonar.projectKey=RaccoonlabDev_cyphal_application sonar.organization=raccoonlabdev -sonar.sources=Cyphal,Udral,ds015,examples +sonar.sources=Cyphal,Udral,ds015,zubax,examples sonar.cfamily.build-wrapper-output=bw-output sonar.host.url=https://sonarcloud.io sonar.cfamily.gcov.reportsPath=build diff --git a/zubax/compact_feedback.cpp b/zubax/compact_feedback.cpp new file mode 100644 index 0000000..557b6c0 --- /dev/null +++ b/zubax/compact_feedback.cpp @@ -0,0 +1,15 @@ +/// This software is distributed under the terms of the MIT License. +/// Copyright (c) 2024 Dmitry Ponomarev. +/// Author: Dmitry Ponomarev + +#include "compact_feedback.hpp" +#include "main.h" +#include "params.hpp" + +namespace zubax::telega { + +void CompactFeedbackPublisher::publish(const CompactFeedback& msg) { + push(zubax_telega_CompactFeedback_0_1_SERIALIZATION_BUFFER_SIZE_BYTES, (const uint8_t*)&msg); +} + +} // namespace zubax::telega diff --git a/zubax/compact_feedback.hpp b/zubax/compact_feedback.hpp new file mode 100644 index 0000000..b1d2798 --- /dev/null +++ b/zubax/compact_feedback.hpp @@ -0,0 +1,34 @@ +/// This software is distributed under the terms of the MIT License. +/// Copyright (c) 2023 Dmitry Ponomarev. +/// Author: Dmitry Ponomarev + +#ifndef ZUBAX_COMPACT_FEEDBACK_HPP_ +#define ZUBAX_COMPACT_FEEDBACK_HPP_ + +#include "cyphal.hpp" +#include "cyphal_publishers.hpp" + +namespace zubax::telega { + +// https://telega.zubax.com/interfaces/cyphal.html#compact +#pragma pack(push, 1) +struct CompactFeedback { + uint32_t dc_voltage : 11; + int32_t dc_current : 12; + int32_t phase_current_amplitude : 12; + int32_t velocity : 13; + int8_t demand_factor_pct : 8; +}; +#pragma pack(pop) + +struct CompactFeedbackPublisher: public cyphal::CyphalPublisher { + CompactFeedbackPublisher() : cyphal::CyphalPublisher(cyphal::Cyphal::get_instance(), 65535) { } + void publish(const CompactFeedback& msg); + static constexpr float RPM_TO_RAD_PER_SEC = 0.1047198; +private: + static constexpr size_t zubax_telega_CompactFeedback_0_1_SERIALIZATION_BUFFER_SIZE_BYTES = 7; +}; + +} // namespace zubax::telega + +#endif // ZUBAX_COMPACT_FEEDBACK_HPP_