1- #include " CANDatabaseAnalysis.h"
2- #include " CANDatabase.h"
1+ #include " cpp-can-parser/ CANDatabaseAnalysis.h"
2+ #include " cpp-can-parser/ CANDatabase.h"
33#include < algorithm>
44#include < cmath>
55#include < tuple>
@@ -48,28 +48,28 @@ struct SignalLayoutEntry {
4848
4949SignalRanges big_endian_ranges (const CANSignal& src) {
5050 SignalRanges result;
51-
52- // For BigEndian signals, the start bit already represents the left mostbit
51+
52+ // For BigEndian signals, the start bit already represents the left mostbit
5353 // ----------------- -----------------
5454 // |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*|
5555 // ----------------- -----------------
5656 // 7 0 15 8
57-
57+
5858 unsigned bitsLeft = src.length ();
5959 unsigned currentPos = src.start_bit ();
60-
60+
6161 for (unsigned current_byte = src.start_bit () / 8 ; bitsLeft > 0 ; current_byte++) {
6262 char lbit = currentPos % 8 ;
6363 char rbit = std::max<char >(-1 , lbit - bitsLeft);
6464
6565 // The static_cast are not "necessary" but it removes some warnings
66- result.push_back ({ static_cast <uint8_t >(current_byte),
66+ result.push_back ({ static_cast <uint8_t >(current_byte),
6767 lbit, rbit });
68-
68+
6969 bitsLeft -= lbit - rbit;
70- currentPos += (lbit - rbit);
70+ currentPos += (lbit - rbit);
7171 }
72-
72+
7373 return result;
7474}
7575
@@ -78,22 +78,22 @@ SignalRanges little_endian_ranges(const CANSignal& src) {
7878 // ----------------- -----------------
7979 // |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*|
8080 // ----------------- -----------------
81- // 0 7 8 15
82- //
81+ // 0 7 8 15
82+ //
8383 // The signal can be found from the start bit + read to the right.
8484 SignalRanges result;
8585
8686 if (src.length () == 0 ) // length is 0, we return an empty result.
8787 return result;
88-
88+
8989 unsigned bitsLeft = src.length ();
9090 unsigned currentPos = src.start_bit ();
9191 for (unsigned current_byte = src.start_bit () / 8 ; bitsLeft > 0 ; current_byte++) {
9292 char lbit = currentPos % 8 ;
9393 char rbit = std::min<char >(lbit + bitsLeft, 8 );
9494
9595 // The static_cast are not "necessary" but it removes some warnings
96- result.push_back ({ static_cast <uint8_t >(current_byte),
96+ result.push_back ({ static_cast <uint8_t >(current_byte),
9797 lbit, rbit });
9898
9999 bitsLeft -= rbit - lbit;
@@ -107,7 +107,7 @@ std::vector<SignalLayoutEntry> compute_layout(const CANFrame& src) {
107107 std::vector<SignalLayoutEntry> result;
108108
109109 for (const auto & signal: src) {
110- const CANSignal& sig = signal.second ;
110+ const CANSignal& sig = signal.second ;
111111
112112 if (sig.endianness () == CANSignal::BigEndian) {
113113 auto ranges = big_endian_ranges (sig);
@@ -126,12 +126,12 @@ std::vector<SignalLayoutEntry> compute_layout(const CANFrame& src) {
126126bool overlap (const SignalLayoutEntry& e1 , const SignalLayoutEntry& e2 ) {
127127 for (const SignalRange& r1 : e1 .ranges ) {
128128 for (const SignalRange& r2: e2 .ranges ) {
129- // Find if r2 shares a SignalRange with the same byte with r1
129+ // Find if r2 shares a SignalRange with the same byte with r1
130130 if (r1.byte != r2.byte )
131131 continue ;
132-
132+
133133 // Now we know that the SignalRange(s) share a common byte
134-
134+
135135 // ordered.first is the leftmost SignalRange in the byte
136136 // ordered.second is the rightmost SignalRange in the byte
137137 auto ordered = std::minmax (r1, r2, [](const SignalRange& r, const SignalRange& rr) {
@@ -154,7 +154,7 @@ bool CppCAN::analysis::is_frame_layout_ok(const CANFrame& src) {
154154 for (size_t i = 0 ; i < layout.size (); i++) {
155155 for (size_t j = i + 1 ; j < layout.size (); j++) {
156156 if (overlap (layout[i], layout[j])) {
157- return false ;
157+ return false ;
158158 }
159159 }
160160 }
@@ -179,7 +179,7 @@ bool CppCAN::analysis::is_frame_layout_ok(const CANFrame& src, std::vector<std::
179179 if (overlap (layout[i], layout[j])) {
180180 report_issue (i, *layout[i].src_signal );
181181 report_issue (j, *layout[j].src_signal );
182- }
182+ }
183183 }
184184 }
185185
0 commit comments