aboutsummaryrefslogtreecommitdiffstats
path: root/low-can-binding/utils/socketcan-j1939
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2019-12-04 17:54:38 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2020-01-09 14:38:26 +0100
commite1caf27db81e9897af7512a0b47e0783593833d5 (patch)
treef3e6134048fc2f8cfbbb2dbf2399669c331cbea5 /low-can-binding/utils/socketcan-j1939
parent2e10ab5760e5d2a6abab7acf47f781442308362f (diff)
All: Make format coherent with the whole project
Add a space after a comma Change some aligments Bug-AGL: SPEC-2988 Change-Id: I5069120f4bbb33742bb4990e2e1f391ec8d5eeb6 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'low-can-binding/utils/socketcan-j1939')
-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
4 files changed, 29 insertions, 29 deletions
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);
}