Add function remove last bcm frame 46/22246/3
authorArthur Guyader <arthur.guyader@iot.bzh>
Wed, 14 Aug 2019 11:22:15 +0000 (13:22 +0200)
committerArthur Guyader <arthur.guyader@iot.bzh>
Fri, 30 Aug 2019 09:46:04 +0000 (11:46 +0200)
This commit creates the function remove_last_bcm_frame.
This function removes the last bcm frame of the subscription.

Bug-AGL : SPEC-2779

Change-Id: I5bb6f07a8d677c4aa882549fc1950f00a0b1da04
Signed-off-by: Arthur Guyader <arthur.guyader@iot.bzh>
low-can-binding/binding/low-can-subscription.cpp
low-can-binding/binding/low-can-subscription.hpp

index a1187ed..bec3ad6 100644 (file)
@@ -353,6 +353,17 @@ void low_can_subscription_t::add_one_bcm_frame(struct canfd_frame& cfd, struct b
        bcm_msg.msg_head.nframes++;
 }
 
+/// @brief Take an existing bcm_msg struct and add a can_frame.
+/// Currently only 1 uniq can_frame can be added, it's not possible to build
+/// a multiplexed message with several can_frame.
+void low_can_subscription_t::remove_last_bcm_frame(struct bcm_msg& bcm_msg)
+{
+       struct canfd_frame cf;
+       memset(&cf,0,sizeof(cf));
+       bcm_msg.fd_frames[bcm_msg.msg_head.nframes] = cf;
+       bcm_msg.msg_head.nframes--;
+}
+
 #ifdef USE_FEATURE_J1939
 int low_can_subscription_t::create_rx_filter_j1939(low_can_subscription_t &subscription, std::shared_ptr<signal_t> sig)
 {
index d0462ec..b5d4f7a 100644 (file)
@@ -93,6 +93,7 @@ public:
 
        static struct bcm_msg make_bcm_head(uint32_t opcode, uint32_t can_id = 0, uint32_t flags = 0, const struct timeval& timeout = {0,0}, const struct timeval& frequency_thinning = {0,0});
        static void add_one_bcm_frame(struct canfd_frame& cfd, struct bcm_msg& bcm_msg);
+       static void remove_last_bcm_frame(struct bcm_msg& bcm_msg);
 
        static int open_socket(low_can_subscription_t &subscription, const std::string& bus_name = "", socket_type type = socket_type::INVALID);