aboutsummaryrefslogtreecommitdiffstats
path: root/low-can-binding/utils
diff options
context:
space:
mode:
Diffstat (limited to 'low-can-binding/utils')
-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
7 files changed, 39 insertions, 39 deletions
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;
}
}