Skip to content

Commit

Permalink
canard++: un-inline handler list methods
Browse files Browse the repository at this point in the history
Mitigates flash impact of semaphore changes.
  • Loading branch information
tpwrules authored and tridge committed Mar 4, 2025
1 parent 19ea632 commit 9b05a4d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions canard/service_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Client : public HandlerList, public Sender {
/// @brief Client constructor
/// @param _interface Interface object
/// @param _cb Callback object
Client(Interface &_interface, Callback<rsptype> &_cb) :
Client(Interface &_interface, Callback<rsptype> &_cb) NOINLINE_FUNC :
HandlerList(CanardTransferTypeResponse, rsptype::cxx_iface::ID, rsptype::cxx_iface::SIGNATURE, _interface.get_index()),
Sender(_interface),
server_node_id(255),
Expand All @@ -53,7 +53,7 @@ class Client : public HandlerList, public Sender {
Client(const Client&) = delete;

// destructor, remove the entry from the singly-linked list
~Client() {
~Client() NOINLINE_FUNC {
#ifdef WITH_SEMAPHORE
WITH_SEMAPHORE(sem[index]);
#endif
Expand All @@ -74,7 +74,7 @@ class Client : public HandlerList, public Sender {

/// @brief handles incoming messages
/// @param transfer transfer object of the request
void handle_message(const CanardRxTransfer& transfer) override {
void handle_message(const CanardRxTransfer& transfer) override NOINLINE_FUNC {
rsptype msg {};
if (rsptype::cxx_iface::rsp_decode(&transfer, &msg)) {
// invalid decode
Expand Down Expand Up @@ -106,7 +106,7 @@ class Client : public HandlerList, public Sender {
/// @param msg message containing the request
/// @param canfd true if CAN FD is to be used
/// @return true if the request was put into the queue successfully
bool request(uint8_t destination_node_id, typename rsptype::cxx_iface::reqtype& msg, bool canfd) {
bool request(uint8_t destination_node_id, typename rsptype::cxx_iface::reqtype& msg, bool canfd) NOINLINE_FUNC {
#if !CANARD_ENABLE_CANFD
if (canfd) {
return false;
Expand Down
8 changes: 4 additions & 4 deletions canard/service_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Server : public HandlerList {
/// @param _interface Interface object
/// @param _cb Callback object
/// @param _index HandlerList instance id
Server(Interface &_interface, Callback<reqtype> &_cb) :
Server(Interface &_interface, Callback<reqtype> &_cb) NOINLINE_FUNC :
HandlerList(CanardTransferTypeRequest, reqtype::cxx_iface::ID, reqtype::cxx_iface::SIGNATURE, _interface.get_index()),
interface(_interface),
cb(_cb) {
Expand All @@ -50,7 +50,7 @@ class Server : public HandlerList {
// delete copy constructor and assignment operator
Server(const Server&) = delete;

~Server() {
~Server() NOINLINE_FUNC {
#ifdef WITH_SEMAPHORE
WITH_SEMAPHORE(sem[index]);
#endif
Expand All @@ -59,7 +59,7 @@ class Server : public HandlerList {

/// @brief handles incoming messages
/// @param transfer transfer object of the request
void handle_message(const CanardRxTransfer& transfer) override {
void handle_message(const CanardRxTransfer& transfer) override NOINLINE_FUNC {
reqtype msg {};
if (reqtype::cxx_iface::req_decode(&transfer, &msg)) {
// invalid decode
Expand All @@ -74,7 +74,7 @@ class Server : public HandlerList {
/// @param transfer transfer object of the request
/// @param msg message containing the response
/// @return true if the response was put into the queue successfully
bool respond(const CanardRxTransfer& transfer, typename reqtype::cxx_iface::rsptype& msg) {
bool respond(const CanardRxTransfer& transfer, typename reqtype::cxx_iface::rsptype& msg) NOINLINE_FUNC {
// encode the message
uint32_t len = reqtype::cxx_iface::rsp_encode(&msg, rsp_buf
#if CANARD_ENABLE_CANFD
Expand Down
6 changes: 3 additions & 3 deletions canard/subscriber.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Subscriber : public HandlerList {
/// @brief Subscriber Constructor
/// @param _cb callback function
/// @param _index HandlerList instance id
Subscriber(Callback<msgtype> &_cb, uint8_t _index) :
Subscriber(Callback<msgtype> &_cb, uint8_t _index) NOINLINE_FUNC :
HandlerList(CanardTransferTypeBroadcast, msgtype::cxx_iface::ID, msgtype::cxx_iface::SIGNATURE, _index),
cb (_cb) {
#ifdef WITH_SEMAPHORE
Expand All @@ -53,7 +53,7 @@ class Subscriber : public HandlerList {
Subscriber(const Subscriber&) = delete;

// destructor, remove the entry from the singly-linked list
~Subscriber() {
~Subscriber() NOINLINE_FUNC {
#ifdef WITH_SEMAPHORE
WITH_SEMAPHORE(sem[index]);
#endif
Expand All @@ -74,7 +74,7 @@ class Subscriber : public HandlerList {

/// @brief parse the message and call the callback
/// @param transfer transfer object
void handle_message(const CanardRxTransfer& transfer) override {
void handle_message(const CanardRxTransfer& transfer) override NOINLINE_FUNC {
msgtype msg {};
if (msgtype::cxx_iface::decode(&transfer, &msg)) {
// invalid decode
Expand Down

0 comments on commit 9b05a4d

Please sign in to comment.