summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2019-11-26 16:19:33 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2019-11-28 16:11:47 +0100
commita8d5f5d3018da0b051dad4c143c6257b2fba9fac (patch)
tree787ee734c284a12be75425bbb9497cf667f022e1
parent55f18708334f0c9904c8e3896251399f7d6b2dd1 (diff)
Update function tx_send for multi frame prevision
Bug-AGL : SPEC-2779 Bug-AGL: SPEC-2976 Change-Id: Ib0b04fe3648c5b83c23327431e21161b6b2489b6 Signed-off-by: Arthur Guyader <arthur.guyader@iot.bzh> Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r--low-can-binding/binding/low-can-subscription.cpp37
1 files changed, 30 insertions, 7 deletions
diff --git a/low-can-binding/binding/low-can-subscription.cpp b/low-can-binding/binding/low-can-subscription.cpp
index d4ada3fe..edc0a0b4 100644
--- a/low-can-binding/binding/low-can-subscription.cpp
+++ b/low-can-binding/binding/low-can-subscription.cpp
@@ -20,6 +20,8 @@
#include "application.hpp"
#include "canutil/write.h"
#include "../utils/socketcan-bcm.hpp"
+#include "../can/can-encoder.hpp"
+
#ifdef USE_FEATURE_J1939
#include "../utils/socketcan-j1939/socketcan-j1939-data.hpp"
#endif
@@ -535,20 +537,41 @@ int low_can_subscription_t::tx_send(low_can_subscription_t &subscription, messag
{
can_message_t *cm = static_cast<can_message_t*>(message);
- struct bcm_msg bcm_msg = subscription.make_bcm_head(TX_SEND, cm->get_id(),cm->get_flags() | TX_CP_CAN_ID); // TX_CP_CAN_ID -> copy in cfd the id of bcm
+ struct bcm_msg bcm_msg = subscription.make_bcm_head(TX_SEND, cm->get_id(),cm->get_flags()|TX_CP_CAN_ID); // TX_CP_CAN_ID -> copy in cfd the id of bcm
+ cm->set_bcm_msg(bcm_msg);
+
std::vector<canfd_frame> cfd_vect = cm->convert_to_canfd_frame_vector();
- for(auto cfd: cfd_vect)
+
+ if(subscription.open_socket(subscription, bus_name,socket_type::BCM) < 0)
{
- subscription.add_one_bcm_frame(cfd, bcm_msg);
+ return -1;
}
- if(subscription.open_socket(subscription, bus_name,socket_type::BCM) < 0)
+ struct bcm_msg &bcm_cm = cm->get_bcm_msg();
+
+
+
+ if(cfd_vect.size() > 1)
{
+ AFB_ERROR("Multi frame BCM not implemented");
+ return -1;
+ }
+ else if(cfd_vect.size() == 1) // raw or fd
+ {
+ subscription.add_one_bcm_frame(cfd_vect[0], bcm_cm);
+
+ if(subscription.socket_->write_message(*cm) < 0)
+ {
+ AFB_ERROR("Error write message id : %d",cfd_vect[0].can_id);
return -1;
+ }
+ }
+ else // error
+ {
+ AFB_ERROR("Error no data available");
+ return -1;
}
- cm->set_bcm_msg(bcm_msg);
- subscription.socket_->write_message(*cm);
if(! subscription.socket_.get())
{
return -1;
@@ -578,4 +601,4 @@ int low_can_subscription_t::j1939_send(low_can_subscription_t &subscription, mes
return 0;
}
-#endif \ No newline at end of file
+#endif