aboutsummaryrefslogtreecommitdiffstats
path: root/low-can-binding/utils
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2019-11-05 19:33:29 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2020-01-08 00:17:29 +0100
commit64691cf96f9c4d7ff59dbd49e1fe01d26c1a00f6 (patch)
tree6e32fa6d9574223d5560508c76ce31d50bc42a14 /low-can-binding/utils
parent3fb6ac3c3670499bee4ce02ff7813739017e8b8f (diff)
all: Format one line 'if' or 'for' statement.
Bug-AGL: SPEC-2988 Change-Id: Ic3b9670a2ce9e982220c54f3632f690ee4eea686 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'low-can-binding/utils')
-rw-r--r--low-can-binding/utils/converter.cpp7
-rw-r--r--low-can-binding/utils/converter.hpp2
-rw-r--r--low-can-binding/utils/openxc-utils.cpp2
-rw-r--r--low-can-binding/utils/socketcan-isotp.cpp10
-rw-r--r--low-can-binding/utils/socketcan-j1939/socketcan-j1939-addressclaiming.cpp12
-rw-r--r--low-can-binding/utils/socketcan-j1939/socketcan-j1939-data.cpp3
-rw-r--r--low-can-binding/utils/socketcan-j1939/socketcan-j1939.cpp39
7 files changed, 16 insertions, 59 deletions
diff --git a/low-can-binding/utils/converter.cpp b/low-can-binding/utils/converter.cpp
index 5cfc8f5c..e3db7f33 100644
--- a/low-can-binding/utils/converter.cpp
+++ b/low-can-binding/utils/converter.cpp
@@ -32,9 +32,8 @@ std::string converter_t::to_hex(const uint8_t data[], const size_t length)
std::stringstream stream;
stream << std::hex << std::setfill('0');
for(int i = 0; i < length; i++)
- {
stream << std::hex << ((int) data[i]);
- }
+
return stream.str();
}
@@ -49,10 +48,10 @@ std::string converter_t::to_hex(const uint8_t data[], const size_t length)
* @param new_start_bit The first bit of the signal in the frame
* @param new_end_bit The last bit of the signal in the frame
*/
-void converter_t::signal_to_bits_bytes(uint32_t bit_position, uint32_t bit_size, int &new_start_byte, int &new_end_byte, int &new_start_bit, int &new_end_bit)
+void converter_t::signal_to_bits_bytes(uint32_t bit_position, uint32_t bit_size, int &new_start_byte, int &new_end_byte, uint8_t &new_start_bit, uint8_t &new_end_bit)
{
new_start_byte = bit_position >> 3;
new_start_bit = bit_position % 8;
new_end_byte = (bit_position + bit_size - 1) >> 3;
new_end_bit = (bit_position + bit_size - 1) % 8;
-} \ No newline at end of file
+}
diff --git a/low-can-binding/utils/converter.hpp b/low-can-binding/utils/converter.hpp
index f388fd0a..d24096a6 100644
--- a/low-can-binding/utils/converter.hpp
+++ b/low-can-binding/utils/converter.hpp
@@ -23,5 +23,5 @@ class converter_t
{
public:
static std::string to_hex(const uint8_t data[], const size_t length);
- static void signal_to_bits_bytes(uint32_t bit_position, uint32_t bit_size, int &new_start_byte, int &new_end_byte, int &new_start_bit, int &new_end_bit);
+ static void signal_to_bits_bytes(uint32_t bit_position, uint32_t bit_size, int &new_start_byte, int &new_end_byte, uint8_t &new_start_bit, uint8_t &new_end_bit);
};
diff --git a/low-can-binding/utils/openxc-utils.cpp b/low-can-binding/utils/openxc-utils.cpp
index db19d1f3..e52676e1 100644
--- a/low-can-binding/utils/openxc-utils.cpp
+++ b/low-can-binding/utils/openxc-utils.cpp
@@ -237,9 +237,7 @@ const openxc_DynamicField build_DynamicField(std::vector<uint8_t> &array)
for(int i=0;i<size;i++)
- {
d.bytes_value[i] = array[i];
- }
return d;
}
diff --git a/low-can-binding/utils/socketcan-isotp.cpp b/low-can-binding/utils/socketcan-isotp.cpp
index 1aab9afa..a3792a70 100644
--- a/low-can-binding/utils/socketcan-isotp.cpp
+++ b/low-can-binding/utils/socketcan-isotp.cpp
@@ -60,9 +60,7 @@ namespace utils
}
if(define_tx_address(device_name,rx_id,tx_id) < 0)
- {
return -1;
- }
struct can_isotp_options opts;
memset(&opts,0,sizeof(opts));
@@ -100,9 +98,7 @@ namespace utils
std::vector<uint8_t> data;
for (int i=0; i < nbytes; i++)
- {
data.push_back(msg[i]);
- }
std::string data_string;
data_string = converter_t::to_hex(msg,nbytes);
@@ -138,9 +134,7 @@ namespace utils
}
if(ret != size)
- {
AFB_WARNING("ISOTP wrote only %zd byte",ret);
- }
}
else
{
@@ -171,9 +165,7 @@ namespace utils
close();
}
else
- {
tx_address_.can_ifindex = ifr.ifr_ifindex;
- }
tx_address_.can_family = AF_CAN;
@@ -188,4 +180,4 @@ namespace utils
return 0;
}
-} \ No newline at end of file
+}
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 df994f59..83ba71a3 100644
--- a/low-can-binding/utils/socketcan-j1939/socketcan-j1939-addressclaiming.cpp
+++ b/low-can-binding/utils/socketcan-j1939/socketcan-j1939-addressclaiming.cpp
@@ -139,9 +139,8 @@ namespace utils
}
else
{
- for (int i = start_addr; i <= end_addr; i++) {
+ for (int i = start_addr; i <= end_addr; i++)
table_j1939_address_[i] = std::make_pair(0,true);
- }
}
}
}
@@ -187,9 +186,7 @@ namespace utils
if(table_j1939_address_[i].second && i!=current_address_)
{
if( table_j1939_address_[i].first >= htole64(J1939_NAME_ECU) || table_j1939_address_[i].first == 0)
- {
return (uint8_t) i;
- }
}
}
return J1939_IDLE_ADDR;
@@ -344,9 +341,8 @@ namespace utils
int ret = sendto(socket_, dat, sizeof(dat), 0, (const struct sockaddr *)&peername, sizeof(peername));
if(ret < 0)
- {
AFB_ERROR("Error pgn_request()");
- }
+
return ret;
}
*/
@@ -362,9 +358,7 @@ namespace utils
for(int i = 0; i < J1939_IDLE_ADDR; i++)
{
if(table_j1939_address_[i].first == name)
- {
return (uint8_t) i;
- }
}
return J1939_IDLE_ADDR;
}
@@ -411,4 +405,4 @@ namespace utils
return claiming_state_;
}
-} \ No newline at end of file
+}
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 b2f17c6e..4fd2b264 100644
--- a/low-can-binding/utils/socketcan-j1939/socketcan-j1939-data.cpp
+++ b/low-can-binding/utils/socketcan-j1939/socketcan-j1939-data.cpp
@@ -35,9 +35,8 @@ namespace utils
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);
- }
+
define_opt();
}
return ret;
diff --git a/low-can-binding/utils/socketcan-j1939/socketcan-j1939.cpp b/low-can-binding/utils/socketcan-j1939/socketcan-j1939.cpp
index d3996d4c..ea68f20a 100644
--- a/low-can-binding/utils/socketcan-j1939/socketcan-j1939.cpp
+++ b/low-can-binding/utils/socketcan-j1939/socketcan-j1939.cpp
@@ -51,12 +51,9 @@ namespace utils
{
filter.name = name;
if(name_mask != J1939_NO_NAME)
- {
filter.name_mask = name_mask;
- } else
- {
+ else
filter.name_mask = ~0ULL;
- }
++filter_on;
}
@@ -64,30 +61,25 @@ namespace utils
{
filter.addr = addr;
if(addr_mask != J1939_NO_ADDR)
- {
filter.addr_mask = addr_mask;
- } else
- {
+ else
filter.addr_mask = ~0;
- }
+
++filter_on;
}
if (pgn <= J1939_PGN_MAX)
{
filter.pgn = pgn;
if(pgn_mask != J1939_NO_PGN)
- {
filter.pgn_mask = pgn_mask;
- } else
- {
+ else
filter.pgn_mask = ~0;
- }
+
++filter_on;
}
+
if(filter_on)
- {
setopt(SOL_CAN_J1939, SO_J1939_FILTER, &filter, sizeof(filter));
- }
}
/**
@@ -137,32 +129,18 @@ namespace utils
if(addr <= 0 || addr >= UINT8_MAX )
- {
tx_address_.can_addr.j1939.addr = J1939_NO_ADDR;
- }
else
- {
tx_address_.can_addr.j1939.addr = addr;
- }
-
if(name <= 0 || name >= UINT64_MAX )
- {
tx_address_.can_addr.j1939.name = J1939_NO_NAME;
- }
else
- {
tx_address_.can_addr.j1939.name = name;
- }
if(pgn <= 0 || pgn > J1939_PGN_MAX)
- {
tx_address_.can_addr.j1939.pgn = J1939_NO_PGN;
- }
else
- {
tx_address_.can_addr.j1939.pgn = pgn;
- }
-
}
@@ -229,9 +207,8 @@ namespace utils
ssize_t nbytes = recvfrom(socket_, &data, sizeof(data), flag, (struct sockaddr *)&peername, &peernamelen);
if(nbytes < 0)
- {
return nullptr;
- }
+
//AFB_DEBUG("Data available: %i bytes read", (int)nbytes);
struct timeval tv;
@@ -270,9 +247,7 @@ namespace utils
uint8_t data[jm.get_data_vector().size()];
for(int i=0; i<jm.get_data_vector().size(); i++)
- {
data[i] = jm.get_data_vector()[i];
- }
if (sendto(socket_, &data, sizeof(data), 0, (const struct sockaddr *)&sockname, sizeof(sockname)) < 0)
{