Skip to content

Commit 9b05a4d

Browse files
tpwrulestridge
authored andcommitted
canard++: un-inline handler list methods
Mitigates flash impact of semaphore changes.
1 parent 19ea632 commit 9b05a4d

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

canard/service_client.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Client : public HandlerList, public Sender {
3636
/// @brief Client constructor
3737
/// @param _interface Interface object
3838
/// @param _cb Callback object
39-
Client(Interface &_interface, Callback<rsptype> &_cb) :
39+
Client(Interface &_interface, Callback<rsptype> &_cb) NOINLINE_FUNC :
4040
HandlerList(CanardTransferTypeResponse, rsptype::cxx_iface::ID, rsptype::cxx_iface::SIGNATURE, _interface.get_index()),
4141
Sender(_interface),
4242
server_node_id(255),
@@ -53,7 +53,7 @@ class Client : public HandlerList, public Sender {
5353
Client(const Client&) = delete;
5454

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

7575
/// @brief handles incoming messages
7676
/// @param transfer transfer object of the request
77-
void handle_message(const CanardRxTransfer& transfer) override {
77+
void handle_message(const CanardRxTransfer& transfer) override NOINLINE_FUNC {
7878
rsptype msg {};
7979
if (rsptype::cxx_iface::rsp_decode(&transfer, &msg)) {
8080
// invalid decode
@@ -106,7 +106,7 @@ class Client : public HandlerList, public Sender {
106106
/// @param msg message containing the request
107107
/// @param canfd true if CAN FD is to be used
108108
/// @return true if the request was put into the queue successfully
109-
bool request(uint8_t destination_node_id, typename rsptype::cxx_iface::reqtype& msg, bool canfd) {
109+
bool request(uint8_t destination_node_id, typename rsptype::cxx_iface::reqtype& msg, bool canfd) NOINLINE_FUNC {
110110
#if !CANARD_ENABLE_CANFD
111111
if (canfd) {
112112
return false;

canard/service_server.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Server : public HandlerList {
3737
/// @param _interface Interface object
3838
/// @param _cb Callback object
3939
/// @param _index HandlerList instance id
40-
Server(Interface &_interface, Callback<reqtype> &_cb) :
40+
Server(Interface &_interface, Callback<reqtype> &_cb) NOINLINE_FUNC :
4141
HandlerList(CanardTransferTypeRequest, reqtype::cxx_iface::ID, reqtype::cxx_iface::SIGNATURE, _interface.get_index()),
4242
interface(_interface),
4343
cb(_cb) {
@@ -50,7 +50,7 @@ class Server : public HandlerList {
5050
// delete copy constructor and assignment operator
5151
Server(const Server&) = delete;
5252

53-
~Server() {
53+
~Server() NOINLINE_FUNC {
5454
#ifdef WITH_SEMAPHORE
5555
WITH_SEMAPHORE(sem[index]);
5656
#endif
@@ -59,7 +59,7 @@ class Server : public HandlerList {
5959

6060
/// @brief handles incoming messages
6161
/// @param transfer transfer object of the request
62-
void handle_message(const CanardRxTransfer& transfer) override {
62+
void handle_message(const CanardRxTransfer& transfer) override NOINLINE_FUNC {
6363
reqtype msg {};
6464
if (reqtype::cxx_iface::req_decode(&transfer, &msg)) {
6565
// invalid decode
@@ -74,7 +74,7 @@ class Server : public HandlerList {
7474
/// @param transfer transfer object of the request
7575
/// @param msg message containing the response
7676
/// @return true if the response was put into the queue successfully
77-
bool respond(const CanardRxTransfer& transfer, typename reqtype::cxx_iface::rsptype& msg) {
77+
bool respond(const CanardRxTransfer& transfer, typename reqtype::cxx_iface::rsptype& msg) NOINLINE_FUNC {
7878
// encode the message
7979
uint32_t len = reqtype::cxx_iface::rsp_encode(&msg, rsp_buf
8080
#if CANARD_ENABLE_CANFD

canard/subscriber.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Subscriber : public HandlerList {
3838
/// @brief Subscriber Constructor
3939
/// @param _cb callback function
4040
/// @param _index HandlerList instance id
41-
Subscriber(Callback<msgtype> &_cb, uint8_t _index) :
41+
Subscriber(Callback<msgtype> &_cb, uint8_t _index) NOINLINE_FUNC :
4242
HandlerList(CanardTransferTypeBroadcast, msgtype::cxx_iface::ID, msgtype::cxx_iface::SIGNATURE, _index),
4343
cb (_cb) {
4444
#ifdef WITH_SEMAPHORE
@@ -53,7 +53,7 @@ class Subscriber : public HandlerList {
5353
Subscriber(const Subscriber&) = delete;
5454

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

7575
/// @brief parse the message and call the callback
7676
/// @param transfer transfer object
77-
void handle_message(const CanardRxTransfer& transfer) override {
77+
void handle_message(const CanardRxTransfer& transfer) override NOINLINE_FUNC {
7878
msgtype msg {};
7979
if (msgtype::cxx_iface::decode(&transfer, &msg)) {
8080
// invalid decode

0 commit comments

Comments
 (0)