summaryrefslogtreecommitdiffstats
path: root/low-can-binding/binding/low-can-subscription.cpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2019-11-05 15:37:47 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2020-01-08 00:17:29 +0100
commitbdde88e49b303bb310609eee13e13c8b99a2ab09 (patch)
tree17946d20986f824cfc433f4ed4d712e2e113150d /low-can-binding/binding/low-can-subscription.cpp
parent699f7c0fd118615f53eb7b7b3a86e1c6d2a42c09 (diff)
subscription: Optimizing opening sockets
Also review some aligment and make more space between bool ops Bug-AGL: SPEC-2988 Change-Id: I613f294a630caf48eea7bb0c7b9c36b07cbacfbf 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.cpp30
1 files changed, 11 insertions, 19 deletions
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;
}