Skip to content

Commit 70e9a29

Browse files
authored
Merge pull request #89 from Digitelektro/feature/the_big_refactor
Feature/the big refactor
2 parents 4b21faf + dfa1a58 commit 70e9a29

24 files changed

Lines changed: 744 additions & 407 deletions

CMakeLists.txt

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@ cmake_minimum_required(VERSION 3.5)
22

33
include(ExternalProject)
44

5-
project(Meteordemod LANGUAGES CXX)
5+
project(meteordemod
6+
VERSION 2.6.0
7+
LANGUAGES CXX
8+
)
9+
10+
configure_file(cmake/version.h.in version.h)
11+
12+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DVERSION_BUILD=${VERSION_BUILD_NUMBER}")
13+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVERSION_BUILD=${VERSION_BUILD_NUMBER}")
614

715
set(CMAKE_CXX_STANDARD 17)
816
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -13,6 +21,10 @@ if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
1321
endif()
1422
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
1523

24+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
25+
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
26+
endif()
27+
1628

1729
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
1830
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9.2")
@@ -51,47 +63,29 @@ add_definitions(-D_USE_MATH_DEFINES -D_SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATI
5163
add_executable(meteordemod
5264
main.cpp
5365
imageproc/spreadimage.cpp
54-
imageproc/spreadimage.h
5566
imageproc/threatimage.cpp
56-
imageproc/threatimage.h
57-
decoder/bitio.cpp
58-
decoder/bitio.h
5967
decoder/correlation.cpp
60-
decoder/correlation.h
61-
decoder/meteorimage.cpp
62-
decoder/meteorimage.h
63-
decoder/packetparser.cpp
64-
decoder/packetparser.h
6568
decoder/reedsolomon.cpp
66-
decoder/reedsolomon.h
6769
decoder/viterbi.cpp
68-
decoder/viterbi.h
6970
decoder/deinterleaver.cpp
7071
decoder/meteordecoder.cpp
71-
decoder/meteordecoder.h
72+
decoder/protocol/ccsds.cpp
73+
decoder/protocol/vcdu.cpp
74+
decoder/protocol/lrpt/decoder.cpp
75+
decoder/protocol/lrpt/msumr/segment.cpp
76+
decoder/protocol/lrpt/msumr/bitio.cpp
77+
decoder/protocol/lrpt/msumr/image.cpp
7278
common/settings.cpp
73-
common/settings.h
74-
common/version.h
7579
tools/matrix.cpp
76-
tools/matrix.h
7780
tools/tlereader.cpp
78-
tools/tlereader.h
7981
tools/vector.cpp
80-
tools/vector.h
8182
tools/pixelgeolocationcalculator.cpp
82-
tools/pixelgeolocationcalculator.h
8383
tools/databuffer.cpp
84-
tools/databuffer.h
8584
tools/iniparser.cpp
86-
tools/iniparser.h
8785
tools/threadpool.cpp
88-
tools/threadpool.h
8986
GIS/shapereader.cpp
90-
GIS/shapereader.h
9187
GIS/shaperenderer.cpp
92-
GIS/shaperenderer.h
9388
GIS/dbfilereader.cpp
94-
GIS/dbfilereader.h
9589
DSP/meteordemodulator.cpp
9690
DSP/agc.cpp
9791
DSP/pll.cpp
@@ -118,6 +112,10 @@ include_directories(
118112
${CMAKE_SOURCE_DIR}/external/libcorrect/include
119113
)
120114

115+
target_include_directories(meteordemod PUBLIC
116+
"${PROJECT_BINARY_DIR}"
117+
)
118+
121119
add_dependencies(meteordemod sgp4)
122120
add_dependencies(meteordemod libcorrect)
123121

@@ -150,9 +148,6 @@ if(UNIX AND NOT APPLE)
150148
find_file (DEBIAN_FOUND debian_version debconf.conf PATHS /etc)
151149
if (DEBIAN_FOUND)
152150
SET(CPACK_GENERATOR "DEB")
153-
SET(CPACK_PACKAGE_VERSION_MAJOR "2")
154-
SET(CPACK_PACKAGE_VERSION_MINOR "5")
155-
SET(CPACK_PACKAGE_VERSION_PATCH "7")
156151
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Digitelektro")
157152
SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/Digitelektro/MeteorDemod")
158153
SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION "Russian Meteor M2 weather satellite data decoder")

cmake/version.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#define VERSION_MAJOR @meteordemod_VERSION_MAJOR@
2+
#define VERSION_MINOR @meteordemod_VERSION_MINOR@
3+
#define VERSION_FIX @meteordemod_VERSION_PATCH@

common/version.h

Lines changed: 0 additions & 8 deletions
This file was deleted.

decoder/bitio.h

Lines changed: 0 additions & 22 deletions
This file was deleted.

decoder/meteordecoder.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#include "meteordecoder.h"
22

3+
#include <iostream>
34

45
MeteorDecoder::MeteorDecoder(bool deInterleave, bool oqpsk, bool differentialDecode)
56
: mDeInterleave(deInterleave)
67
, mDifferentialDecode(differentialDecode)
78
, mCorrelation(differentialDecode ? sSynchWordOQPSK : sSynchWordQPSK, oqpsk) {}
89

9-
size_t MeteorDecoder::decode(uint8_t* softBits, size_t length) {
10+
size_t MeteorDecoder::decode(uint8_t* softBits, size_t length, std::function<void(const uint8_t* cadu, std::size_t size)> callback) {
1011
size_t decodedPacketCounter = 0;
1112
size_t syncWordFound = 0;
1213

@@ -17,7 +18,7 @@ size_t MeteorDecoder::decode(uint8_t* softBits, size_t length) {
1718
length = outLen;
1819
}
1920

20-
mCorrelation.correlate(softBits, length, [&softBits, length, &decodedPacketCounter, &syncWordFound, this](Correlation::CorellationResult correlationResult, Correlation::PhaseShift phaseShift) {
21+
mCorrelation.correlate(softBits, length, [&softBits, length, &decodedPacketCounter, &syncWordFound, &callback, this](Correlation::CorellationResult correlationResult, Correlation::PhaseShift phaseShift) {
2122
bool packetOk;
2223
uint32_t processedBits = 0;
2324

@@ -28,7 +29,7 @@ size_t MeteorDecoder::decode(uint8_t* softBits, size_t length) {
2829
return processedBits;
2930
}
3031

31-
memcpy(mDataTodecode, &softBits[correlationResult.pos + processedBits], 16384);
32+
std::copy(&softBits[correlationResult.pos + processedBits], &softBits[correlationResult.pos + processedBits] + 16384, mDataTodecode);
3233

3334
mCorrelation.rotateSoftIqInPlace(mDataTodecode, 16384, phaseShift);
3435

@@ -53,17 +54,18 @@ size_t MeteorDecoder::decode(uint8_t* softBits, size_t length) {
5354
for(int i = 0; i < 4; i++) {
5455
mReedSolomon.deinterleave(mViterbiResult + 4, i, 4);
5556
rsResult[i] = mReedSolomon.decode();
56-
mReedSolomon.interleave(mDecodedPacket, i, 4);
57+
mReedSolomon.interleave(mDecodedPacket + 4, i, 4);
5758
}
5859

5960
std::cout << "SyncWordFound:" << syncWordFound << " | Decoded Packets:" << decodedPacketCounter << " | Current Pos:" << (correlationResult.pos + processedBits) << " | Phase:" << phaseShift << " | synch:" << std::hex
60-
<< last_sync_ << " | RS: (" << std::dec << rsResult[0] << ", " << rsResult[1] << ", " << rsResult[2] << ", " << rsResult[3] << ")"
61+
<< last_sync_ << " | BER: " << mViterbi.getLastBER() << " | RS: (" << std::dec << rsResult[0] << ", " << rsResult[1] << ", " << rsResult[2] << ", " << rsResult[3] << ")"
6162
<< "\t\t\r";
6263

6364
packetOk = (rsResult[0] != -1) && (rsResult[1] != -1) && (rsResult[2] != -1) && (rsResult[3] != -1);
6465

6566
if(packetOk) {
66-
parseFrame(mDecodedPacket, 892);
67+
std::copy(mViterbiResult, mViterbiResult + 4, mDecodedPacket);
68+
callback(mDecodedPacket, sizeof(mDecodedPacket));
6769
decodedPacketCounter++;
6870
processedBits += 16384;
6971
}

decoder/meteordecoder.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
#include <stdint.h>
55

66
#include <cmath>
7+
#include <functional>
78

89
#include "correlation.h"
910
#include "deinterleaver.h"
10-
#include "packetparser.h"
1111
#include "reedsolomon.h"
1212
#include "viterbi.h"
1313

14-
class MeteorDecoder : public PacketParser {
14+
class MeteorDecoder {
1515
private:
1616
static constexpr uint8_t PRAND[]
1717
= {0xff, 0x48, 0x0e, 0xc0, 0x9a, 0x0d, 0x70, 0xbc, 0x8e, 0x2c, 0x93, 0xad, 0xa7, 0xb7, 0x46, 0xce, 0x5a, 0x97, 0x7d, 0xcc, 0x32, 0xa2, 0xbf, 0x3e, 0x0a, 0x10, 0xf1, 0x88, 0x94, 0xcd, 0xea, 0xb1, 0xfe, 0x90, 0x1d, 0x81, 0x34,
@@ -27,7 +27,7 @@ class MeteorDecoder : public PacketParser {
2727
MeteorDecoder() = delete;
2828
MeteorDecoder(bool deInterleave, bool oqpsk, bool differentialDecode);
2929

30-
size_t decode(uint8_t* softBits, size_t length);
30+
size_t decode(uint8_t* softBits, size_t length, std::function<void(const uint8_t* cadu, std::size_t size)> callback);
3131

3232
private:
3333
bool mDeInterleave;

decoder/packetparser.cpp

Lines changed: 0 additions & 142 deletions
This file was deleted.

0 commit comments

Comments
 (0)