diff --git a/CMakeLists.txt b/CMakeLists.txt index 07dc0c79..cd78100e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,6 +77,8 @@ file(GLOB dvmhost_SRC "nxdn/acl/*.cpp" "nxdn/channel/*.h" "nxdn/channel/*.cpp" + "nxdn/edac/*.h" + "nxdn/edac/*.cpp" "nxdn/lc/*.h" "nxdn/lc/*.cpp" "nxdn/lc/rcch/*.h" @@ -85,8 +87,9 @@ file(GLOB dvmhost_SRC "nxdn/packet/*.cpp" # Core - "edac/*.h" + "edac/*.h" "edac/*.cpp" + "edac/rs/*.h" "host/*.h" "host/*.cpp" "host/calibrate/*.h" @@ -149,7 +152,7 @@ file(GLOB dvmtests_SRC # digital mode options option(ENABLE_DMR "Enable DMR Digtial Mode" on) option(ENABLE_P25 "Enable P25 Digital Mode" on) -option(ENABLE_NXDN "Enable NXDN Digital Mode" off) +option(ENABLE_NXDN "Enable NXDN Digital Mode" on) option(ENABLE_DFSI_SUPPORT "Enable P25 DFSI Transport Support" off) option(ENABLE_TESTS "Enable compilation of test suite" off) diff --git a/nxdn/Convolution.h b/nxdn/Convolution.h deleted file mode 100644 index b85243a7..00000000 --- a/nxdn/Convolution.h +++ /dev/null @@ -1,75 +0,0 @@ -/** -* Digital Voice Modem - Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Host Software -* -*/ -// -// Based on code from the MMDVMHost project. (https://github.com/g4klx/MMDVMHost) -// Licensed under the GPLv2 License (https://opensource.org/licenses/GPL-2.0) -// -/* -* Copyright (C) 2015,2016,2018,2021 by Jonathan Naylor G4KLX -* Copyright (C) 2022 by Bryan Biedenkapp N2PLL -* -* 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 -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -#if !defined(__NXDN_CONVOLUTION_H__) -#define __NXDN_CONVOLUTION_H__ - -#include "Defines.h" - -#include - -namespace nxdn -{ - // --------------------------------------------------------------------------- - // Class Declaration - // Implements NXDN frame convolution processing. - // --------------------------------------------------------------------------- - - class HOST_SW_API Convolution { - public: - /// Initializes a new instance of the Convolution class. - Convolution(); - /// Finalizes a instance of the Convolution class. - ~Convolution(); - - /// - void start(); - /// - uint32_t chainback(uint8_t* out, uint32_t nBits); - - /// - bool decode(uint8_t s0, uint8_t s1); - /// - void encode(const uint8_t* in, uint8_t* out, uint32_t nBits) const; - - private: - uint16_t* m_metrics1; - uint16_t* m_metrics2; - - uint16_t* m_oldMetrics; - uint16_t* m_newMetrics; - - uint64_t* m_decisions; - - uint64_t* m_dp; - }; -} // namespace nxdn - -#endif // __NXDN_CONVOLUTION_H__ diff --git a/nxdn/channel/CAC.cpp b/nxdn/channel/CAC.cpp index e611dce1..bcc7c774 100644 --- a/nxdn/channel/CAC.cpp +++ b/nxdn/channel/CAC.cpp @@ -28,13 +28,12 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "nxdn/channel/CAC.h" -#include "nxdn/Convolution.h" +#include "nxdn/edac/Convolution.h" #include "nxdn/NXDNDefines.h" #include "edac/CRC.h" #include "Log.h" #include "Utils.h" -using namespace edac; using namespace nxdn; using namespace nxdn::channel; @@ -204,7 +203,7 @@ bool CAC::decode(const uint8_t* data) // TODO TODO -- Long CAC Puncturing // decode convolution - Convolution conv; + edac::Convolution conv; conv.start(); uint32_t n = 0U; @@ -225,7 +224,7 @@ bool CAC::decode(const uint8_t* data) #endif // check CRC-16 - bool ret = CRC::checkCRC16(m_data, NXDN_CAC_SHORT_LENGTH_BITS); + bool ret = ::edac::CRC::checkCRC16(m_data, NXDN_CAC_SHORT_LENGTH_BITS); if (!ret) { LogError(LOG_NXDN, "CAC::decode(), failed CRC-6 check"); return false; @@ -272,7 +271,7 @@ void CAC::encode(uint8_t* data) const WRITE_BIT(buffer, i, b); } - uint16_t crc = CRC::addCRC16(buffer, NXDN_CAC_LENGTH_BITS); + uint16_t crc = ::edac::CRC::addCRC16(buffer, NXDN_CAC_LENGTH_BITS); #if DEBUG_NXDN_CAC Utils::dump(2U, "Encoded CAC", buffer, NXDN_CAC_FEC_LENGTH_BYTES); @@ -282,7 +281,7 @@ void CAC::encode(uint8_t* data) const uint8_t convolution[NXDN_CAC_FEC_CONV_LENGTH_BYTES]; ::memset(convolution, 0x00U, NXDN_CAC_FEC_CONV_LENGTH_BYTES); - Convolution conv; + edac::Convolution conv; conv.encode(buffer, convolution, NXDN_CAC_CRC_LENGTH_BITS); // puncture diff --git a/nxdn/channel/FACCH1.cpp b/nxdn/channel/FACCH1.cpp index 91300832..000904c5 100644 --- a/nxdn/channel/FACCH1.cpp +++ b/nxdn/channel/FACCH1.cpp @@ -28,13 +28,12 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "nxdn/channel/FACCH1.h" -#include "nxdn/Convolution.h" +#include "nxdn/edac/Convolution.h" #include "nxdn/NXDNDefines.h" #include "edac/CRC.h" #include "Log.h" #include "Utils.h" -using namespace edac; using namespace nxdn; using namespace nxdn::channel; @@ -151,7 +150,7 @@ bool FACCH1::decode(const uint8_t* data, uint32_t offset) } // decode convolution - Convolution conv; + edac::Convolution conv; conv.start(); n = 0U; @@ -172,7 +171,7 @@ bool FACCH1::decode(const uint8_t* data, uint32_t offset) #endif // check CRC-12 - bool ret = CRC::checkCRC12(m_data, NXDN_FACCH1_LENGTH_BITS); + bool ret = ::edac::CRC::checkCRC12(m_data, NXDN_FACCH1_LENGTH_BITS); if (!ret) { LogError(LOG_NXDN, "FACCH1::decode(), failed CRC-12 check"); return false; @@ -194,7 +193,7 @@ void FACCH1::encode(uint8_t* data, uint32_t offset) const ::memset(buffer, 0x00U, NXDN_FACCH1_CRC_LENGTH_BYTES); ::memcpy(buffer, m_data, NXDN_FACCH1_CRC_LENGTH_BYTES - 2U); - CRC::addCRC12(buffer, NXDN_FACCH1_LENGTH_BITS); + ::edac::CRC::addCRC12(buffer, NXDN_FACCH1_LENGTH_BITS); #if DEBUG_NXDN_FACCH1 Utils::dump(2U, "Encoded FACCH1", buffer, NXDN_FACCH1_CRC_LENGTH_BYTES); @@ -204,7 +203,7 @@ void FACCH1::encode(uint8_t* data, uint32_t offset) const uint8_t convolution[NXDN_FACCH1_FEC_CONV_LENGTH_BYTES]; ::memset(convolution, 0x00U, NXDN_FACCH1_FEC_CONV_LENGTH_BYTES); - Convolution conv; + edac::Convolution conv; conv.encode(buffer, convolution, NXDN_FACCH1_CRC_LENGTH_BITS); // puncture diff --git a/nxdn/channel/SACCH.cpp b/nxdn/channel/SACCH.cpp index 1b3f4867..635a5298 100644 --- a/nxdn/channel/SACCH.cpp +++ b/nxdn/channel/SACCH.cpp @@ -29,13 +29,12 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "nxdn/channel/SACCH.h" -#include "nxdn/Convolution.h" +#include "nxdn/edac/Convolution.h" #include "nxdn/NXDNDefines.h" #include "edac/CRC.h" #include "Log.h" #include "Utils.h" -using namespace edac; using namespace nxdn; using namespace nxdn::channel; @@ -153,7 +152,7 @@ bool SACCH::decode(const uint8_t* data) } // decode convolution - Convolution conv; + edac::Convolution conv; conv.start(); n = 0U; @@ -174,7 +173,7 @@ bool SACCH::decode(const uint8_t* data) #endif // check CRC-6 - bool ret = CRC::checkCRC6(m_data, NXDN_SACCH_LENGTH_BITS); + bool ret = ::edac::CRC::checkCRC6(m_data, NXDN_SACCH_LENGTH_BITS); if (!ret) { LogError(LOG_NXDN, "SACCH::decode(), failed CRC-6 check"); return false; @@ -208,7 +207,7 @@ void SACCH::encode(uint8_t* data) const WRITE_BIT(buffer, i, b); } - CRC::addCRC6(buffer, NXDN_SACCH_LENGTH_BITS); + ::edac::CRC::addCRC6(buffer, NXDN_SACCH_LENGTH_BITS); #if DEBUG_NXDN_SACCH Utils::dump(2U, "Encoded SACCH", buffer, NXDN_SACCH_CRC_LENGTH_BYTES); @@ -218,7 +217,7 @@ void SACCH::encode(uint8_t* data) const uint8_t convolution[NXDN_SACCH_FEC_CONV_LENGTH_BYTES]; ::memset(convolution, 0x00U, NXDN_SACCH_FEC_CONV_LENGTH_BYTES); - Convolution conv; + edac::Convolution conv; conv.encode(buffer, convolution, NXDN_SACCH_CRC_LENGTH_BITS); // puncture diff --git a/nxdn/channel/UDCH.cpp b/nxdn/channel/UDCH.cpp index 798e46ea..167d6c83 100644 --- a/nxdn/channel/UDCH.cpp +++ b/nxdn/channel/UDCH.cpp @@ -29,13 +29,12 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "nxdn/channel/UDCH.h" -#include "nxdn/Convolution.h" +#include "nxdn/edac/Convolution.h" #include "nxdn/NXDNDefines.h" #include "edac/CRC.h" #include "Log.h" #include "Utils.h" -using namespace edac; using namespace nxdn; using namespace nxdn::channel; @@ -177,7 +176,7 @@ bool UDCH::decode(const uint8_t* data) } // decode convolution - Convolution conv; + edac::Convolution conv; conv.start(); n = 0U; @@ -198,7 +197,7 @@ bool UDCH::decode(const uint8_t* data) #endif // check CRC-15 - bool ret = CRC::checkCRC15(m_data, NXDN_UDCH_LENGTH_BITS); + bool ret = ::edac::CRC::checkCRC15(m_data, NXDN_UDCH_LENGTH_BITS); if (!ret) { LogError(LOG_NXDN, "UDCH::decode(), failed CRC-15 check"); return false; @@ -223,7 +222,7 @@ void UDCH::encode(uint8_t* data) const ::memset(buffer, 0x00U, NXDN_UDCH_CRC_LENGTH_BYTES); ::memcpy(buffer, m_data, 23U); - CRC::addCRC15(buffer, NXDN_UDCH_LENGTH_BITS); + ::edac::CRC::addCRC15(buffer, NXDN_UDCH_LENGTH_BITS); #if DEBUG_NXDN_UDCH Utils::dump(2U, "Encoded UDCH", m_data, NXDN_UDCH_CRC_LENGTH_BYTES); @@ -233,7 +232,7 @@ void UDCH::encode(uint8_t* data) const uint8_t convolution[NXDN_UDCH_FEC_CONV_LENGTH_BYTES]; ::memset(convolution, 0x00U, NXDN_UDCH_FEC_CONV_LENGTH_BYTES); - Convolution conv; + edac::Convolution conv; conv.encode(buffer, convolution, NXDN_UDCH_CRC_LENGTH_BITS); // puncture diff --git a/nxdn/Convolution.cpp b/nxdn/edac/Convolution.cpp similarity index 98% rename from nxdn/Convolution.cpp rename to nxdn/edac/Convolution.cpp index c8ced0ad..9f61cb73 100644 --- a/nxdn/Convolution.cpp +++ b/nxdn/edac/Convolution.cpp @@ -28,11 +28,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "nxdn/Convolution.h" +#include "nxdn/edac/Convolution.h" #include "Log.h" #include "Utils.h" -using namespace nxdn; +using namespace nxdn::edac; #include #include diff --git a/nxdn/edac/Convolution.h b/nxdn/edac/Convolution.h new file mode 100644 index 00000000..1ceebb8b --- /dev/null +++ b/nxdn/edac/Convolution.h @@ -0,0 +1,78 @@ +/** +* Digital Voice Modem - Host Software +* GPLv2 Open Source. Use is subject to license terms. +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* @package DVM / Host Software +* +*/ +// +// Based on code from the MMDVMHost project. (https://github.com/g4klx/MMDVMHost) +// Licensed under the GPLv2 License (https://opensource.org/licenses/GPL-2.0) +// +/* +* Copyright (C) 2015,2016,2018,2021 by Jonathan Naylor G4KLX +* Copyright (C) 2022 by Bryan Biedenkapp N2PLL +* +* 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 +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +#if !defined(__NXDN_EDAC__CONVOLUTION_H__) +#define __NXDN_EDAC__CONVOLUTION_H__ + +#include "Defines.h" + +#include + +namespace nxdn +{ + namespace edac + { + // --------------------------------------------------------------------------- + // Class Declaration + // Implements NXDN frame convolution processing. + // --------------------------------------------------------------------------- + + class HOST_SW_API Convolution { + public: + /// Initializes a new instance of the Convolution class. + Convolution(); + /// Finalizes a instance of the Convolution class. + ~Convolution(); + + /// + void start(); + /// + uint32_t chainback(uint8_t* out, uint32_t nBits); + + /// + bool decode(uint8_t s0, uint8_t s1); + /// + void encode(const uint8_t* in, uint8_t* out, uint32_t nBits) const; + + private: + uint16_t* m_metrics1; + uint16_t* m_metrics2; + + uint16_t* m_oldMetrics; + uint16_t* m_newMetrics; + + uint64_t* m_decisions; + + uint64_t* m_dp; + }; + } // namespace edac +} // namespace nxdn + +#endif // __NXDN_EDAC__CONVOLUTION_H__