summaryrefslogtreecommitdiffstats
path: root/low-can-binding/binding
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2019-11-26 16:19:26 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2019-11-28 16:11:47 +0100
commita41ee0d8149e69451e9cc1d622dfd84cbb1e7651 (patch)
tree4f3ccae3f8b96072c833f200499baf84bf425619 /low-can-binding/binding
parentd4e4f4a23fefe8df109b990bd59396b527d3d31b (diff)
Update function rx_filter_can for multi frame prevision.
This commit updates the functions rx_filter_can to anticipate the development of the multi-frame. Bug-AGL : SPEC-2779 Bug-AGL: SPEC-2976 Change-Id: I5f67cf84e5d3e47c75c588f8776ead92eb6c3c8e Signed-off-by: Arthur Guyader <arthur.guyader@iot.bzh> Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'low-can-binding/binding')
-rw-r--r--low-can-binding/binding/low-can-cb.cpp2
-rw-r--r--low-can-binding/binding/low-can-subscription.cpp56
2 files changed, 46 insertions, 12 deletions
diff --git a/low-can-binding/binding/low-can-cb.cpp b/low-can-binding/binding/low-can-cb.cpp
index 737a851a..f3fe7c83 100644
--- a/low-can-binding/binding/low-can-cb.cpp
+++ b/low-can-binding/binding/low-can-cb.cpp
@@ -606,7 +606,7 @@ static void write_frame(afb_req_t request, const std::string& bus_name, json_obj
"can_dlc", &length,
"can_data", &can_data))
{
- message = new can_message_t(CANFD_MAX_DLEN,(uint32_t)id,(uint32_t)length,message_format_t::STANDARD,false,0,data,0);
+ message = new can_message_t(0,(uint32_t)id,(uint32_t)length,message_format_t::STANDARD,false,0,data,0);
write_raw_frame(request,bus_name,message,can_data,socket_type::BCM);
}
#ifdef USE_FEATURE_J1939
diff --git a/low-can-binding/binding/low-can-subscription.cpp b/low-can-binding/binding/low-can-subscription.cpp
index bec3ad63..d4ada3fe 100644
--- a/low-can-binding/binding/low-can-subscription.cpp
+++ b/low-can-binding/binding/low-can-subscription.cpp
@@ -331,6 +331,7 @@ struct bcm_msg low_can_subscription_t::make_bcm_head(uint32_t opcode, uint32_t c
bcm_msg.msg_head.ival2.tv_sec = frequency_thinning.tv_sec ;
bcm_msg.msg_head.ival2.tv_usec = frequency_thinning.tv_usec;
+
return bcm_msg;
}
@@ -389,32 +390,65 @@ int low_can_subscription_t::create_rx_filter_can(low_can_subscription_t &subscri
struct timeval freq, timeout = {0, 0};
struct canfd_frame cfd;
subscription.signal_= sig;
+ bool is_fd = sig->get_message()->is_fd();
+
+ std::vector<uint8_t> data;
+ uint32_t length_msg = sig->get_message()->get_length();
- if (sig->get_message()->is_fd())
+ if(length_msg == 0)
+ {
+ AFB_ERROR("Error in the length of message with id %d",sig->get_message()->get_id());
+ return -1;
+ }
+
+ for(int i = 0; i<length_msg;i++)
+ {
+ data.push_back(0);
+ }
+
+ encoder_t::encode_data(subscription.signal_,data,true,false,true);
+
+ can_message_t cm;
+
+ if (is_fd)
{
flags = SETTIMER|RX_NO_AUTOTIMER|CAN_FD_FRAME;
cfd.len = CANFD_MAX_DLEN;
+ cm = can_message_t(CANFD_MAX_DLEN,sig->get_message()->get_id(),length_msg,sig->get_message()->get_format(),false,CAN_FD_FRAME,data,0);
}
else
{
flags = SETTIMER|RX_NO_AUTOTIMER;
cfd.len = CAN_MAX_DLEN;
+ cm = can_message_t(CAN_MAX_DLEN,sig->get_message()->get_id(),length_msg,sig->get_message()->get_format(),false,0,data,0);
}
- val = (float)(1 << subscription.signal_->get_bit_size()) - 1;
- if(! bitfield_encode_float(val,
- subscription.signal_->get_bit_position(),
- subscription.signal_->get_bit_size(),
- 1,
- subscription.signal_->get_offset(),
- cfd.data,
- cfd.len))
- return -1;
frequency_clock_t f = subscription.event_filter_.frequency == 0 ? subscription.signal_->get_frequency() : frequency_clock_t(subscription.event_filter_.frequency);
freq = f.get_timeval_from_period();
struct bcm_msg bcm_msg = subscription.make_bcm_head(RX_SETUP, subscription.signal_->get_message()->get_id(), flags, timeout, freq);
- subscription.add_one_bcm_frame(cfd, bcm_msg);
+
+ std::vector<canfd_frame> cfd_vect = cm.convert_to_canfd_frame_vector();
+
+ if(cfd_vect.size() > 1) //multi
+ {
+ AFB_ERROR("Not implemented yet");
+ return -1;
+ }
+ else if(cfd_vect.size() == 1)
+ {
+ canfd_frame cf = cfd_vect[0];
+ for(int i=0;i<cfd.len;i++)
+ {
+ cfd.data[i] = cf.data[i];
+ }
+ subscription.add_one_bcm_frame(cfd, bcm_msg);
+ }
+ else
+ {
+ AFB_ERROR("No data available");
+ return -1;
+ }
return create_rx_filter_bcm(subscription, bcm_msg);
}