summaryrefslogtreecommitdiffstats
path: root/low-can-binding/binding/low-can-subscription.cpp
diff options
context:
space:
mode:
authorArthur GUYADER <arthur.guyader@iot.bzh>2019-12-12 18:12:01 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2020-01-09 16:25:36 +0100
commit43cc23cd9d0986ae370f5839aa952c6e3eb196d0 (patch)
tree0e99d6a235d50731a0f55c15a722e51887b9555a /low-can-binding/binding/low-can-subscription.cpp
parentc57722b34d38c9843a728829204d2711aaadacbb (diff)
j1939: Follow updates of the kernel
This commit patch j1939 feature after the update of the kernel from linux-can-next to mainline. Now promisc option removes filter of the bind. The option is now a parameter in the event_filter. The feature recv_own isn't available, you can't receive on the same socket an emit frame from you. Not a big problem because receive and send method use two different sockets in the implementation. Change-Id: I5ac410177c1512090827870300b8aa1679477b84 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/low-can-subscription.cpp')
-rw-r--r--low-can-binding/binding/low-can-subscription.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/low-can-binding/binding/low-can-subscription.cpp b/low-can-binding/binding/low-can-subscription.cpp
index 3cbcb6c9..4bdf3181 100644
--- a/low-can-binding/binding/low-can-subscription.cpp
+++ b/low-can-binding/binding/low-can-subscription.cpp
@@ -254,6 +254,11 @@ float low_can_subscription_t::get_max() const
return event_filter_.max;
}
+bool low_can_subscription_t::get_promisc() const
+{
+ return event_filter_.promisc;
+}
+
/**
* @brief Getter of the rx_id of the event_filter
*
@@ -314,6 +319,11 @@ void low_can_subscription_t::set_max(float max)
event_filter_.max = max;
}
+void low_can_subscription_t::set_promisc(bool promisc)
+{
+ event_filter_.promisc = promisc;
+}
+
/**
* @brief Setter for the rx_id of the event_filter
*
@@ -409,30 +419,32 @@ int low_can_subscription_t::open_socket(low_can_subscription_t &subscription, co
else if(flags & J1939_ADDR_CLAIM_PROTOCOL)
{
pgn_t pgn = J1939_NO_PGN;
+ std::shared_ptr<utils::socketcan_j1939_addressclaiming_t> socket = std::make_shared<utils::socketcan_j1939_addressclaiming_t>();
if(!bus_name.empty())
{
- std::shared_ptr<utils::socketcan_j1939_addressclaiming_t> socket = std::make_shared<utils::socketcan_j1939_addressclaiming_t>();
ret = socket->open(bus_name, pgn);
- subscription.socket_ = socket;
}
+ subscription.socket_ = socket;
subscription.index_ = (int)subscription.socket_->socket();
}
else if(flags & J1939_PROTOCOL)
{
pgn_t pgn = J1939_NO_PGN;
+ std::shared_ptr<utils::socketcan_j1939_data_t> socket = std::make_shared<utils::socketcan_j1939_data_t>();
if(subscription.signal_)
{
pgn = subscription.signal_->get_message()->get_id();
- std::shared_ptr<utils::socketcan_j1939_data_t> socket = std::make_shared<utils::socketcan_j1939_data_t>();
ret = socket->open(subscription.signal_->get_message()->get_bus_device_name(), pgn);
- subscription.socket_ = socket;
}
else if(!bus_name.empty())
{
- std::shared_ptr<utils::socketcan_j1939_data_t> socket = std::make_shared<utils::socketcan_j1939_data_t>();
ret = socket->open(bus_name, pgn);
- subscription.socket_ = socket;
}
+
+ if(ret)
+ socket->define_opt(!j1939_pgn_is_pdu1(pgn),subscription.event_filter_.promisc);
+
+ subscription.socket_ = socket;
subscription.index_ = (int)subscription.socket_->socket();
}
#endif