summaryrefslogtreecommitdiffstats
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/application.hpp2
-rw-r--r--low-can-binding/binding/low-can-cb.cpp30
-rw-r--r--low-can-binding/binding/low-can-subscription.cpp8
-rw-r--r--low-can-binding/binding/low-can-subscription.hpp2
-rw-r--r--low-can-binding/can/can-decoder.cpp4
-rw-r--r--low-can-binding/can/can-encoder.cpp12
-rw-r--r--low-can-binding/can/message/can-message.cpp14
-rw-r--r--low-can-binding/can/message/can-message.hpp12
-rw-r--r--low-can-binding/can/message/j1939-message.cpp6
-rw-r--r--low-can-binding/can/message/message.cpp4
-rw-r--r--low-can-binding/can/message/message.hpp2
-rwxr-xr-x[-rw-r--r--]low-can-binding/can/signals.cpp4
-rwxr-xr-x[-rw-r--r--]low-can-binding/can/signals.hpp6
-rw-r--r--low-can-binding/utils/openxc-utils.cpp2
-rw-r--r--low-can-binding/utils/socketcan-isotp.cpp16
-rw-r--r--low-can-binding/utils/socketcan-j1939/socketcan-j1939-addressclaiming.cpp40
-rw-r--r--low-can-binding/utils/socketcan-j1939/socketcan-j1939-addressclaiming.hpp4
-rw-r--r--low-can-binding/utils/socketcan-j1939/socketcan-j1939-data.cpp4
-rw-r--r--low-can-binding/utils/socketcan-j1939/socketcan-j1939.cpp10
-rw-r--r--low-can-binding/utils/socketcan.cpp2
21 files changed, 94 insertions, 94 deletions
diff --git a/low-can-binding/binding/application.cpp b/low-can-binding/binding/application.cpp
index bcb8d732..c4da68ae 100644
--- a/low-can-binding/binding/application.cpp
+++ b/low-can-binding/binding/application.cpp
@@ -145,7 +145,7 @@ void application_t::set_active_message_set(uint8_t id)
active_message_set_ = id;
}
-bool application_t::isEngineOn()
+bool application_t::is_engine_on()
{
struct utils::signals_found sf;
openxc_DynamicField search_key = build_DynamicField("engine.speed");
@@ -213,4 +213,4 @@ void application_t::set_subscription_address_claiming(std::shared_ptr<low_can_su
subscription_address_claiming_ = new_subscription;
}
-#endif \ No newline at end of file
+#endif
diff --git a/low-can-binding/binding/application.hpp b/low-can-binding/binding/application.hpp
index 30e21833..7b4732c0 100644
--- a/low-can-binding/binding/application.hpp
+++ b/low-can-binding/binding/application.hpp
@@ -89,7 +89,7 @@ class application_t
uint32_t get_signal_id(signal_t& sig) const;
- bool isEngineOn();
+ bool is_engine_on();
void set_active_message_set(uint8_t id);
diff --git a/low-can-binding/binding/low-can-cb.cpp b/low-can-binding/binding/low-can-cb.cpp
index 1c01738f..5b351b59 100644
--- a/low-can-binding/binding/low-can-cb.cpp
+++ b/low-can-binding/binding/low-can-cb.cpp
@@ -221,7 +221,7 @@ static int subscribe_unsubscribe_diagnostic_messages(afb_req_t request,
// poll a PID for nothing.
if(sig->get_supported() && subscribe)
{
- if (!app.isEngineOn())
+ if (!app.is_engine_on())
AFB_WARNING("signal: Engine is off, %s won't received responses until it's on", sig->get_name().c_str());
diag_m.add_recurring_request(diag_req, sig->get_name().c_str(), false, sig->get_decoder(), sig->get_callback(), event_filter.frequency, perm_rec_diag_req);
@@ -382,14 +382,14 @@ static int one_subscribe_unsubscribe_events(afb_req_t request, bool subscribe, c
return ret;
}
-static int one_subscribe_unsubscribe_id(afb_req_t request, bool subscribe, const uint32_t& id ,json_object *args)
+static int one_subscribe_unsubscribe_id(afb_req_t request, bool subscribe, const uint32_t& id, json_object *args)
{
int ret = 0;
std::shared_ptr<message_definition_t> message_definition = application_t::instance().get_message_definition(id);
struct utils::signals_found sf;
if(message_definition)
- sf.signals = list_ptr_signal_t(message_definition->get_signals().begin(),message_definition->get_signals().end());
+ sf.signals = list_ptr_signal_t(message_definition->get_signals().begin(), message_definition->get_signals().end());
if(sf.signals.empty())
{
@@ -563,7 +563,7 @@ static int send_message(message_t *message, const std::string& bus_name, uint32_
static void write_raw_frame(afb_req_t request, const std::string& bus_name, message_t *message,
- struct json_object *can_data, uint32_t flags, event_filter_t &event_filter)
+ struct json_object *can_data, uint32_t flags, event_filter_t &event_filter)
{
struct utils::signals_found sf;
@@ -572,7 +572,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());
+ AFB_DEBUG("ID WRITE RAW : %d", sf.signals.front()->get_message()->get_id());
if(flags & BCM_PROTOCOL)
{
if(sf.signals.front()->get_message()->is_fd())
@@ -639,20 +639,20 @@ static void write_raw_frame(afb_req_t request, const std::string& bus_name, mess
static void write_frame(afb_req_t request, const std::string& bus_name, json_object *json_value, event_filter_t &event_filter)
{
message_t *message;
- int id;
- int length;
+ uint32_t id;
+ uint32_t length;
struct json_object *can_data = nullptr;
std::vector<uint8_t> data;
- AFB_DEBUG("JSON content %s",json_object_get_string(json_value));
+ AFB_DEBUG("JSON content %s", json_object_get_string(json_value));
if(!wrap_json_unpack(json_value, "{si, si, so !}",
"can_id", &id,
"can_dlc", &length,
"can_data", &can_data))
{
- message = new can_message_t(0,(uint32_t)id,(uint32_t)length,false,0,data,0);
- write_raw_frame(request,bus_name,message,can_data,BCM_PROTOCOL,event_filter);
+ message = new can_message_t(0, id, length, false, 0, data, 0);
+ write_raw_frame(request, bus_name, message, can_data, BCM_PROTOCOL, event_filter);
}
#ifdef USE_FEATURE_J1939
else if(!wrap_json_unpack(json_value, "{si, si, so !}",
@@ -660,8 +660,8 @@ static void write_frame(afb_req_t request, const std::string& bus_name, json_obj
"length", &length,
"data", &can_data))
{
- message = new j1939_message_t((uint32_t)length,data,0,J1939_NO_NAME,(pgn_t)id,J1939_NO_ADDR);
- write_raw_frame(request,bus_name,message,can_data,J1939_PROTOCOL, event_filter);
+ message = new j1939_message_t(length, data, 0, J1939_NO_NAME, (pgn_t)id, J1939_NO_ADDR);
+ write_raw_frame(request, bus_name, message, can_data, J1939_PROTOCOL, event_filter);
}
#endif
else
@@ -712,7 +712,7 @@ static void write_signal(afb_req_t request, const std::string& name, json_object
flags = BCM_PROTOCOL;
// cfd = encoder_t::build_frame(sig, value);
- message_t *message = encoder_t::build_message(sig,value,false,false);
+ message_t *message = encoder_t::build_message(sig, value, false, false);
if(! send_message(message, sig->get_message()->get_bus_device_name(), flags, event_filter, sig) && send)
afb_req_success(request, nullptr, "Message correctly sent");
@@ -923,8 +923,8 @@ int init_binding(afb_api_t api)
application.set_subscription_address_claiming(low_can_j1939);
ret = low_can_subscription_t::open_socket(*low_can_j1939,
- j1939_bus,
- J1939_ADDR_CLAIM_PROTOCOL);
+ j1939_bus,
+ J1939_ADDR_CLAIM_PROTOCOL);
if(ret < 0)
{
diff --git a/low-can-binding/binding/low-can-subscription.cpp b/low-can-binding/binding/low-can-subscription.cpp
index 8b5f302e..8c0a07c1 100644
--- a/low-can-binding/binding/low-can-subscription.cpp
+++ b/low-can-binding/binding/low-can-subscription.cpp
@@ -394,12 +394,12 @@ 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();
}
- ret = socket->open(subscription.signal_->get_message()->get_bus_device_name(),rx,tx);
+ 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());
+ ret = socket->open(bus_name, subscription.get_rx_id(), subscription.get_tx_id());
subscription.socket_ = socket;
}
subscription.index_ = (int)subscription.socket_->socket();
@@ -495,7 +495,7 @@ void low_can_subscription_t::add_one_bcm_frame(struct canfd_frame& cfd, struct b
void low_can_subscription_t::remove_last_bcm_frame(struct bcm_msg& bcm_msg)
{
struct canfd_frame cf;
- memset(&cf,0,sizeof(cf));
+ memset(&cf, 0, sizeof(cf));
bcm_msg.fd_frames[bcm_msg.msg_head.nframes] = cf;
bcm_msg.msg_head.nframes--;
}
@@ -704,7 +704,7 @@ int low_can_subscription_t::tx_send(low_can_subscription_t &subscription, messag
{
can_message_t *cm = static_cast<can_message_t*>(message);
- struct bcm_msg bcm_msg = subscription.make_bcm_head(TX_SEND, cm->get_id(),cm->get_flags()|TX_CP_CAN_ID); // TX_CP_CAN_ID -> copy in cfd the id of bcm
+ struct bcm_msg bcm_msg = subscription.make_bcm_head(TX_SEND, cm->get_id(), cm->get_flags()|TX_CP_CAN_ID); // TX_CP_CAN_ID -> copy in cfd the id of bcm
cm->set_bcm_msg(bcm_msg);
std::vector<canfd_frame> cfd_vect = cm->convert_to_canfd_frame_vector();
diff --git a/low-can-binding/binding/low-can-subscription.hpp b/low-can-binding/binding/low-can-subscription.hpp
index ac08d265..fa6b795e 100644
--- a/low-can-binding/binding/low-can-subscription.hpp
+++ b/low-can-binding/binding/low-can-subscription.hpp
@@ -99,7 +99,7 @@ public:
void set_tx_id(canid_t tx_id);
void set_signal(std::shared_ptr<signal_t> signal);
- static struct bcm_msg make_bcm_head(uint32_t opcode, uint32_t can_id = 0, uint32_t flags = 0, const struct timeval& timeout = {0,0}, const struct timeval& frequency_thinning = {0,0});
+ static struct bcm_msg make_bcm_head(uint32_t opcode, uint32_t can_id = 0, uint32_t flags = 0, const struct timeval& timeout = {0, 0}, const struct timeval& frequency_thinning = {0, 0});
static void add_one_bcm_frame(struct canfd_frame& cfd, struct bcm_msg& bcm_msg);
static void remove_last_bcm_frame(struct bcm_msg& bcm_msg);
diff --git a/low-can-binding/can/can-decoder.cpp b/low-can-binding/can/can-decoder.cpp
index 56626691..e901240b 100644
--- a/low-can-binding/can/can-decoder.cpp
+++ b/low-can-binding/can/can-decoder.cpp
@@ -50,13 +50,13 @@ float decoder_t::parse_signal_bitfield(signal_t& signal, std::shared_ptr<message
data_signal.push_back(data[i]);
// if(bit_size > 255)
-// AFB_ERROR("Error signal %s to long bit size",signal.get_name().c_str());
+// AFB_ERROR("Error signal %s to long bit size", signal.get_name().c_str());
// if(new_start_bit > 255)
// AFB_ERROR("Too long signal offset %d", new_start_bit);
if(data_signal.size() > 65535)
- AFB_ERROR("Too long data signal %s",signal.get_name().c_str());
+ AFB_ERROR("Too long data signal %s", signal.get_name().c_str());
return bitfield_parse_float(data_signal.data(), (uint16_t) data_signal.size(),
new_start_bit, bit_size, signal.get_factor(),
diff --git a/low-can-binding/can/can-encoder.cpp b/low-can-binding/can/can-encoder.cpp
index fb68b879..113428b9 100644
--- a/low-can-binding/can/can-encoder.cpp
+++ b/low-can-binding/can/can-encoder.cpp
@@ -47,7 +47,7 @@ void encoder_t::encode_data(std::shared_ptr<signal_t> sig, std::vector<uint8_t>
uint8_t len_signal_bytes = 0;
if(len_signal_bytes_tmp > 255)
{
- AFB_ERROR("Error signal %s too long",sig->get_name().c_str());
+ AFB_ERROR("Error signal %s too long", sig->get_name().c_str());
}
else
{
@@ -56,13 +56,13 @@ void encoder_t::encode_data(std::shared_ptr<signal_t> sig, std::vector<uint8_t>
/*
if(new_start_bit > 255)
{
- AFB_ERROR("Error signal %s too long",sig->get_name().c_str());
+ AFB_ERROR("Error signal %s too long", sig->get_name().c_str());
}
*/
uint8_t new_bit_size = 0;
if(bit_size > 255)
{
- AFB_ERROR("Error signal %s to long bit size",sig->get_name().c_str());
+ AFB_ERROR("Error signal %s to long bit size", sig->get_name().c_str());
}
else
{
@@ -148,7 +148,7 @@ message_t* encoder_t::build_frame(const std::shared_ptr<signal_t>& signal, uint6
for(const auto& sig: signal->get_message()->get_signals())
{
- encode_data(sig,data,false,factor,offset);
+ encode_data(sig, data, false, factor, offset);
}
message->set_data(data);
return message;
@@ -177,7 +177,7 @@ message_t* encoder_t::build_message(const std::shared_ptr<signal_t>& signal, uin
data,
0);
- return build_frame(signal,value,message, factor, offset);
+ return build_frame(signal, value, message, factor, offset);
}
#ifdef USE_FEATURE_J1939
else if(signal->get_message()->is_j1939())
@@ -188,7 +188,7 @@ message_t* encoder_t::build_message(const std::shared_ptr<signal_t>& signal, uin
J1939_NO_NAME,
signal->get_message()->get_id(),
J1939_NO_ADDR);
- return build_frame(signal,value,message, factor, offset);
+ return build_frame(signal, value, message, factor, offset);
}
#endif
else
diff --git a/low-can-binding/can/message/can-message.cpp b/low-can-binding/can/message/can-message.cpp
index 1f73c27e..5c3e0f0e 100644
--- a/low-can-binding/can/message/can-message.cpp
+++ b/low-can-binding/can/message/can-message.cpp
@@ -204,12 +204,12 @@ struct std::vector<canfd_frame> can_message_t::convert_to_canfd_frame_vector()
std::vector<uint8_t> data = get_data_vector((i*64),(i*64)+63);
if(data.size()<64)
{
- ::memset(frame.data,0,sizeof(frame.data));
- ::memcpy(frame.data,data.data(),data.size());
+ ::memset(frame.data, 0, sizeof(frame.data));
+ ::memcpy(frame.data, data.data(), data.size());
}
else
{
- ::memcpy(frame.data,data.data(),64);
+ ::memcpy(frame.data, data.data(), 64);
}
ret.push_back(frame);
i++;
@@ -226,13 +226,13 @@ struct std::vector<canfd_frame> can_message_t::convert_to_canfd_frame_vector()
std::vector<uint8_t> data = get_data_vector(i*8,(i*8)+7);
if(data.size()<8)
{
- ::memset(frame.data,0,sizeof(frame.data));
- ::memcpy(frame.data,data.data(),data.size());
+ ::memset(frame.data, 0, sizeof(frame.data));
+ ::memcpy(frame.data, data.data(), data.size());
}
else
{
- ::memset(frame.data,0,sizeof(frame.data));
- ::memcpy(frame.data,data.data(),8);
+ ::memset(frame.data, 0, sizeof(frame.data));
+ ::memcpy(frame.data, data.data(), 8);
}
ret.push_back(frame);
i++;
diff --git a/low-can-binding/can/message/can-message.hpp b/low-can-binding/can/message/can-message.hpp
index acc3bfc1..9d501a25 100644
--- a/low-can-binding/can/message/can-message.hpp
+++ b/low-can-binding/can/message/can-message.hpp
@@ -40,12 +40,12 @@ class can_message_t : public message_t {
public:
can_message_t();
can_message_t( uint32_t maxdlen,
- uint32_t id,
- uint32_t length,
- bool rtr_flag_,
- uint32_t flags,
- std::vector<uint8_t>& data,
- uint64_t timestamp);
+ uint32_t id,
+ uint32_t length,
+ bool rtr_flag_,
+ uint32_t flags,
+ std::vector<uint8_t>& data,
+ uint64_t timestamp);
uint32_t get_id() const;
void set_id(const canid_t id);
diff --git a/low-can-binding/can/message/j1939-message.cpp b/low-can-binding/can/message/j1939-message.cpp
index 432a1393..3740ea20 100644
--- a/low-can-binding/can/message/j1939-message.cpp
+++ b/low-can-binding/can/message/j1939-message.cpp
@@ -94,7 +94,7 @@ uint8_t j1939_message_t::get_addr() const{
/// @param[in] timestamp - timestamp of the message
///
/// @return A j1939_message_t object fully initialized with sockaddr_can and data values.
-std::shared_ptr<j1939_message_t> j1939_message_t::convert_from_addr(struct sockaddr_can& addr, uint8_t (&data)[128],size_t nbytes, uint64_t timestamp)
+std::shared_ptr<j1939_message_t> j1939_message_t::convert_from_addr(struct sockaddr_can& addr, uint8_t (&data)[128], size_t nbytes, uint64_t timestamp)
{
int i;
uint32_t length = 0;
@@ -112,7 +112,7 @@ std::shared_ptr<j1939_message_t> j1939_message_t::convert_from_addr(struct socka
data_vector.clear();
std::string data_string;
- data_string = converter_t::to_hex(data,length);
+ data_string = converter_t::to_hex(data, length);
for(i=0;i<length;i++)
{
@@ -122,7 +122,7 @@ std::shared_ptr<j1939_message_t> j1939_message_t::convert_from_addr(struct socka
AFB_DEBUG("Found pgn: %X, length: %X, data %s",
addr.can_addr.j1939.pgn, length, data_string.c_str());
- return std::make_shared<j1939_message_t>(j1939_message_t(length, data_vector, timestamp,addr.can_addr.j1939.name,addr.can_addr.j1939.pgn,addr.can_addr.j1939.addr));
+ return std::make_shared<j1939_message_t>(j1939_message_t(length, data_vector, timestamp, addr.can_addr.j1939.name, addr.can_addr.j1939.pgn, addr.can_addr.j1939.addr));
}
/// @brief Test if members pgn_ and length are set.
diff --git a/low-can-binding/can/message/message.cpp b/low-can-binding/can/message/message.cpp
index 2496b672..2a23ca5a 100644
--- a/low-can-binding/can/message/message.cpp
+++ b/low-can-binding/can/message/message.cpp
@@ -83,7 +83,7 @@ const uint8_t* message_t::get_data() const
/// @return pointer to the first element
/// of class member data_
///
-const std::vector<uint8_t> message_t::get_data_vector(int start,int end) const
+const std::vector<uint8_t> message_t::get_data_vector(int start, int end) const
{
std::vector<uint8_t> ret;
if(start >= 0)
@@ -105,7 +105,7 @@ const std::vector<uint8_t> message_t::get_data_vector(int start,int end) const
}
else
{
- AFB_ERROR("Error index to get data vector, [%d-%d] - for length %d",start,end,length_);
+ AFB_ERROR("Error index to get data vector, [%d-%d] - for length %d", start, end, length_);
}
return ret;
}
diff --git a/low-can-binding/can/message/message.hpp b/low-can-binding/can/message/message.hpp
index 1a31a8d4..7f13ac47 100644
--- a/low-can-binding/can/message/message.hpp
+++ b/low-can-binding/can/message/message.hpp
@@ -66,7 +66,7 @@ public:
int get_sub_id() const;
const uint8_t* get_data() const;
const std::vector<uint8_t> get_data_vector() const;
- const std::vector<uint8_t> get_data_vector(int start,int end) const;
+ const std::vector<uint8_t> get_data_vector(int start, int end) const;
uint32_t get_length() const;
uint64_t get_timestamp() const;
diff --git a/low-can-binding/can/signals.cpp b/low-can-binding/can/signals.cpp
index 7d3b7331..57aefa55 100644..100755
--- a/low-can-binding/can/signals.cpp
+++ b/low-can-binding/can/signals.cpp
@@ -44,7 +44,7 @@ signal_t::signal_t(
signal_decoder decoder,
signal_encoder encoder,
bool received,
- std::pair<bool,int> multiplex,
+ std::pair<bool, int> multiplex,
bool is_big_endian,
bool is_signed,
std::string unit)
@@ -220,7 +220,7 @@ void signal_t::set_timestamp(uint64_t timestamp)
frequency_.tick(timestamp);
}
-std::pair<bool,int> signal_t::get_multiplex() const
+std::pair<bool, int> signal_t::get_multiplex() const
{
return multiplex_;
}
diff --git a/low-can-binding/can/signals.hpp b/low-can-binding/can/signals.hpp
index 2fcc27ed..32cd7606 100644..100755
--- a/low-can-binding/can/signals.hpp
+++ b/low-can-binding/can/signals.hpp
@@ -96,7 +96,7 @@ private:
bool received_; /*!< received_ - True if this signal has ever been received.*/
float last_value_; /*!< lastValue_ - The last received value of the signal. If 'received' is false,
* this value is undefined. */
- std::pair<bool,int> multiplex_; /*!< multiplex_ - If bool is false and int is 0 is not a multiplex signal
+ std::pair<bool, int> multiplex_; /*!< multiplex_ - If bool is false and int is 0 is not a multiplex signal
If bool is true, that indicate that is a multiplexor
If int is different of 0, that indicate the link with a multiplexor */
bool is_big_endian_; /*!< is_big_endian - True if the signal's data are meant to be read as a big_endian */
@@ -121,7 +121,7 @@ public:
signal_decoder decoder,
signal_encoder encoder,
bool received,
- std::pair<bool,int> multiplex,
+ std::pair<bool, int> multiplex,
bool is_big_endian,
bool is_signed,
std::string unit);
@@ -162,7 +162,7 @@ public:
bool get_received() const;
float get_last_value() const;
std::pair<float, uint64_t> get_last_value_with_timestamp() const;
- std::pair<bool,int> get_multiplex() const;
+ std::pair<bool, int> get_multiplex() const;
bool get_is_big_endian() const;
bool get_is_signed() const;
const std::string get_unit() const;
diff --git a/low-can-binding/utils/openxc-utils.cpp b/low-can-binding/utils/openxc-utils.cpp
index e52676e1..b88c45d9 100644
--- a/low-can-binding/utils/openxc-utils.cpp
+++ b/low-can-binding/utils/openxc-utils.cpp
@@ -401,7 +401,7 @@ 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);
+ 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()));
}
diff --git a/low-can-binding/utils/socketcan-isotp.cpp b/low-can-binding/utils/socketcan-isotp.cpp
index a3792a70..928e8c72 100644
--- a/low-can-binding/utils/socketcan-isotp.cpp
+++ b/low-can-binding/utils/socketcan-isotp.cpp
@@ -36,7 +36,7 @@ namespace utils
int socketcan_isotp_t::open(std::string device_name)
{
AFB_WARNING("NOT USE THIS FUNCTION !");
- return open(device_name,NO_CAN_ID,NO_CAN_ID);
+ return open(device_name, NO_CAN_ID, NO_CAN_ID);
}
/**
@@ -59,11 +59,11 @@ namespace utils
return -1;
}
- if(define_tx_address(device_name,rx_id,tx_id) < 0)
+ if(define_tx_address(device_name, rx_id, tx_id) < 0)
return -1;
struct can_isotp_options opts;
- memset(&opts,0,sizeof(opts));
+ memset(&opts, 0, sizeof(opts));
setopt(SOL_CAN_ISOTP, CAN_ISOTP_OPTS, &opts, sizeof(opts));
if(bind((struct sockaddr *)&tx_address_, sizeof(tx_address_)) < 0)
@@ -86,7 +86,7 @@ namespace utils
std::shared_ptr<can_message_t> cm = std::make_shared<can_message_t>();
uint8_t msg[MAX_ISOTP_FRAMES];
- ssize_t nbytes = read(socket(),msg,MAX_ISOTP_FRAMES);
+ ssize_t nbytes = read(socket(), msg, MAX_ISOTP_FRAMES);
cm->set_id(tx_address_.can_addr.tp.rx_id);
@@ -101,8 +101,8 @@ namespace utils
data.push_back(msg[i]);
std::string data_string;
- data_string = converter_t::to_hex(msg,nbytes);
- AFB_DEBUG("DATA ISO TP for id : %x = %s",cm->get_id(),data_string.c_str());
+ data_string = converter_t::to_hex(msg, nbytes);
+ AFB_DEBUG("DATA ISO TP for id : %x = %s", cm->get_id(), data_string.c_str());
cm->set_data(data);
@@ -126,7 +126,7 @@ namespace utils
size_t size = m.get_length();
if(size < MAX_ISOTP_FRAMES)
{
- ssize_t ret = write(socket(),m.get_data(),size);
+ ssize_t ret = write(socket(), m.get_data(), size);
if(ret < 0)
{
AFB_ERROR("Error sending : %i %s", errno, ::strerror(errno));
@@ -134,7 +134,7 @@ namespace utils
}
if(ret != size)
- AFB_WARNING("ISOTP wrote only %zd byte",ret);
+ AFB_WARNING("ISOTP wrote only %zd byte", ret);
}
else
{
diff --git a/low-can-binding/utils/socketcan-j1939/socketcan-j1939-addressclaiming.cpp b/low-can-binding/utils/socketcan-j1939/socketcan-j1939-addressclaiming.cpp
index 83ba71a3..ebb39742 100644
--- a/low-can-binding/utils/socketcan-j1939/socketcan-j1939-addressclaiming.cpp
+++ b/low-can-binding/utils/socketcan-j1939/socketcan-j1939-addressclaiming.cpp
@@ -26,7 +26,7 @@ namespace utils
*/
socketcan_j1939_addressclaiming_t::socketcan_j1939_addressclaiming_t():
socketcan_j1939_t(),
- table_j1939_address_{{std::make_pair(0,false)}},
+ table_j1939_address_{{std::make_pair(0, false)}},
signal_stop_{false},
claiming_state_{claiming_state::INITIAL}
{}
@@ -64,7 +64,7 @@ namespace utils
if(jm->get_addr() != current_address_)
{
- save_addr_name(jm->get_addr(),jm->get_name());
+ save_addr_name(jm->get_addr(), jm->get_name());
return invalid_message;
}
@@ -76,7 +76,7 @@ namespace utils
return invalid_message;
}
- save_addr_name(jm->get_addr(),jm->get_name());
+ save_addr_name(jm->get_addr(), jm->get_name());
if(timer_handle_->evtSource)
@@ -97,7 +97,7 @@ namespace utils
AFB_DEBUG("Address colision");
if(jm->get_name() > htole64(J1939_NAME_ECU))
{
- if(claim_address(false,false) < 0)
+ if(claim_address(false, false) < 0)
{
AFB_ERROR("Claim address failed");
change_state(claiming_state::INVALID);
@@ -106,9 +106,9 @@ namespace utils
return invalid_message;
}
- save_addr_name(jm->get_addr(),jm->get_name());
+ save_addr_name(jm->get_addr(), jm->get_name());
- if(claim_address(false,true) < 0)
+ if(claim_address(false, true) < 0)
{
AFB_ERROR("Claim address failed");
change_state(claiming_state::INVALID);
@@ -140,7 +140,7 @@ namespace utils
else
{
for (int i = start_addr; i <= end_addr; i++)
- table_j1939_address_[i] = std::make_pair(0,true);
+ table_j1939_address_[i] = std::make_pair(0, true);
}
}
}
@@ -152,18 +152,18 @@ namespace utils
* @param name The name of the ECU that is in the address
* @return int 0 if save is ok
*/
- int socketcan_j1939_addressclaiming_t::save_addr_name(uint8_t addr,name_t name)
+ int socketcan_j1939_addressclaiming_t::save_addr_name(uint8_t addr, name_t name)
{
if(addr < J1939_IDLE_ADDR)
{
if(table_j1939_address_[addr].first < name)
{
table_j1939_address_[addr].first = name;
- AFB_DEBUG("[socketcan-j1939-addressclaiming][save_addr_name] NAME : %x <--> ADDR : %d",(unsigned int)name,addr);
+ AFB_DEBUG("[socketcan-j1939-addressclaiming][save_addr_name] NAME : %x <--> ADDR : %d",(unsigned int)name, addr);
}
else if(table_j1939_address_[addr].first == name)
{
- AFB_WARNING("Name %x has already adress %d",(unsigned int)name,addr);
+ AFB_WARNING("Name %x has already adress %d",(unsigned int)name, addr);
}
}
else
@@ -216,20 +216,20 @@ namespace utils
socketcan_j1939_addressclaiming_t *addressclaiming_socket = (socketcan_j1939_addressclaiming_t*) timerhandle->context;
// If the cache is cleared :
addressclaiming_socket->change_state(claiming_state::OPERATIONAL);
- addressclaiming_socket->save_addr_name(addressclaiming_socket->current_address_,htole64(J1939_NAME_ECU));
+ addressclaiming_socket->save_addr_name(addressclaiming_socket->current_address_, htole64(J1939_NAME_ECU));
AFB_DEBUG("Get address %d for this ecu", addressclaiming_socket->current_address_);
/*Else :
uint8_t data[3]= { 0, 0, 0, };
- std::vector<uint8_t> data_v(data,data+3);
- int res = addressclaiming_socket->write_j1939_message(J1939_PGN_REQUEST,data_v,3);
+ std::vector<uint8_t> data_v(data, data+3);
+ int res = addressclaiming_socket->write_j1939_message(J1939_PGN_REQUEST, data_v, 3);
if(res < 0)
{
if(res == -99)
{
- addressclaiming_socket->save_addr_name(addressclaiming_socket->current_address_,htole64(1));
+ addressclaiming_socket->save_addr_name(addressclaiming_socket->current_address_, htole64(1));
AFB_DEBUG("Address busy but no claming request from other ECU");
- addressclaiming_socket->claim_address(false,true);
+ addressclaiming_socket->claim_address(false, true);
}
else
{
@@ -239,7 +239,7 @@ namespace utils
else
{
addressclaiming_socket->change_state(claiming_state::OPERATIONAL);
- addressclaiming_socket->save_addr_name(addressclaiming_socket->current_address_,htole64(J1939_NAME_ECU));
+ addressclaiming_socket->save_addr_name(addressclaiming_socket->current_address_, htole64(J1939_NAME_ECU));
AFB_DEBUG("Get address %d for this ecu", addressclaiming_socket->current_address_);
}*/
@@ -268,7 +268,7 @@ namespace utils
* @param new_address If true, claim a new address, else only resend a claim with same address
* @return int -1 if fail
*/
- int socketcan_j1939_addressclaiming_t::claim_address(bool first_claim,bool new_address)
+ int socketcan_j1939_addressclaiming_t::claim_address(bool first_claim, bool new_address)
{
if(new_address)
{
@@ -286,7 +286,7 @@ namespace utils
if(first_claim)
{
- int ret = socketcan_j1939_t::open(device_name_,htole64(J1939_NAME_ECU),J1939_NO_PGN,current_address_);
+ int ret = socketcan_j1939_t::open(device_name_, htole64(J1939_NAME_ECU), J1939_NO_PGN, current_address_);
if(ret < 0)
{
@@ -295,7 +295,7 @@ namespace utils
}
AFB_DEBUG("[socketcan-j1939-addressclaiming][claim_address] Success open socket address claiming");
- add_filter(J1939_NO_NAME,J1939_PGN_ADDRESS_CLAIMED,J1939_NO_ADDR,J1939_NO_NAME,J1939_PGN_PDU1_MAX,J1939_NO_ADDR);
+ add_filter(J1939_NO_NAME, J1939_PGN_ADDRESS_CLAIMED, J1939_NO_ADDR, J1939_NO_NAME, J1939_PGN_PDU1_MAX, J1939_NO_ADDR);
define_opt();
}
else
@@ -374,7 +374,7 @@ namespace utils
{
device_name_ = device_name;
initialize_table_j1939_address();
- if(claim_address(true,true) < 0)
+ if(claim_address(true, true) < 0)
{
AFB_ERROR("Claim address failed");
return -1;
diff --git a/low-can-binding/utils/socketcan-j1939/socketcan-j1939-addressclaiming.hpp b/low-can-binding/utils/socketcan-j1939/socketcan-j1939-addressclaiming.hpp
index 5a950572..e946123a 100644
--- a/low-can-binding/utils/socketcan-j1939/socketcan-j1939-addressclaiming.hpp
+++ b/low-can-binding/utils/socketcan-j1939/socketcan-j1939-addressclaiming.hpp
@@ -33,10 +33,10 @@ namespace utils
std::pair<uint64_t, bool> table_j1939_address_[J1939_IDLE_ADDR];
private:
- int claim_address(bool first_claim,bool new_address);
+ int claim_address(bool first_claim, bool new_address);
int pgn_request();
void initialize_table_j1939_address();
- int save_addr_name(uint8_t addr,name_t name);
+ int save_addr_name(uint8_t addr, name_t name);
uint8_t choose_new_address();
uint8_t get_addr_table(name_t name);
void change_state(claiming_state new_state);
diff --git a/low-can-binding/utils/socketcan-j1939/socketcan-j1939-data.cpp b/low-can-binding/utils/socketcan-j1939/socketcan-j1939-data.cpp
index 4fd2b264..08c13752 100644
--- a/low-can-binding/utils/socketcan-j1939/socketcan-j1939-data.cpp
+++ b/low-can-binding/utils/socketcan-j1939/socketcan-j1939-data.cpp
@@ -31,11 +31,11 @@ namespace utils
*/
int socketcan_j1939_data_t::open(std::string device_name, pgn_t pgn)
{
- int ret = socketcan_j1939_t::open(device_name,htole64(J1939_NAME_ECU),pgn,J1939_NO_ADDR);
+ int ret = socketcan_j1939_t::open(device_name, htole64(J1939_NAME_ECU), pgn, J1939_NO_ADDR);
if(ret >= 0)
{
if(tx_address_.can_addr.j1939.pgn != J1939_NO_PGN)
- add_filter(J1939_NO_NAME,tx_address_.can_addr.j1939.pgn,J1939_NO_ADDR,J1939_NO_NAME,J1939_NO_PGN,J1939_NO_ADDR);
+ add_filter(J1939_NO_NAME, tx_address_.can_addr.j1939.pgn, J1939_NO_ADDR, J1939_NO_NAME, J1939_NO_PGN, J1939_NO_ADDR);
define_opt();
}
diff --git a/low-can-binding/utils/socketcan-j1939/socketcan-j1939.cpp b/low-can-binding/utils/socketcan-j1939/socketcan-j1939.cpp
index ea68f20a..38163254 100644
--- a/low-can-binding/utils/socketcan-j1939/socketcan-j1939.cpp
+++ b/low-can-binding/utils/socketcan-j1939/socketcan-j1939.cpp
@@ -42,8 +42,8 @@ namespace utils
*/
void socketcan_j1939_t::add_filter(name_t name, pgn_t pgn, uint8_t addr, name_t name_mask, pgn_t pgn_mask, uint8_t addr_mask)
{
- // AFB_DEBUG("[socketcan_j1939_t][add_filter] PGN : %" PRIu32 " ; NAME : %" PRIu64 " ; ADDR : %" PRIu8,pgn,(long unsigned int)name,addr);
- // AFB_DEBUG("PGN_MASK : %" PRIu32 " ; NAME_MASK : %" PRIu64 "; ADDR_MASK : %" PRIu8,pgn_mask,(long unsigned int)name_mask,addr_mask);
+ // AFB_DEBUG("[socketcan_j1939_t][add_filter] PGN : %" PRIu32 " ; NAME : %" PRIu64 " ; ADDR : %" PRIu8, pgn,(long unsigned int)name, addr);
+ // AFB_DEBUG("PGN_MASK : %" PRIu32 " ; NAME_MASK : %" PRIu64 "; ADDR_MASK : %" PRIu8, pgn_mask,(long unsigned int)name_mask, addr_mask);
int filter_on = 0;
struct j1939_filter filter;
memset(&filter, 0, sizeof(filter));
@@ -152,7 +152,7 @@ namespace utils
*/
int socketcan_j1939_t::open(std::string device_name)
{
- return open(device_name,0,0,0);
+ return open(device_name, 0, 0, 0);
}
/**
@@ -169,7 +169,7 @@ namespace utils
socket_ = socketcan_t::open(PF_CAN, SOCK_DGRAM, CAN_J1939);
- define_tx_address(device_name,name,pgn,addr);
+ define_tx_address(device_name, name, pgn, addr);
if(bind((struct sockaddr *)&tx_address_, sizeof(tx_address_)) < 0)
{
@@ -230,7 +230,7 @@ namespace utils
int socketcan_j1939_t::write_j1939_message(pgn_t pgn, std::vector<uint8_t> &data, uint32_t len_data)
{
j1939_message_t msg = j1939_message_t(len_data, data, 0, 0, pgn, 0);
- msg.set_sockname(pgn,J1939_NO_NAME,J1939_NO_ADDR);
+ msg.set_sockname(pgn, J1939_NO_NAME, J1939_NO_ADDR);
return write_message(msg);
}
diff --git a/low-can-binding/utils/socketcan.cpp b/low-can-binding/utils/socketcan.cpp
index d72f108d..50dfafb3 100644
--- a/low-can-binding/utils/socketcan.cpp
+++ b/low-can-binding/utils/socketcan.cpp
@@ -117,7 +117,7 @@ namespace utils
{
if(write_message(vobj[i])<0)
{
- AFB_ERROR("Error send message %d",i);
+ AFB_ERROR("Error send message %d", i);
return -1;
}
}