From 3a73a25c1e2848badf405f19e1c32bc50de471a1 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Sun, 11 Apr 2021 17:31:05 +0100 Subject: [PATCH] Update M17 to the latest secification, removal of the CRC from the stream data. --- M17Control.cpp | 27 +++++---------------------- M17Control.h | 1 - M17Convolution.cpp | 7 +++---- Version.h | 2 +- 4 files changed, 9 insertions(+), 28 deletions(-) diff --git a/M17Control.cpp b/M17Control.cpp index f518037..8ee67d4 100644 --- a/M17Control.cpp +++ b/M17Control.cpp @@ -75,7 +75,6 @@ m_networkWatchdog(1000U, 0U, 1500U), m_elapsed(), m_rfFrames(0U), m_netFrames(0U), -m_rfFN(0U), m_rfErrs(0U), m_rfBits(1U), m_rfLSF(), @@ -194,7 +193,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(); @@ -258,22 +256,10 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len) writeFile(data + 2U); #endif CM17Convolution conv; - unsigned char frame[M17_FN_LENGTH_BYTES + M17_PAYLOAD_LENGTH_BYTES + M17_CRC_LENGTH_BYTES]; + unsigned char frame[M17_FN_LENGTH_BYTES + M17_PAYLOAD_LENGTH_BYTES]; conv.decodeData(data + 2U + M17_SYNC_LENGTH_BYTES + M17_LICH_FRAGMENT_FEC_LENGTH_BYTES, frame); - bool valid = CM17CRC::checkCRC16(frame, M17_FN_LENGTH_BYTES + M17_PAYLOAD_LENGTH_BYTES + M17_CRC_LENGTH_BYTES); - if (valid) { - m_rfFN = (frame[0U] << 8) + (frame[1U] << 0); - } else { - m_rfFN++; - - // The new FN - frame[0U] = m_rfFN >> 8; - frame[1U] = m_rfFN >> 0; - - // Recalculate the CRC - CM17CRC::encodeCRC16(frame, M17_FN_LENGTH_BYTES + M17_PAYLOAD_LENGTH_BYTES + M17_CRC_LENGTH_BYTES); - } + unsigned int fn = ((frame[0U] << 8) + (frame[1U] << 0)) & 0x7FU; unsigned char rfData[2U + M17_FRAME_LENGTH_BYTES]; @@ -310,7 +296,7 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len) errors += CUtils::countBits(rfData[offset] ^ data[offset]); } - LogDebug("M17, FN: %u, errs: %u/144 (%.1f%%)", m_rfFN & 0x7FU, errors, float(errors) / 1.44F); + LogDebug("M17, FN: %u, errs: %u/144 (%.1f%%)", fn & 0x7FU, errors, float(errors) / 1.44F); m_rfBits += M17_FN_LENGTH_BITS + M17_PAYLOAD_LENGTH_BITS; m_rfErrs += errors; @@ -345,7 +331,7 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len) m_rfLSFn = 0U; // Only check for the EOT marker if the frame has a valid CRC - if (valid && (m_rfFN & 0x8000U) == 0x8000U) { + if ((fn & 0x8000U) == 0x8000U) { std::string source = m_rfLSF.getSource(); std::string dest = m_rfLSF.getDest(); @@ -520,12 +506,9 @@ void CM17Control::writeNetwork() CM17Utils::combineFragmentLICHFEC(lich1, lich2, lich3, lich4, data + 2U + M17_SYNC_LENGTH_BYTES); // Add the FN and the data/audio - unsigned char payload[M17_FN_LENGTH_BYTES + M17_PAYLOAD_LENGTH_BYTES + M17_CRC_LENGTH_BYTES]; + unsigned char payload[M17_FN_LENGTH_BYTES + M17_PAYLOAD_LENGTH_BYTES]; ::memcpy(payload, netData + 28U, M17_FN_LENGTH_BYTES + M17_PAYLOAD_LENGTH_BYTES); - // Add the CRC - CM17CRC::encodeCRC16(payload, M17_FN_LENGTH_BYTES + M17_PAYLOAD_LENGTH_BYTES + M17_CRC_LENGTH_BYTES); - // Add the Convolution FEC CM17Convolution conv; conv.encodeData(payload, data + 2U + M17_SYNC_LENGTH_BYTES + M17_LICH_FRAGMENT_FEC_LENGTH_BYTES); diff --git a/M17Control.h b/M17Control.h index d351099..4b8b485 100644 --- a/M17Control.h +++ b/M17Control.h @@ -65,7 +65,6 @@ private: CStopWatch m_elapsed; unsigned int m_rfFrames; unsigned int m_netFrames; - unsigned int m_rfFN; unsigned int m_rfErrs; unsigned int m_rfBits; CM17LSF m_rfLSF; diff --git a/M17Convolution.cpp b/M17Convolution.cpp index 5a83ab0..b7b17f5 100644 --- a/M17Convolution.cpp +++ b/M17Convolution.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 by Jonathan Naylor G4KLX + * Copyright (C) 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 @@ -32,9 +32,8 @@ const unsigned int PUNCTURE_LIST_LINK_SETUP[] = { 449U, 452U, 455U, 462U, 465U, 468U, 471U, 478U, 481U, 484U}; const unsigned int PUNCTURE_LIST_DATA[] = { - 5U, 11U, 17U, 20U, 23U, 29U, 35U, 46U, 52U, 58U, 61U, 64U, 70U, 76U, 87U, 93U, 99U, 102U, 105U, 111U, 117U, 128U, 134U, 140U, - 143U, 146U, 152U, 158U, 169U, 175U, 181U, 184U, 187U, 193U, 199U, 210U, 216U, 222U, 225U, 228U, 234U, 240U, 251U, 257U, 263U, - 266U, 269U, 275U, 281U, 292U, 298U, 304U, 307U, 310U, 316U, 322U}; + 11U, 23U, 35U, 47U, 59U, 71U, 83U, 95U, 107U, 119U, 131U, 143U, 155U, 167U, 179U, 191U, 203U, 215U, 227U, 239U, 251U, 263U, + 275U, 287U, 299U, 311U, 323U }; const unsigned char BIT_MASK_TABLE[] = {0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U, 0x02U, 0x01U}; diff --git a/Version.h b/Version.h index 486d545..5bef73a 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20210408"; +const char* VERSION = "20210411"; #endif