mirror of
https://github.com/g4klx/MMDVMHost
synced 2025-12-21 23:45:49 +08:00
Add validation for M17 end bit.
This commit is contained in:
@@ -78,7 +78,6 @@ m_rfErrs(0U),
|
|||||||
m_rfBits(1U),
|
m_rfBits(1U),
|
||||||
m_rfLSF(),
|
m_rfLSF(),
|
||||||
m_rfLSFn(0U),
|
m_rfLSFn(0U),
|
||||||
m_rfFN(0U),
|
|
||||||
m_netLSF(),
|
m_netLSF(),
|
||||||
m_netLSFn(0U),
|
m_netLSFn(0U),
|
||||||
m_rssiMapper(rssiMapper),
|
m_rssiMapper(rssiMapper),
|
||||||
@@ -189,7 +188,6 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len)
|
|||||||
m_aveRSSI = m_rssi;
|
m_aveRSSI = m_rssi;
|
||||||
m_rssiCount = 1U;
|
m_rssiCount = 1U;
|
||||||
m_rfLSFn = 0U;
|
m_rfLSFn = 0U;
|
||||||
m_rfFN = 0U;
|
|
||||||
|
|
||||||
#if defined(DUMP_M17)
|
#if defined(DUMP_M17)
|
||||||
openFile();
|
openFile();
|
||||||
@@ -238,7 +236,6 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len)
|
|||||||
m_maxRSSI = m_rssi;
|
m_maxRSSI = m_rssi;
|
||||||
m_aveRSSI = m_rssi;
|
m_aveRSSI = m_rssi;
|
||||||
m_rssiCount = 1U;
|
m_rssiCount = 1U;
|
||||||
m_rfFN = 0U;
|
|
||||||
|
|
||||||
#if defined(DUMP_M17)
|
#if defined(DUMP_M17)
|
||||||
openFile();
|
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 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);
|
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);
|
LogDebug("M17, audio: FN: %u, errs: %u/272 (%.1f%%)", fn & 0x7FFFU, errors, float(errors) / 2.72F);
|
||||||
|
|
||||||
m_rfFN++;
|
|
||||||
|
|
||||||
m_rfBits += 272U;
|
m_rfBits += 272U;
|
||||||
m_rfErrs += errors;
|
m_rfErrs += errors;
|
||||||
@@ -324,8 +319,10 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len)
|
|||||||
if (m_rfLSFn >= 6U)
|
if (m_rfLSFn >= 6U)
|
||||||
m_rfLSFn = 0U;
|
m_rfLSFn = 0U;
|
||||||
|
|
||||||
// Only check for the EOT marker if the frame has a reasonable BER
|
bool bValid = (fn & 0x7FFFU) < (210U * 25U); // 210 seconds maximum
|
||||||
if ((m_rfFN & 0x8000U) == 0x8000U) {
|
bool bEnd = (fn & 0x8000U) == 0x8000U;
|
||||||
|
|
||||||
|
if (bValid && bEnd) {
|
||||||
std::string source = m_rfLSF.getSource();
|
std::string source = m_rfLSF.getSource();
|
||||||
std::string dest = m_rfLSF.getDest();
|
std::string dest = m_rfLSF.getDest();
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ private:
|
|||||||
unsigned int m_rfBits;
|
unsigned int m_rfBits;
|
||||||
CM17LSF m_rfLSF;
|
CM17LSF m_rfLSF;
|
||||||
unsigned int m_rfLSFn;
|
unsigned int m_rfLSFn;
|
||||||
unsigned int m_rfFN;
|
|
||||||
CM17LSF m_netLSF;
|
CM17LSF m_netLSF;
|
||||||
unsigned int m_netLSFn;
|
unsigned int m_netLSFn;
|
||||||
CRSSIInterpolator* m_rssiMapper;
|
CRSSIInterpolator* m_rssiMapper;
|
||||||
|
|||||||
@@ -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_LINK_SETUP_SYNC_BYTES[] = {0x55U, 0xF7U};
|
||||||
const unsigned char M17_STREAM_SYNC_BYTES[] = {0xFFU, 0x5DU};
|
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_BITS = 16U;
|
||||||
const unsigned int M17_SYNC_LENGTH_BYTES = M17_SYNC_LENGTH_BITS / 8U;
|
const unsigned int M17_SYNC_LENGTH_BYTES = M17_SYNC_LENGTH_BITS / 8U;
|
||||||
|
|||||||
8
Sync.cpp
8
Sync.cpp
@@ -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
|
* 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
|
* 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);
|
::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
3
Sync.h
@@ -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
|
* 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
|
* 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 addM17LinkSetupSync(unsigned char* data);
|
||||||
static void addM17StreamSync(unsigned char* data);
|
static void addM17StreamSync(unsigned char* data);
|
||||||
static void addM17PacketSync(unsigned char* data);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user