M17: FrameDecoder: style formatting pass
This commit is contained in:
parent
79d2e9a27e
commit
5fe5cb287b
|
|
@ -8,8 +8,11 @@
|
||||||
# - AlignTrailingComments:
|
# - AlignTrailingComments:
|
||||||
# Kind: Always
|
# Kind: Always
|
||||||
# OverEmptyLines: 1
|
# OverEmptyLines: 1
|
||||||
|
# - BraceWrapping:
|
||||||
|
# AfterClass: true
|
||||||
# - Standard: c++14
|
# - Standard: c++14
|
||||||
# - BreakBeforeBinaryOperators: NonAssignment
|
# - BreakBeforeBinaryOperators: NonAssignment
|
||||||
|
# - PenaltyBreakAssignment: 30
|
||||||
# Original header below
|
# Original header below
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# SPDX-License-Identifier: GPL-2.0
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
|
@ -46,7 +49,7 @@ AlwaysBreakTemplateDeclarations: false
|
||||||
BinPackArguments: true
|
BinPackArguments: true
|
||||||
BinPackParameters: true
|
BinPackParameters: true
|
||||||
BraceWrapping:
|
BraceWrapping:
|
||||||
AfterClass: false
|
AfterClass: true
|
||||||
AfterControlStatement: false
|
AfterControlStatement: false
|
||||||
AfterEnum: false
|
AfterEnum: false
|
||||||
AfterFunction: true
|
AfterFunction: true
|
||||||
|
|
@ -105,7 +108,7 @@ ObjCSpaceAfterProperty: true
|
||||||
ObjCSpaceBeforeProtocolList: true
|
ObjCSpaceBeforeProtocolList: true
|
||||||
|
|
||||||
# Taken from git's rules
|
# Taken from git's rules
|
||||||
PenaltyBreakAssignment: 10
|
PenaltyBreakAssignment: 30
|
||||||
PenaltyBreakBeforeFirstCallParameter: 30
|
PenaltyBreakBeforeFirstCallParameter: 30
|
||||||
PenaltyBreakComment: 10
|
PenaltyBreakComment: 10
|
||||||
PenaltyBreakFirstLessLess: 0
|
PenaltyBreakFirstLessLess: 0
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,7 @@
|
||||||
namespace M17
|
namespace M17
|
||||||
{
|
{
|
||||||
|
|
||||||
enum class M17FrameType : uint8_t
|
enum class M17FrameType : uint8_t {
|
||||||
{
|
|
||||||
PREAMBLE = 0, ///< Frame contains a preamble.
|
PREAMBLE = 0, ///< Frame contains a preamble.
|
||||||
LINK_SETUP = 1, ///< Frame is a Link Setup Frame.
|
LINK_SETUP = 1, ///< Frame is a Link Setup Frame.
|
||||||
STREAM = 2, ///< Frame is a stream data frame.
|
STREAM = 2, ///< Frame is a stream data frame.
|
||||||
|
|
@ -50,7 +49,6 @@ enum class M17FrameType : uint8_t
|
||||||
class M17FrameDecoder
|
class M17FrameDecoder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*/
|
*/
|
||||||
|
|
@ -97,7 +95,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine frame type by searching which syncword among the standard M17
|
* Determine frame type by searching which syncword among the standard M17
|
||||||
* ones has the minumum hamming distance from the given one. If the hamming
|
* ones has the minumum hamming distance from the given one. If the hamming
|
||||||
|
|
@ -135,7 +132,6 @@ private:
|
||||||
*/
|
*/
|
||||||
bool decodeLich(std::array<uint8_t, 6> &segment, const lich_t &lich);
|
bool decodeLich(std::array<uint8_t, 6> &segment, const lich_t &lich);
|
||||||
|
|
||||||
|
|
||||||
uint8_t lsfSegmentMap; ///< Bitmap for LSF reassembly from LICH
|
uint8_t lsfSegmentMap; ///< Bitmap for LSF reassembly from LICH
|
||||||
M17LinkSetupFrame lsf; ///< Latest LSF received.
|
M17LinkSetupFrame lsf; ///< Latest LSF received.
|
||||||
M17LinkSetupFrame lsfFromLich; ///< LSF assembled from LICH segments.
|
M17LinkSetupFrame lsfFromLich; ///< LSF assembled from LICH segments.
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,13 @@
|
||||||
|
|
||||||
using namespace M17;
|
using namespace M17;
|
||||||
|
|
||||||
M17FrameDecoder::M17FrameDecoder() { }
|
M17FrameDecoder::M17FrameDecoder()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
M17FrameDecoder::~M17FrameDecoder() { }
|
M17FrameDecoder::~M17FrameDecoder()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void M17FrameDecoder::reset()
|
void M17FrameDecoder::reset()
|
||||||
{
|
{
|
||||||
|
|
@ -55,8 +59,7 @@ M17FrameType M17FrameDecoder::decodeFrame(const frame_t& frame)
|
||||||
|
|
||||||
auto type = getFrameType(syncWord);
|
auto type = getFrameType(syncWord);
|
||||||
|
|
||||||
switch(type)
|
switch (type) {
|
||||||
{
|
|
||||||
case M17FrameType::LINK_SETUP:
|
case M17FrameType::LINK_SETUP:
|
||||||
decodeLSF(data);
|
decodeLSF(data);
|
||||||
break;
|
break;
|
||||||
|
|
@ -72,7 +75,8 @@ M17FrameType M17FrameDecoder::decodeFrame(const frame_t& frame)
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
M17FrameType M17FrameDecoder::getFrameType(const std::array< uint8_t, 2 >& syncWord)
|
M17FrameType
|
||||||
|
M17FrameDecoder::getFrameType(const std::array<uint8_t, 2> &syncWord)
|
||||||
{
|
{
|
||||||
// Preamble
|
// Preamble
|
||||||
M17FrameType type = M17FrameType::PREAMBLE;
|
M17FrameType type = M17FrameType::PREAMBLE;
|
||||||
|
|
@ -82,8 +86,8 @@ M17FrameType M17FrameDecoder::getFrameType(const std::array< uint8_t, 2 >& syncW
|
||||||
// Link setup frame
|
// Link setup frame
|
||||||
uint8_t hammDistance = hammingDistance(syncWord[0], LSF_SYNC_WORD[0])
|
uint8_t hammDistance = hammingDistance(syncWord[0], LSF_SYNC_WORD[0])
|
||||||
+ hammingDistance(syncWord[1], LSF_SYNC_WORD[1]);
|
+ hammingDistance(syncWord[1], LSF_SYNC_WORD[1]);
|
||||||
if(hammDistance < minDistance)
|
|
||||||
{
|
if (hammDistance < minDistance) {
|
||||||
type = M17FrameType::LINK_SETUP;
|
type = M17FrameType::LINK_SETUP;
|
||||||
minDistance = hammDistance;
|
minDistance = hammDistance;
|
||||||
}
|
}
|
||||||
|
|
@ -91,16 +95,15 @@ M17FrameType M17FrameDecoder::getFrameType(const std::array< uint8_t, 2 >& syncW
|
||||||
// Stream frame
|
// Stream frame
|
||||||
hammDistance = hammingDistance(syncWord[0], STREAM_SYNC_WORD[0])
|
hammDistance = hammingDistance(syncWord[0], STREAM_SYNC_WORD[0])
|
||||||
+ hammingDistance(syncWord[1], STREAM_SYNC_WORD[1]);
|
+ hammingDistance(syncWord[1], STREAM_SYNC_WORD[1]);
|
||||||
if(hammDistance < minDistance)
|
|
||||||
{
|
if (hammDistance < minDistance) {
|
||||||
type = M17FrameType::STREAM;
|
type = M17FrameType::STREAM;
|
||||||
minDistance = hammDistance;
|
minDistance = hammDistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check value of minimum hamming distance found, if exceeds the allowed
|
// Check value of minimum hamming distance found, if exceeds the allowed
|
||||||
// limit consider the frame as of unknown type.
|
// limit consider the frame as of unknown type.
|
||||||
if(minDistance > MAX_SYNC_HAMM_DISTANCE)
|
if (minDistance > MAX_SYNC_HAMM_DISTANCE) {
|
||||||
{
|
|
||||||
type = M17FrameType::UNKNOWN;
|
type = M17FrameType::UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -124,8 +127,7 @@ void M17FrameDecoder::decodeStream(const std::array< uint8_t, 46 >& data)
|
||||||
std::copy_n(data.begin(), lich.size(), lich.begin());
|
std::copy_n(data.begin(), lich.size(), lich.begin());
|
||||||
bool decodeOk = decodeLich(lsfSegment, lich);
|
bool decodeOk = decodeLich(lsfSegment, lich);
|
||||||
|
|
||||||
if(decodeOk)
|
if (decodeOk) {
|
||||||
{
|
|
||||||
// Append LICH segment
|
// Append LICH segment
|
||||||
uint8_t segmentNum = lsfSegment[5];
|
uint8_t segmentNum = lsfSegment[5];
|
||||||
uint8_t segmentSize = lsfSegment.size() - 1;
|
uint8_t segmentSize = lsfSegment.size() - 1;
|
||||||
|
|
@ -137,9 +139,9 @@ void M17FrameDecoder::decodeStream(const std::array< uint8_t, 46 >& data)
|
||||||
lsfSegmentMap |= 1 << segmentNum;
|
lsfSegmentMap |= 1 << segmentNum;
|
||||||
|
|
||||||
// Check if we have received all the six LICH segments
|
// Check if we have received all the six LICH segments
|
||||||
if(lsfSegmentMap == 0x3F)
|
if (lsfSegmentMap == 0x3F) {
|
||||||
{
|
if (lsfFromLich.valid())
|
||||||
if(lsfFromLich.valid()) lsf = lsfFromLich;
|
lsf = lsfFromLich;
|
||||||
lsfSegmentMap = 0;
|
lsfSegmentMap = 0;
|
||||||
lsfFromLich.clear();
|
lsfFromLich.clear();
|
||||||
}
|
}
|
||||||
|
|
@ -176,26 +178,21 @@ bool M17FrameDecoder::decodeLich(std::array < uint8_t, 6 >& segment,
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
uint32_t block = 0;
|
uint32_t block = 0;
|
||||||
|
|
||||||
for(size_t i = 0; i < 4; i++)
|
for (size_t i = 0; i < 4; i++) {
|
||||||
{
|
|
||||||
memcpy(&block, lich.data() + 3 * i, 3);
|
memcpy(&block, lich.data() + 3 * i, 3);
|
||||||
block = __builtin_bswap32(block) >> 8;
|
block = __builtin_bswap32(block) >> 8;
|
||||||
uint16_t decoded = golay24_decode(block);
|
uint16_t decoded = golay24_decode(block);
|
||||||
|
|
||||||
// Unrecoverable error, abort decoding
|
// Unrecoverable error, abort decoding
|
||||||
if(decoded == 0xFFFF)
|
if (decoded == 0xFFFF) {
|
||||||
{
|
|
||||||
segment.fill(0x00);
|
segment.fill(0x00);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(i & 1)
|
if (i & 1) {
|
||||||
{
|
|
||||||
segment[index++] |= (decoded >> 8); // upper 4 bits
|
segment[index++] |= (decoded >> 8); // upper 4 bits
|
||||||
segment[index++] = (decoded & 0xFF); // lower 8 bits
|
segment[index++] = (decoded & 0xFF); // lower 8 bits
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
segment[index++] |= (decoded >> 4); // upper 8 bits
|
segment[index++] |= (decoded >> 4); // upper 8 bits
|
||||||
segment[index] = (decoded & 0x0F) << 4; // lower 4 bits
|
segment[index] = (decoded & 0x0F) << 4; // lower 4 bits
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,8 +69,10 @@ openrtx/include/interfaces/radio.h
|
||||||
openrtx/include/peripherals/gps.h
|
openrtx/include/peripherals/gps.h
|
||||||
openrtx/include/peripherals/rng.h
|
openrtx/include/peripherals/rng.h
|
||||||
openrtx/include/peripherals/rtc.h
|
openrtx/include/peripherals/rtc.h
|
||||||
|
openrtx/include/protocols/M17/M17FrameDecoder.hpp
|
||||||
openrtx/src/core/dsp.cpp
|
openrtx/src/core/dsp.cpp
|
||||||
openrtx/src/core/memory_profiling.cpp
|
openrtx/src/core/memory_profiling.cpp
|
||||||
|
openrtx/src/protocols/M17/M17FrameDecoder.cpp
|
||||||
platform/drivers/ADC/ADC0_GDx.h
|
platform/drivers/ADC/ADC0_GDx.h
|
||||||
platform/drivers/audio/MAX9814.h
|
platform/drivers/audio/MAX9814.h
|
||||||
platform/drivers/baseband/MCP4551.h
|
platform/drivers/baseband/MCP4551.h
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue