summaryrefslogtreecommitdiffstats
path: root/low-can-binding/binding
diff options
context:
space:
mode:
authorArthur Guyader <arthur.guyader@iot.bzh>2019-08-26 15:46:08 +0200
committerArthur Guyader <arthur.guyader@iot.bzh>2019-08-30 11:49:29 +0200
commit62083285cdaaab054e940013bc1c20cb4959327f (patch)
treed8fcbaa41c16ac0ff7b14b0af3f26088b7c88d1a /low-can-binding/binding
parent7656fad53bc48189dc62809e3f5351f873ea9b88 (diff)
Update function tx_send for multi frame prevision
Bug-AGL : SPEC-2779 Change-Id: Ib0b04fe3648c5b83c23327431e21161b6b2489b6 Signed-off-by: Arthur Guyader <arthur.guyader@iot.bzh>
Diffstat (limited to 'low-can-binding/binding')
-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