Add validation for M17 end bit.

This commit is contained in:
Jonathan Naylor 2021-08-18 19:36:00 +01:00
parent 200986b698
commit 8e34cab68b
6 changed files with 9 additions and 21 deletions

View file

@ -78,7 +78,6 @@ m_rfErrs(0U),
m_rfBits(1U),
m_rfLSF(),
m_rfLSFn(0U),
m_rfFN(0U),
m_netLSF(),
m_netLSFn(0U),
m_rssiMapper(rssiMapper),
@ -189,7 +188,6 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len)
m_aveRSSI = m_rssi;
m_rssiCount = 1U;
m_rfLSFn = 0U;
m_rfFN = 0U;
#if defined(DUMP_M17)
openFile();
@ -238,7 +236,6 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len)
m_maxRSSI = m_rssi;
m_aveRSSI = m_rssi;
m_rssiCount = 1U;
m_rfFN = 0U;
#if defined(DUMP_M17)
openFile();
@ -257,11 +254,9 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len)
unsigned char frame[M17_FN_LENGTH_BYTES + M17_PAYLOAD_LENGTH_BYTES];
unsigned int errors = conv.decodeData(data + 2U + M17_SYNC_LENGTH_BYTES + M17_LICH_FRAGMENT_FEC_LENGTH_BYTES, frame);
m_rfFN = (frame[0U] << 8) + (frame[1U] << 0);
uint16_t fn = (frame[0U] << 8) + (frame[1U] << 0);
LogDebug("M17, audio: FN: %u, errs: %u/272 (%.1f%%)", m_rfFN & 0x7FFFU, errors, float(errors) / 2.72F);
m_rfFN++;
LogDebug("M17, audio: FN: %u, errs: %u/272 (%.1f%%)", fn & 0x7FFFU, errors, float(errors) / 2.72F);
m_rfBits += 272U;
m_rfErrs += errors;
@ -324,8 +319,10 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len)
if (m_rfLSFn >= 6U)
m_rfLSFn = 0U;
// Only check for the EOT marker if the frame has a reasonable BER
if ((m_rfFN & 0x8000U) == 0x8000U) {
bool bValid = (fn & 0x7FFFU) < (210U * 25U); // 210 seconds maximum
bool bEnd = (fn & 0x8000U) == 0x8000U;
if (bValid && bEnd) {
std::string source = m_rfLSF.getSource();
std::string dest = m_rfLSF.getDest();

View file

@ -68,7 +68,6 @@ private:
unsigned int m_rfBits;
CM17LSF m_rfLSF;
unsigned int m_rfLSFn;
unsigned int m_rfFN;
CM17LSF m_netLSF;
unsigned int m_netLSFn;
CRSSIInterpolator* m_rssiMapper;

View file

@ -26,7 +26,6 @@ const unsigned int M17_FRAME_LENGTH_BYTES = M17_FRAME_LENGTH_BITS / 8U;
const unsigned char M17_LINK_SETUP_SYNC_BYTES[] = {0x55U, 0xF7U};
const unsigned char M17_STREAM_SYNC_BYTES[] = {0xFFU, 0x5DU};
const unsigned char M17_PACKET_SYNC_BYTES[] = {0x75U, 0xFFU};
const unsigned int M17_SYNC_LENGTH_BITS = 16U;
const unsigned int M17_SYNC_LENGTH_BYTES = M17_SYNC_LENGTH_BITS / 8U;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016,2018,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2018,2020,2021 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -99,9 +99,3 @@ void CSync::addM17StreamSync(unsigned char* data)
::memcpy(data, M17_STREAM_SYNC_BYTES, M17_SYNC_LENGTH_BYTES);
}
void CSync::addM17PacketSync(unsigned char* data)
{
assert(data != NULL);
::memcpy(data, M17_PACKET_SYNC_BYTES, M17_SYNC_LENGTH_BYTES);
}

3
Sync.h
View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016,2018,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2018,2020,2021 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -35,7 +35,6 @@ public:
static void addM17LinkSetupSync(unsigned char* data);
static void addM17StreamSync(unsigned char* data);
static void addM17PacketSync(unsigned char* data);
private:
};

View file

@ -19,6 +19,6 @@
#if !defined(VERSION_H)
#define VERSION_H
const char* VERSION = "20210817";
const char* VERSION = "20210818";
#endif