summaryrefslogtreecommitdiffstats
path: root/low-can-binding/utils/socketcan-j1939
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/socketcan-j1939
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/socketcan-j1939')
-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
3 files changed, 11 insertions, 43 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 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)
{