aboutsummaryrefslogtreecommitdiffstats
path: root/low-can-binding
diff options
context:
space:
mode:
Diffstat (limited to 'low-can-binding')
-rw-r--r--low-can-binding/binding/application.cpp4
-rw-r--r--low-can-binding/binding/low-can-cb.cpp31
-rw-r--r--low-can-binding/binding/low-can-subscription.cpp30
-rw-r--r--low-can-binding/can/can-decoder.cpp19
-rw-r--r--low-can-binding/utils/openxc-utils.cpp1
5 files changed, 8 insertions, 77 deletions
diff --git a/low-can-binding/binding/application.cpp b/low-can-binding/binding/application.cpp
index c5dfa1b6..4c9641c4 100644
--- a/low-can-binding/binding/application.cpp
+++ b/low-can-binding/binding/application.cpp
@@ -154,13 +154,9 @@ bool application_t::is_engine_on()
if(sf.signals.front()->get_last_value_with_timestamp().first > 0 &&
std::difftime(std::time(nullptr), last_timestamp_in_s) < ENGINE_VALUE_TIMEOUT)
- {
engine_on = true;
- }
else
- {
AFB_NOTICE("is_engine_on: engine.speed CAN signal found, but engine seems off");
- }
}
else
{
diff --git a/low-can-binding/binding/low-can-cb.cpp b/low-can-binding/binding/low-can-cb.cpp
index 5d5a5170..4be7261e 100644
--- a/low-can-binding/binding/low-can-cb.cpp
+++ b/low-can-binding/binding/low-can-cb.cpp
@@ -126,9 +126,7 @@ static int subscribe_unsubscribe_signal(afb_req_t request,
* subsciptions.
*/
if(! request)
- {
return 0;
- }
// Event doesn't exist , so let's create it
if ((ret = can_subscription->subscribe(request)) < 0)
@@ -485,35 +483,6 @@ void unsubscribe(afb_req_t request)
do_subscribe_unsubscribe(request, false);
}
-/*
-static int send_frame(struct canfd_frame& cfd, const std::string& bus_name, socket_type type)
-{
- if(bus_name.empty())
- {
- return -1;
- }
-
- std::map<std::string, std::shared_ptr<low_can_subscription_t> >& cd = application_t::instance().get_can_devices();
-
- if( cd.count(bus_name) == 0)
- {
- cd[bus_name] = std::make_shared<low_can_subscription_t>(low_can_subscription_t());
- }
-
-
- if(type == socket_type::BCM)
- {
- return low_can_subscription_t::tx_send(*cd[bus_name], cfd, bus_name);
- }
- else if(type == socket_type::J1939)
- {
- return low_can_subscription_t::j1939_send(*cd[bus_name], cfd, bus_name);
- }
- else{
- return -1;
- }
-}
-*/
static int send_message(message_t *message, const std::string& bus_name, uint32_t flags, event_filter_t &event_filter, std::shared_ptr<signal_t> signal)
{
if(bus_name.empty())
diff --git a/low-can-binding/binding/low-can-subscription.cpp b/low-can-binding/binding/low-can-subscription.cpp
index 4bdf3181..6cfcb718 100644
--- a/low-can-binding/binding/low-can-subscription.cpp
+++ b/low-can-binding/binding/low-can-subscription.cpp
@@ -102,12 +102,9 @@ int low_can_subscription_t::set_event()
int low_can_subscription_t::subscribe(afb_req_t request)
{
if(! afb_event_is_valid(event_))
- {
if(set_event() < 0)
- {
return -1;
- }
- }
+
return afb_req_subscribe(request, event_);
}
@@ -175,12 +172,9 @@ const vect_ptr_diag_msg_t low_can_subscription_t::get_diagnostic_message() const
const std::shared_ptr<diagnostic_message_t> low_can_subscription_t::get_diagnostic_message(uint32_t pid) const
{
for(const auto& diag: diagnostic_message_)
- {
if(diag->get_pid() == pid)
- {
return diag;
- }
- }
+
return nullptr;
}
@@ -190,12 +184,9 @@ const std::shared_ptr<diagnostic_message_t> low_can_subscription_t::get_diagnost
const std::shared_ptr<diagnostic_message_t> low_can_subscription_t::get_diagnostic_message(const std::string& name) const
{
for(const auto& diag: diagnostic_message_)
- {
if(diag->get_name() == name)
- {
return diag;
- }
- }
+
return nullptr;
}
@@ -421,9 +412,7 @@ int low_can_subscription_t::open_socket(low_can_subscription_t &subscription, co
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())
- {
ret = socket->open(bus_name, pgn);
- }
subscription.socket_ = socket;
subscription.index_ = (int)subscription.socket_->socket();
}
@@ -628,26 +617,17 @@ int low_can_subscription_t::create_rx_filter_can(low_can_subscription_t &subscri
int low_can_subscription_t::create_rx_filter(std::shared_ptr<signal_t> sig)
{
if(!sig->get_message()->is_isotp() && !sig->get_message()->is_j1939())
- {
return low_can_subscription_t::create_rx_filter_can(*this, sig);
- }
#ifdef USE_FEATURE_ISOTP
else if(sig->get_message()->is_isotp())
- {
return low_can_subscription_t::create_rx_filter_isotp(*this, sig);
- }
#endif
#ifdef USE_FEATURE_J1939
else if(sig->get_message()->is_j1939())
- {
return low_can_subscription_t::create_rx_filter_j1939(*this, sig);
- }
#endif
- else
- {
- AFB_ERROR("Signal can't be j1939 and isotp");
- return -1;
- }
+ AFB_ERROR("Signal can't be j1939 and isotp");
+ return -1;
}
diff --git a/low-can-binding/can/can-decoder.cpp b/low-can-binding/can/can-decoder.cpp
index 15341b1c..3f05fd53 100644
--- a/low-can-binding/can/can-decoder.cpp
+++ b/low-can-binding/can/can-decoder.cpp
@@ -65,11 +65,9 @@ int decoder_t::handle_sign(const signal_t& signal, std::vector<uint8_t>& data_si
case sign_t::TWOS_COMPLEMENT:
//complement only until end_bit
data_signal[0] = ((data_signal[0] ^ mask) & mask);
- if(data_signal.size() > 1) {
- for(int i=1; i < data_signal.size(); i++) {
+ if(data_signal.size() > 1)
+ for(int i=1; i < data_signal.size(); i++)
data_signal[i] = data_signal[i] ^ 0xFF;
- }
- }
if(signal.get_sign() == sign_t::TWOS_COMPLEMENT)
data_signal[data_signal.size() - 1] = static_cast<uint8_t>(data_signal[data_signal.size() - 1] + 1);
break;
@@ -213,9 +211,7 @@ openxc_DynamicField decoder_t::decode_ascii(signal_t& signal, std::shared_ptr<me
std::string ret_s = "";
openxc_DynamicField openxc_bytes = decode_bytes(signal,message,send);
if(!openxc_bytes.has_bytes_value)
- {
AFB_ERROR("Error no bytes value to translate to ascii");
- }
ret_s = converter_t::to_ascii(openxc_bytes.bytes_value,openxc_bytes.length_array);
openxc_DynamicField ret = build_DynamicField(ret_s);
return ret;
@@ -230,9 +226,7 @@ openxc_DynamicField decoder_t::decode_date(signal_t& signal, std::shared_ptr<mes
// Don't send if they is no changes
if ((signal.get_last_value() == value && !signal.get_send_same()) || !*send )
- {
*send = false;
- }
signal.set_last_value(value);
return decoded_value;
@@ -246,10 +240,7 @@ openxc_DynamicField decoder_t::decode_time(signal_t& signal, std::shared_ptr<mes
openxc_DynamicField decoded_value = build_DynamicField(value);
// Don't send if they is no changes
- if ((signal.get_last_value() == value && !signal.get_send_same()) || !*send )
- {
- *send = false;
- }
+ *send = (signal.get_last_value() == value && !signal.get_send_same()) || !*send ? false : true;
signal.set_last_value(value);
return decoded_value;
@@ -278,9 +269,7 @@ openxc_DynamicField decoder_t::decode_noop(signal_t& signal, std::shared_ptr<mes
// Don't send if they is no changes
if ((signal.get_last_value() == value && !signal.get_send_same()) || !*send )
- {
*send = false;
- }
signal.set_last_value(value);
return decoded_value;
@@ -369,9 +358,7 @@ openxc_DynamicField decoder_t::decode_state(signal_t& signal, std::shared_ptr<me
// Don't send if they is no changes
if ((signal.get_last_value() == value && !signal.get_send_same()) || !*send )
- {
*send = false;
- }
signal.set_last_value(value);
diff --git a/low-can-binding/utils/openxc-utils.cpp b/low-can-binding/utils/openxc-utils.cpp
index e2cf8d59..5ca70b88 100644
--- a/low-can-binding/utils/openxc-utils.cpp
+++ b/low-can-binding/utils/openxc-utils.cpp
@@ -402,7 +402,6 @@ void jsonify_DynamicField(const openxc_DynamicField& field, json_object* value)
else if(field.has_bytes_value)
{
std::string s = converter_t::to_hex(field.bytes_value, field.length_array);
-
json_object_object_add(value, "value", json_object_new_string(s.c_str()));
}
}