+ if(flags & BCM_PROTOCOL)
+ {
+ 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)
+ {
+ 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;
+ if(flags & ISOTP_SEND)
+ {
+ rx = subscription.get_rx_id();
+ tx = subscription.signal_->get_message()->get_id();
+ }
+ else if(flags & ISOTP_RECEIVE)
+ {
+ rx = subscription.signal_->get_message()->get_id();
+ tx = subscription.get_tx_id();
+ }
+ ret = socket->open(subscription.signal_->get_message()->get_bus_device_name(), rx, tx);
+ subscription.socket_ = socket;
+ }
+ else if(! bus_name.empty())
+ {
+ ret = socket->open(bus_name, subscription.get_rx_id(), subscription.get_tx_id());
+ subscription.socket_ = socket;
+ }
+ subscription.index_ = (int)subscription.socket_->socket();
+ }
+#endif
+#ifdef USE_FEATURE_J1939
+ else if(flags & J1939_ADDR_CLAIM_PROTOCOL)
+ {
+ pgn_t pgn = J1939_NO_PGN;
+ 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.index_ = (int)subscription.socket_->socket();
+ }
+ else if(flags & J1939_PROTOCOL)
+ {
+ pgn_t pgn = J1939_NO_PGN;
+ if(subscription.signal_ != nullptr)
+ {
+ 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;
+ }
+ subscription.index_ = (int)subscription.socket_->socket();
+ }
+#endif
+ else
+ {
+ AFB_ERROR("Socket format not supported");
+ return INVALID_SOCKET;
+ }
+ }
+ else{
+ ret = subscription.socket_->socket();