From 5e01df112aa607adeea6b5b66e83cdee287ed3ae Mon Sep 17 00:00:00 2001 From: Jamie Vital Date: Sat, 11 Jan 2025 09:26:57 -0500 Subject: [PATCH] Cleanup and fix LRPT sat detection in edge case --- .../meteor/instruments/msumr/lrpt/idct.cpp | 2 - .../meteor/instruments/msumr/lrpt/segment.cpp | 8 ++- .../meteor/instruments/msumr/lrpt/segment.h | 3 -- .../msumr/module_meteor_msumr_lrpt.cpp | 53 +++++++++++-------- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/plugins/meteor_support/meteor/instruments/msumr/lrpt/idct.cpp b/plugins/meteor_support/meteor/instruments/msumr/lrpt/idct.cpp index 68145a797..b4d93dbf9 100644 --- a/plugins/meteor_support/meteor/instruments/msumr/lrpt/idct.cpp +++ b/plugins/meteor_support/meteor/instruments/msumr/lrpt/idct.cpp @@ -6,8 +6,6 @@ namespace meteor { namespace lrpt { - const int blockSize = 64; // A DCT block is 8x8. - const int w1 = 2841; // 2048*sqrt(2)*cos(1*pi/16) const int w2 = 2676; // 2048*sqrt(2)*cos(2*pi/16) const int w3 = 2408; // 2048*sqrt(2)*cos(3*pi/16) diff --git a/plugins/meteor_support/meteor/instruments/msumr/lrpt/segment.cpp b/plugins/meteor_support/meteor/instruments/msumr/lrpt/segment.cpp index 33a63cdea..684a17293 100644 --- a/plugins/meteor_support/meteor/instruments/msumr/lrpt/segment.cpp +++ b/plugins/meteor_support/meteor/instruments/msumr/lrpt/segment.cpp @@ -19,8 +19,7 @@ namespace meteor // day_time == 0 && us_time == 0; } - Segment::Segment(uint8_t* data, int length, bool partial, bool meteorm2x_mode) : meteorm2x_mode(meteorm2x_mode), - partial(partial) + Segment::Segment(uint8_t* data, int length, bool partial, bool meteorm2x_mode) : partial(partial) { if (length - 14 <= 0) { @@ -51,10 +50,9 @@ namespace meteor } } - Segment::Segment() : meteorm2x_mode(false), // We don't care if invalid - partial(true) + Segment::Segment() : partial(true), + valid(false) { - valid = false; } Segment::~Segment() diff --git a/plugins/meteor_support/meteor/instruments/msumr/lrpt/segment.h b/plugins/meteor_support/meteor/instruments/msumr/lrpt/segment.h index 49486f4f3..b669a4527 100644 --- a/plugins/meteor_support/meteor/instruments/msumr/lrpt/segment.h +++ b/plugins/meteor_support/meteor/instruments/msumr/lrpt/segment.h @@ -12,9 +12,6 @@ namespace meteor { class Segment { - private: - bool meteorm2x_mode; - public: uint16_t day_time; uint32_t ms_time; diff --git a/plugins/meteor_support/meteor/instruments/msumr/module_meteor_msumr_lrpt.cpp b/plugins/meteor_support/meteor/instruments/msumr/module_meteor_msumr_lrpt.cpp index fce4cbd59..0ad689f2c 100644 --- a/plugins/meteor_support/meteor/instruments/msumr/module_meteor_msumr_lrpt.cpp +++ b/plugins/meteor_support/meteor/instruments/msumr/module_meteor_msumr_lrpt.cpp @@ -146,33 +146,40 @@ namespace meteor { msureader.work(pkt); - if (pkt.header.apid == 70 && pkt.payload.size() >= 62) + if (pkt.header.apid == 70) { - // Telemetry Timestamp - if (meteorm2x_mode) - telemetry_timestamps[ccsds::parseCCSDSTimeFullRaw(&pkt.payload.data()[0], 11322)] = msumr_ids.size(); - else - telemetry_timestamps[ccsds::parseCCSDSTimeFullRaw(&pkt.payload.data()[0], 0)] = msumr_ids.size(); - - // ID parsing - uint8_t msumr_id = pkt.payload[8 + 12] >> 4; - msumr_ids.push_back(msumr_id); - parseMSUMRTelemetry(msu_mr_telemetry, msu_mr_telemetry_calib, msumr_ids.size() - 1, &pkt.payload[8]); - - // Convert calibration data - uint16_t words10_bits[12]; - for (int n = 0; n < 3; n++) + if (pkt.payload.size() >= 16) { - int bitpos = 43 + n * 5; - // Convert 5 bytes to 4 10-bits values - words10_bits[n * 4 + 0] = ((pkt.payload[bitpos] << 2) | (pkt.payload[bitpos + 1] >> 6)); - words10_bits[n * 4 + 1] = (((pkt.payload[bitpos + 1] % 64) << 4) | (pkt.payload[bitpos + 2] >> 4)); - words10_bits[n * 4 + 2] = (((pkt.payload[bitpos + 2] % 16) << 6) | (pkt.payload[bitpos + 3] >> 2)); - words10_bits[n * 4 + 3] = (((pkt.payload[bitpos + 3] % 4) << 8) | pkt.payload[bitpos + 4]); + // Telemetry Timestamp + if (meteorm2x_mode) + telemetry_timestamps[ccsds::parseCCSDSTimeFullRaw(&pkt.payload.data()[0], 11322)] = msumr_ids.size(); + else + telemetry_timestamps[ccsds::parseCCSDSTimeFullRaw(&pkt.payload.data()[0], 0)] = msumr_ids.size(); + + // ID parsing + uint8_t msumr_id = pkt.payload[8 + 12] >> 4; + msumr_ids.push_back(msumr_id); } - for (int channel = 0; channel < 6; channel++) - calibration_info[channel].push_back({words10_bits[channel * 2], words10_bits[channel * 2 + 1]}); + if (pkt.payload.size() >= 62) + { + parseMSUMRTelemetry(msu_mr_telemetry, msu_mr_telemetry_calib, msumr_ids.size() - 1, &pkt.payload[8]); + + // Convert calibration data + uint16_t words10_bits[12]; + for (int n = 0; n < 3; n++) + { + int bitpos = 43 + n * 5; + // Convert 5 bytes to 4 10-bits values + words10_bits[n * 4 + 0] = ((pkt.payload[bitpos] << 2) | (pkt.payload[bitpos + 1] >> 6)); + words10_bits[n * 4 + 1] = (((pkt.payload[bitpos + 1] % 64) << 4) | (pkt.payload[bitpos + 2] >> 4)); + words10_bits[n * 4 + 2] = (((pkt.payload[bitpos + 2] % 16) << 6) | (pkt.payload[bitpos + 3] >> 2)); + words10_bits[n * 4 + 3] = (((pkt.payload[bitpos + 3] % 4) << 8) | pkt.payload[bitpos + 4]); + } + + for (int channel = 0; channel < 6; channel++) + calibration_info[channel].push_back({ words10_bits[channel * 2], words10_bits[channel * 2 + 1] }); + } } } }