summaryrefslogtreecommitdiffstats
path: root/low-can-binding
diff options
context:
space:
mode:
Diffstat (limited to 'low-can-binding')
-rw-r--r--low-can-binding/binding/low-can-cb.cpp22
-rw-r--r--low-can-binding/binding/low-can-subscription.cpp30
2 files changed, 22 insertions, 30 deletions
diff --git a/low-can-binding/binding/low-can-cb.cpp b/low-can-binding/binding/low-can-cb.cpp
index fd57867c..8bb595e9 100644
--- a/low-can-binding/binding/low-can-cb.cpp
+++ b/low-can-binding/binding/low-can-cb.cpp
@@ -111,7 +111,7 @@ int read_message(sd_event_source *event_source, int fd, uint32_t revents, void *
}
// check if error or hangup
- if ((revents & (EPOLLERR|EPOLLRDHUP|EPOLLHUP)) != 0)
+ if ((revents & (EPOLLERR | EPOLLRDHUP | EPOLLHUP)) != 0)
{
sd_event_source_unref(event_source);
can_subscription->get_socket()->close();
@@ -193,11 +193,11 @@ static int add_to_event_loop(std::shared_ptr<low_can_subscription_t>& can_subscr
}
static int subscribe_unsubscribe_diagnostic_messages(afb_req_t request,
- bool subscribe,
- list_ptr_diag_msg_t diagnostic_messages,
- struct event_filter_t& event_filter,
- map_subscription& s,
- bool perm_rec_diag_req)
+ bool subscribe,
+ list_ptr_diag_msg_t diagnostic_messages,
+ struct event_filter_t& event_filter,
+ map_subscription& s,
+ bool perm_rec_diag_req)
{
int rets = 0;
application_t& app = application_t::instance();
@@ -258,10 +258,10 @@ static int subscribe_unsubscribe_diagnostic_messages(afb_req_t request,
}
static int subscribe_unsubscribe_signals(afb_req_t request,
- bool subscribe,
- list_ptr_signal_t signals,
- struct event_filter_t& event_filter,
- map_subscription& s)
+ bool subscribe,
+ list_ptr_signal_t signals,
+ struct event_filter_t& event_filter,
+ map_subscription& s)
{
int rets = 0;
for(const auto& sig: signals)
@@ -589,7 +589,7 @@ static void write_raw_frame(afb_req_t request, const std::string& bus_name, mess
if( !sf.signals.empty() )
{
AFB_DEBUG("ID WRITE RAW : %d",sf.signals.front()->get_message()->get_id());
- if(flags&BCM_PROTOCOL)
+ if(flags & BCM_PROTOCOL)
{
if(sf.signals.front()->get_message()->is_fd())
{
diff --git a/low-can-binding/binding/low-can-subscription.cpp b/low-can-binding/binding/low-can-subscription.cpp
index e9ee198b..1e22d260 100644
--- a/low-can-binding/binding/low-can-subscription.cpp
+++ b/low-can-binding/binding/low-can-subscription.cpp
@@ -366,27 +366,21 @@ int low_can_subscription_t::open_socket(low_can_subscription_t &subscription, co
{
if(flags & BCM_PROTOCOL)
{
- if( subscription.signal_ != nullptr)
- {
- subscription.socket_ = std::make_shared<utils::socketcan_bcm_t>();
- ret = subscription.socket_->open(subscription.signal_->get_message()->get_bus_device_name());
- }
- else if (! subscription.diagnostic_message_ .empty())
- {
- subscription.socket_ = std::make_shared<utils::socketcan_bcm_t>();
- ret = subscription.socket_->open(application_t::instance().get_diagnostic_manager().get_bus_device_name());
- }
- else if ( !bus_name.empty())
- {
- subscription.socket_ = std::make_shared<utils::socketcan_bcm_t>();
- ret = subscription.socket_->open(bus_name);
- }
+ subscription.socket_ = std::make_shared<utils::socketcan_bcm_t>();
+ if( subscription.signal_ )
+ ret = subscription.socket_->open(subscription.signal_->get_message()->get_bus_device_name());
+ else if(! subscription.diagnostic_message_.empty())
+ ret = subscription.socket_->open(application_t::instance().get_diagnostic_bus());
+ else if(! bus_name.empty())
+ ret = subscription.socket_->open(bus_name);
+
subscription.index_ = (int)subscription.socket_->socket();
}
#ifdef USE_FEATURE_ISOTP
else if(flags & ISOTP_PROTOCOL)
{
- if(subscription.signal_ != nullptr)
+ std::shared_ptr<utils::socketcan_isotp_t> socket = std::make_shared<utils::socketcan_isotp_t>();
+ if(subscription.signal_ )
{
canid_t rx = NO_CAN_ID;
canid_t tx = NO_CAN_ID;
@@ -400,13 +394,11 @@ int low_can_subscription_t::open_socket(low_can_subscription_t &subscription, co
rx = subscription.signal_->get_message()->get_id();
tx = subscription.get_tx_id();
}
- std::shared_ptr<utils::socketcan_isotp_t> socket = std::make_shared<utils::socketcan_isotp_t>();
ret = socket->open(subscription.signal_->get_message()->get_bus_device_name(),rx,tx);
subscription.socket_ = socket;
}
- else if(!bus_name.empty())
+ else if(! bus_name.empty())
{
- std::shared_ptr<utils::socketcan_isotp_t> socket = std::make_shared<utils::socketcan_isotp_t>();
ret = socket->open(bus_name, subscription.get_rx_id(),subscription.get_tx_id());
subscription.socket_ = socket;
}