aboutsummaryrefslogtreecommitdiffstats
path: root/low-can-binding/utils/socketcan-j1939/socketcan-j1939.cpp
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/socketcan-j1939.cpp
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/socketcan-j1939.cpp')
-rw-r--r--low-can-binding/utils/socketcan-j1939/socketcan-j1939.cpp39
1 files changed, 7 insertions, 32 deletions
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)
{