[FEC] Fix missing parentheses in macro
This commit is contained in:
parent
8068bcc356
commit
f045ed10b5
2 changed files with 14 additions and 14 deletions
|
@ -402,7 +402,7 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) {
|
||||||
uint16_t stuffedFrameBuffPos = stuffedFrameBuffLenBits + 7 - 2*(stuffedFrameBuffLenBits%8);
|
uint16_t stuffedFrameBuffPos = stuffedFrameBuffLenBits + 7 - 2*(stuffedFrameBuffLenBits%8);
|
||||||
if((frameBuff[i] >> shift) & 0x01) {
|
if((frameBuff[i] >> shift) & 0x01) {
|
||||||
// copy 1 and increment counter
|
// copy 1 and increment counter
|
||||||
SET_BIT_IN_ARRAY(stuffedFrameBuff, stuffedFrameBuffPos);
|
SET_BIT_IN_ARRAY_MSB(stuffedFrameBuff, stuffedFrameBuffPos);
|
||||||
stuffedFrameBuffLenBits++;
|
stuffedFrameBuffLenBits++;
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
|
@ -412,14 +412,14 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) {
|
||||||
stuffedFrameBuffPos = stuffedFrameBuffLenBits + 7 - 2*(stuffedFrameBuffLenBits%8);
|
stuffedFrameBuffPos = stuffedFrameBuffLenBits + 7 - 2*(stuffedFrameBuffLenBits%8);
|
||||||
|
|
||||||
// insert 0 and reset counter
|
// insert 0 and reset counter
|
||||||
CLEAR_BIT_IN_ARRAY(stuffedFrameBuff, stuffedFrameBuffPos);
|
CLEAR_BIT_IN_ARRAY_MSB(stuffedFrameBuff, stuffedFrameBuffPos);
|
||||||
stuffedFrameBuffLenBits++;
|
stuffedFrameBuffLenBits++;
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// copy 0 and reset counter
|
// copy 0 and reset counter
|
||||||
CLEAR_BIT_IN_ARRAY(stuffedFrameBuff, stuffedFrameBuffPos);
|
CLEAR_BIT_IN_ARRAY_MSB(stuffedFrameBuff, stuffedFrameBuffPos);
|
||||||
stuffedFrameBuffLenBits++;
|
stuffedFrameBuffLenBits++;
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
|
@ -454,20 +454,20 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) {
|
||||||
for(size_t i = preambleLen + 1; i < stuffedFrameBuffLen*8; i++) {
|
for(size_t i = preambleLen + 1; i < stuffedFrameBuffLen*8; i++) {
|
||||||
size_t currBitPos = i + 7 - 2*(i%8);
|
size_t currBitPos = i + 7 - 2*(i%8);
|
||||||
size_t prevBitPos = (i - 1) + 7 - 2*((i - 1)%8);
|
size_t prevBitPos = (i - 1) + 7 - 2*((i - 1)%8);
|
||||||
if(TEST_BIT_IN_ARRAY(stuffedFrameBuff, currBitPos)) {
|
if(TEST_BIT_IN_ARRAY_MSB(stuffedFrameBuff, currBitPos)) {
|
||||||
// bit is 1, no change, copy previous bit
|
// bit is 1, no change, copy previous bit
|
||||||
if(TEST_BIT_IN_ARRAY(stuffedFrameBuff, prevBitPos)) {
|
if(TEST_BIT_IN_ARRAY_MSB(stuffedFrameBuff, prevBitPos)) {
|
||||||
SET_BIT_IN_ARRAY(stuffedFrameBuff, currBitPos);
|
SET_BIT_IN_ARRAY_MSB(stuffedFrameBuff, currBitPos);
|
||||||
} else {
|
} else {
|
||||||
CLEAR_BIT_IN_ARRAY(stuffedFrameBuff, currBitPos);
|
CLEAR_BIT_IN_ARRAY_MSB(stuffedFrameBuff, currBitPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// bit is 0, transition, copy inversion of the previous bit
|
// bit is 0, transition, copy inversion of the previous bit
|
||||||
if(TEST_BIT_IN_ARRAY(stuffedFrameBuff, prevBitPos)) {
|
if(TEST_BIT_IN_ARRAY_MSB(stuffedFrameBuff, prevBitPos)) {
|
||||||
CLEAR_BIT_IN_ARRAY(stuffedFrameBuff, currBitPos);
|
CLEAR_BIT_IN_ARRAY_MSB(stuffedFrameBuff, currBitPos);
|
||||||
} else {
|
} else {
|
||||||
SET_BIT_IN_ARRAY(stuffedFrameBuff, currBitPos);
|
SET_BIT_IN_ARRAY_MSB(stuffedFrameBuff, currBitPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,10 +72,10 @@ class RadioLibBCH {
|
||||||
extern RadioLibBCH RadioLibBCHInstance;
|
extern RadioLibBCH RadioLibBCHInstance;
|
||||||
|
|
||||||
// macros to access bits in byte array, from http://www.mathcs.emory.edu/~cheung/Courses/255/Syllabus/1-C-intro/bit-array.html
|
// macros to access bits in byte array, from http://www.mathcs.emory.edu/~cheung/Courses/255/Syllabus/1-C-intro/bit-array.html
|
||||||
#define SET_BIT_IN_ARRAY(A, k) ( A[(k/8)] |= (1 << (k%8)) )
|
#define SET_BIT_IN_ARRAY_MSB(A, k) ( A[((k)/8)] |= (1 << ((k)%8)) )
|
||||||
#define CLEAR_BIT_IN_ARRAY(A, k) ( A[(k/8)] &= ~(1 << (k%8)) )
|
#define CLEAR_BIT_IN_ARRAY_MSB(A, k) ( A[((k)/8)] &= ~(1 << ((k)%8)) )
|
||||||
#define TEST_BIT_IN_ARRAY(A, k) ( A[(k/8)] & (1 << (k%8)) )
|
#define TEST_BIT_IN_ARRAY_MSB(A, k) ( A[((k)/8)] & (1 << ((k)%8)) )
|
||||||
#define GET_BIT_IN_ARRAY(A, k) ( (A[(k/8)] & (1 << (k%8))) ? 1 : 0 )
|
#define GET_BIT_IN_ARRAY_MSB(A, k) ( (A[((k)/8)] & (1 << ((k)%8))) ? 1 : 0 )
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue