mirror of
https://github.com/g4klx/MMDVMHost
synced 2025-12-21 06:55:52 +08:00
Merge branch 'master' into mqtt
This commit is contained in:
16
DMRSlot.cpp
16
DMRSlot.cpp
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2021,2023 Jonathan Naylor, G4KLX
|
||||
* Copyright (C) 2015-2021,2023,2024 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
|
||||
@@ -15,10 +15,10 @@
|
||||
#include "DMRDataHeader.h"
|
||||
#include "DMRSlotType.h"
|
||||
#include "DMRShortLC.h"
|
||||
#include "DMRTrellis.h"
|
||||
#include "DMRFullLC.h"
|
||||
#include "BPTC19696.h"
|
||||
#include "DMRSlot.h"
|
||||
#include "Trellis.h"
|
||||
#include "DMRCSBK.h"
|
||||
#include "DMREMB.h"
|
||||
#include "Utils.h"
|
||||
@@ -576,13 +576,13 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
|
||||
CUtils::dump(1U, title, payload, 12U);
|
||||
bptc.encode(payload, data + 2U);
|
||||
} else if (dataType == DT_RATE_34_DATA) {
|
||||
CDMRTrellis trellis;
|
||||
CTrellis trellis;
|
||||
unsigned char payload[18U];
|
||||
bool ret = trellis.decode(data + 2U, payload);
|
||||
bool ret = trellis.decode34(data + 2U, payload);
|
||||
if (ret) {
|
||||
::sprintf(title, "DMR Slot %u, Data 3/4", m_slotNo);
|
||||
CUtils::dump(1U, title, payload, 18U);
|
||||
trellis.encode(payload, data + 2U);
|
||||
trellis.encode34(payload, data + 2U);
|
||||
} else {
|
||||
LogMessage("DMR Slot %u, unfixable RF rate 3/4 data", m_slotNo);
|
||||
CUtils::dump(1U, "Data", data + 2U, DMR_FRAME_LENGTH_BYTES);
|
||||
@@ -1768,13 +1768,13 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
|
||||
CUtils::dump(1U, title, payload, 12U);
|
||||
bptc.encode(payload, data + 2U);
|
||||
} else if (dataType == DT_RATE_34_DATA) {
|
||||
CDMRTrellis trellis;
|
||||
CTrellis trellis;
|
||||
unsigned char payload[18U];
|
||||
bool ret = trellis.decode(data + 2U, payload);
|
||||
bool ret = trellis.decode34(data + 2U, payload);
|
||||
if (ret) {
|
||||
::sprintf(title, "DMR Slot %u, Data 3/4", m_slotNo);
|
||||
CUtils::dump(1U, title, payload, 18U);
|
||||
trellis.encode(payload, data + 2U);
|
||||
trellis.encode34(payload, data + 2U);
|
||||
} else {
|
||||
LogMessage("DMR Slot %u, unfixable network rate 3/4 data", m_slotNo);
|
||||
CUtils::dump(1U, "Data", data + 2U, DMR_FRAME_LENGTH_BYTES);
|
||||
|
||||
379
DMRTrellis.cpp
379
DMRTrellis.cpp
@@ -1,379 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016,2023 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
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "DMRTrellis.h"
|
||||
#include "DMRDefines.h"
|
||||
#include "Log.h"
|
||||
|
||||
#if defined(USE_DMR)
|
||||
|
||||
#include <cstdio>
|
||||
#include <cassert>
|
||||
|
||||
const unsigned int INTERLEAVE_TABLE[] = {
|
||||
0U, 1U, 8U, 9U, 16U, 17U, 24U, 25U, 32U, 33U, 40U, 41U, 48U, 49U, 56U, 57U, 64U, 65U, 72U, 73U, 80U, 81U, 88U, 89U, 96U, 97U,
|
||||
2U, 3U, 10U, 11U, 18U, 19U, 26U, 27U, 34U, 35U, 42U, 43U, 50U, 51U, 58U, 59U, 66U, 67U, 74U, 75U, 82U, 83U, 90U, 91U,
|
||||
4U, 5U, 12U, 13U, 20U, 21U, 28U, 29U, 36U, 37U, 44U, 45U, 52U, 53U, 60U, 61U, 68U, 69U, 76U, 77U, 84U, 85U, 92U, 93U,
|
||||
6U, 7U, 14U, 15U, 22U, 23U, 30U, 31U, 38U, 39U, 46U, 47U, 54U, 55U, 62U, 63U, 70U, 71U, 78U, 79U, 86U, 87U, 94U, 95U};
|
||||
|
||||
const unsigned char ENCODE_TABLE[] = {
|
||||
0U, 8U, 4U, 12U, 2U, 10U, 6U, 14U,
|
||||
4U, 12U, 2U, 10U, 6U, 14U, 0U, 8U,
|
||||
1U, 9U, 5U, 13U, 3U, 11U, 7U, 15U,
|
||||
5U, 13U, 3U, 11U, 7U, 15U, 1U, 9U,
|
||||
3U, 11U, 7U, 15U, 1U, 9U, 5U, 13U,
|
||||
7U, 15U, 1U, 9U, 5U, 13U, 3U, 11U,
|
||||
2U, 10U, 6U, 14U, 0U, 8U, 4U, 12U,
|
||||
6U, 14U, 0U, 8U, 4U, 12U, 2U, 10U};
|
||||
|
||||
const unsigned char BIT_MASK_TABLE[] = {0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U, 0x02U, 0x01U};
|
||||
|
||||
#define WRITE_BIT(p,i,b) p[(i)>>3] = (b) ? (p[(i)>>3] | BIT_MASK_TABLE[(i)&7]) : (p[(i)>>3] & ~BIT_MASK_TABLE[(i)&7])
|
||||
#define READ_BIT(p,i) (p[(i)>>3] & BIT_MASK_TABLE[(i)&7])
|
||||
|
||||
CDMRTrellis::CDMRTrellis()
|
||||
{
|
||||
}
|
||||
|
||||
CDMRTrellis::~CDMRTrellis()
|
||||
{
|
||||
}
|
||||
|
||||
bool CDMRTrellis::decode(const unsigned char* data, unsigned char* payload)
|
||||
{
|
||||
assert(data != NULL);
|
||||
assert(payload != NULL);
|
||||
|
||||
signed char dibits[98U];
|
||||
deinterleave(data, dibits);
|
||||
|
||||
unsigned char points[49U];
|
||||
dibitsToPoints(dibits, points);
|
||||
|
||||
// Check the original code
|
||||
unsigned char tribits[49U];
|
||||
unsigned int failPos = checkCode(points, tribits);
|
||||
if (failPos == 999U) {
|
||||
tribitsToBits(tribits, payload);
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned char savePoints[49U];
|
||||
for (unsigned int i = 0U; i < 49U; i++)
|
||||
savePoints[i] = points[i];
|
||||
|
||||
bool ret = fixCode(points, failPos, payload);
|
||||
if (ret)
|
||||
return true;
|
||||
|
||||
if (failPos == 0U)
|
||||
return false;
|
||||
|
||||
// Backtrack one place for a last go
|
||||
return fixCode(savePoints, failPos - 1U, payload);
|
||||
}
|
||||
|
||||
void CDMRTrellis::encode(const unsigned char* payload, unsigned char* data)
|
||||
{
|
||||
assert(payload != NULL);
|
||||
assert(data != NULL);
|
||||
|
||||
unsigned char tribits[49U];
|
||||
bitsToTribits(payload, tribits);
|
||||
|
||||
unsigned char points[49U];
|
||||
unsigned char state = 0U;
|
||||
|
||||
for (unsigned int i = 0U; i < 49U; i++) {
|
||||
unsigned char tribit = tribits[i];
|
||||
|
||||
points[i] = ENCODE_TABLE[state * 8U + tribit];
|
||||
|
||||
state = tribit;
|
||||
}
|
||||
|
||||
signed char dibits[98U];
|
||||
pointsToDibits(points, dibits);
|
||||
|
||||
interleave(dibits, data);
|
||||
}
|
||||
|
||||
void CDMRTrellis::deinterleave(const unsigned char* data, signed char* dibits) const
|
||||
{
|
||||
for (unsigned int i = 0U; i < 98U; i++) {
|
||||
unsigned int n = i * 2U + 0U;
|
||||
if (n >= 98U) n += 68U;
|
||||
bool b1 = READ_BIT(data, n) != 0x00U;
|
||||
|
||||
n = i * 2U + 1U;
|
||||
if (n >= 98U) n += 68U;
|
||||
bool b2 = READ_BIT(data, n) != 0x00U;
|
||||
|
||||
signed char dibit;
|
||||
if (!b1 && b2)
|
||||
dibit = +3;
|
||||
else if (!b1 && !b2)
|
||||
dibit = +1;
|
||||
else if (b1 && !b2)
|
||||
dibit = -1;
|
||||
else
|
||||
dibit = -3;
|
||||
|
||||
n = INTERLEAVE_TABLE[i];
|
||||
dibits[n] = dibit;
|
||||
}
|
||||
}
|
||||
|
||||
void CDMRTrellis::interleave(const signed char* dibits, unsigned char* data) const
|
||||
{
|
||||
for (unsigned int i = 0U; i < 98U; i++) {
|
||||
unsigned int n = INTERLEAVE_TABLE[i];
|
||||
|
||||
bool b1, b2;
|
||||
switch (dibits[n]) {
|
||||
case +3:
|
||||
b1 = false;
|
||||
b2 = true;
|
||||
break;
|
||||
case +1:
|
||||
b1 = false;
|
||||
b2 = false;
|
||||
break;
|
||||
case -1:
|
||||
b1 = true;
|
||||
b2 = false;
|
||||
break;
|
||||
default:
|
||||
b1 = true;
|
||||
b2 = true;
|
||||
break;
|
||||
}
|
||||
|
||||
n = i * 2U + 0U;
|
||||
if (n >= 98U) n += 68U;
|
||||
WRITE_BIT(data, n, b1);
|
||||
|
||||
n = i * 2U + 1U;
|
||||
if (n >= 98U) n += 68U;
|
||||
WRITE_BIT(data, n, b2);
|
||||
}
|
||||
}
|
||||
|
||||
void CDMRTrellis::dibitsToPoints(const signed char* dibits, unsigned char* points) const
|
||||
{
|
||||
for (unsigned int i = 0U; i < 49U; i++) {
|
||||
if (dibits[i * 2U + 0U] == +1 && dibits[i * 2U + 1U] == -1)
|
||||
points[i] = 0U;
|
||||
else if (dibits[i * 2U + 0U] == -1 && dibits[i * 2U + 1U] == -1)
|
||||
points[i] = 1U;
|
||||
else if (dibits[i * 2U + 0U] == +3 && dibits[i * 2U + 1U] == -3)
|
||||
points[i] = 2U;
|
||||
else if (dibits[i * 2U + 0U] == -3 && dibits[i * 2U + 1U] == -3)
|
||||
points[i] = 3U;
|
||||
else if (dibits[i * 2U + 0U] == -3 && dibits[i * 2U + 1U] == -1)
|
||||
points[i] = 4U;
|
||||
else if (dibits[i * 2U + 0U] == +3 && dibits[i * 2U + 1U] == -1)
|
||||
points[i] = 5U;
|
||||
else if (dibits[i * 2U + 0U] == -1 && dibits[i * 2U + 1U] == -3)
|
||||
points[i] = 6U;
|
||||
else if (dibits[i * 2U + 0U] == +1 && dibits[i * 2U + 1U] == -3)
|
||||
points[i] = 7U;
|
||||
else if (dibits[i * 2U + 0U] == -3 && dibits[i * 2U + 1U] == +3)
|
||||
points[i] = 8U;
|
||||
else if (dibits[i * 2U + 0U] == +3 && dibits[i * 2U + 1U] == +3)
|
||||
points[i] = 9U;
|
||||
else if (dibits[i * 2U + 0U] == -1 && dibits[i * 2U + 1U] == +1)
|
||||
points[i] = 10U;
|
||||
else if (dibits[i * 2U + 0U] == +1 && dibits[i * 2U + 1U] == +1)
|
||||
points[i] = 11U;
|
||||
else if (dibits[i * 2U + 0U] == +1 && dibits[i * 2U + 1U] == +3)
|
||||
points[i] = 12U;
|
||||
else if (dibits[i * 2U + 0U] == -1 && dibits[i * 2U + 1U] == +3)
|
||||
points[i] = 13U;
|
||||
else if (dibits[i * 2U + 0U] == +3 && dibits[i * 2U + 1U] == +1)
|
||||
points[i] = 14U;
|
||||
else if (dibits[i * 2U + 0U] == -3 && dibits[i * 2U + 1U] == +1)
|
||||
points[i] = 15U;
|
||||
}
|
||||
}
|
||||
|
||||
void CDMRTrellis::pointsToDibits(const unsigned char* points, signed char* dibits) const
|
||||
{
|
||||
for (unsigned int i = 0U; i < 49U; i++) {
|
||||
switch (points[i]) {
|
||||
case 0U:
|
||||
dibits[i * 2U + 0U] = +1;
|
||||
dibits[i * 2U + 1U] = -1;
|
||||
break;
|
||||
case 1U:
|
||||
dibits[i * 2U + 0U] = -1;
|
||||
dibits[i * 2U + 1U] = -1;
|
||||
break;
|
||||
case 2U:
|
||||
dibits[i * 2U + 0U] = +3;
|
||||
dibits[i * 2U + 1U] = -3;
|
||||
break;
|
||||
case 3U:
|
||||
dibits[i * 2U + 0U] = -3;
|
||||
dibits[i * 2U + 1U] = -3;
|
||||
break;
|
||||
case 4U:
|
||||
dibits[i * 2U + 0U] = -3;
|
||||
dibits[i * 2U + 1U] = -1;
|
||||
break;
|
||||
case 5U:
|
||||
dibits[i * 2U + 0U] = +3;
|
||||
dibits[i * 2U + 1U] = -1;
|
||||
break;
|
||||
case 6U:
|
||||
dibits[i * 2U + 0U] = -1;
|
||||
dibits[i * 2U + 1U] = -3;
|
||||
break;
|
||||
case 7U:
|
||||
dibits[i * 2U + 0U] = +1;
|
||||
dibits[i * 2U + 1U] = -3;
|
||||
break;
|
||||
case 8U:
|
||||
dibits[i * 2U + 0U] = -3;
|
||||
dibits[i * 2U + 1U] = +3;
|
||||
break;
|
||||
case 9U:
|
||||
dibits[i * 2U + 0U] = +3;
|
||||
dibits[i * 2U + 1U] = +3;
|
||||
break;
|
||||
case 10U:
|
||||
dibits[i * 2U + 0U] = -1;
|
||||
dibits[i * 2U + 1U] = +1;
|
||||
break;
|
||||
case 11U:
|
||||
dibits[i * 2U + 0U] = +1;
|
||||
dibits[i * 2U + 1U] = +1;
|
||||
break;
|
||||
case 12U:
|
||||
dibits[i * 2U + 0U] = +1;
|
||||
dibits[i * 2U + 1U] = +3;
|
||||
break;
|
||||
case 13U:
|
||||
dibits[i * 2U + 0U] = -1;
|
||||
dibits[i * 2U + 1U] = +3;
|
||||
break;
|
||||
case 14U:
|
||||
dibits[i * 2U + 0U] = +3;
|
||||
dibits[i * 2U + 1U] = +1;
|
||||
break;
|
||||
default:
|
||||
dibits[i * 2U + 0U] = -3;
|
||||
dibits[i * 2U + 1U] = +1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CDMRTrellis::bitsToTribits(const unsigned char* payload, unsigned char* tribits) const
|
||||
{
|
||||
for (unsigned int i = 0U; i < 48U; i++) {
|
||||
unsigned int n = i * 3U;
|
||||
|
||||
bool b1 = READ_BIT(payload, n) != 0x00U;
|
||||
n++;
|
||||
bool b2 = READ_BIT(payload, n) != 0x00U;
|
||||
n++;
|
||||
bool b3 = READ_BIT(payload, n) != 0x00U;
|
||||
|
||||
unsigned char tribit = 0U;
|
||||
tribit |= b1 ? 4U : 0U;
|
||||
tribit |= b2 ? 2U : 0U;
|
||||
tribit |= b3 ? 1U : 0U;
|
||||
|
||||
tribits[i] = tribit;
|
||||
}
|
||||
|
||||
tribits[48U] = 0U;
|
||||
}
|
||||
|
||||
void CDMRTrellis::tribitsToBits(const unsigned char* tribits, unsigned char* payload) const
|
||||
{
|
||||
for (unsigned int i = 0U; i < 48U; i++) {
|
||||
unsigned char tribit = tribits[i];
|
||||
|
||||
bool b1 = (tribit & 0x04U) == 0x04U;
|
||||
bool b2 = (tribit & 0x02U) == 0x02U;
|
||||
bool b3 = (tribit & 0x01U) == 0x01U;
|
||||
|
||||
unsigned int n = i * 3U;
|
||||
|
||||
WRITE_BIT(payload, n, b1);
|
||||
n++;
|
||||
WRITE_BIT(payload, n, b2);
|
||||
n++;
|
||||
WRITE_BIT(payload, n, b3);
|
||||
}
|
||||
}
|
||||
|
||||
bool CDMRTrellis::fixCode(unsigned char* points, unsigned int failPos, unsigned char* payload) const
|
||||
{
|
||||
for (unsigned j = 0U; j < 20U; j++) {
|
||||
unsigned int bestPos = 0U;
|
||||
unsigned int bestVal = 0U;
|
||||
|
||||
for (unsigned int i = 0U; i < 16U; i++) {
|
||||
points[failPos] = i;
|
||||
|
||||
unsigned char tribits[49U];
|
||||
unsigned int pos = checkCode(points, tribits);
|
||||
if (pos == 999U) {
|
||||
tribitsToBits(tribits, payload);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pos > bestPos) {
|
||||
bestPos = pos;
|
||||
bestVal = i;
|
||||
}
|
||||
}
|
||||
|
||||
points[failPos] = bestVal;
|
||||
failPos = bestPos;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int CDMRTrellis::checkCode(const unsigned char* points, unsigned char* tribits) const
|
||||
{
|
||||
unsigned char state = 0U;
|
||||
|
||||
for (unsigned int i = 0U; i < 49U; i++) {
|
||||
tribits[i] = 9U;
|
||||
|
||||
for (unsigned int j = 0U; j < 8U; j++) {
|
||||
if (points[i] == ENCODE_TABLE[state * 8U + j]) {
|
||||
tribits[i] = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tribits[i] == 9U)
|
||||
return i;
|
||||
|
||||
state = tribits[i];
|
||||
}
|
||||
|
||||
if (tribits[48U] != 0U)
|
||||
return 48U;
|
||||
|
||||
return 999U;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
43
DMRTrellis.h
43
DMRTrellis.h
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016,2023 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
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef DMRTrellis_H
|
||||
#define DMRTrellis_H
|
||||
|
||||
#include "Defines.h"
|
||||
|
||||
#if defined(USE_DMR)
|
||||
|
||||
class CDMRTrellis {
|
||||
public:
|
||||
CDMRTrellis();
|
||||
~CDMRTrellis();
|
||||
|
||||
bool decode(const unsigned char* data, unsigned char* payload);
|
||||
void encode(const unsigned char* payload, unsigned char* data);
|
||||
|
||||
private:
|
||||
void deinterleave(const unsigned char* in, signed char* dibits) const;
|
||||
void interleave(const signed char* dibits, unsigned char* out) const;
|
||||
void dibitsToPoints(const signed char* dibits, unsigned char* points) const;
|
||||
void pointsToDibits(const unsigned char* points, signed char* dibits) const;
|
||||
void bitsToTribits(const unsigned char* payload, unsigned char* tribits) const;
|
||||
void tribitsToBits(const unsigned char* tribits, unsigned char* payload) const;
|
||||
bool fixCode(unsigned char* points, unsigned int failPos, unsigned char* payload) const;
|
||||
unsigned int checkCode(const unsigned char* points, unsigned char* tribits) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -184,7 +184,6 @@
|
||||
<ClInclude Include="DMRSlot.h" />
|
||||
<ClInclude Include="DMRSlotType.h" />
|
||||
<ClInclude Include="DMRTA.h" />
|
||||
<ClInclude Include="DMRTrellis.h" />
|
||||
<ClInclude Include="DStarControl.h" />
|
||||
<ClInclude Include="DStarDefines.h" />
|
||||
<ClInclude Include="DStarHeader.h" />
|
||||
@@ -230,7 +229,6 @@
|
||||
<ClInclude Include="P25LowSpeedData.h" />
|
||||
<ClInclude Include="P25Network.h" />
|
||||
<ClInclude Include="P25NID.h" />
|
||||
<ClInclude Include="P25Trellis.h" />
|
||||
<ClInclude Include="P25Utils.h" />
|
||||
<ClInclude Include="POCSAGControl.h" />
|
||||
<ClInclude Include="POCSAGDefines.h" />
|
||||
@@ -243,6 +241,7 @@
|
||||
<ClInclude Include="RS634717.h" />
|
||||
<ClInclude Include="RSSIInterpolator.h" />
|
||||
<ClInclude Include="NXDNSACCH.h" />
|
||||
<ClInclude Include="Trellis.h" />
|
||||
<ClInclude Include="UARTController.h" />
|
||||
<ClInclude Include="Modem.h" />
|
||||
<ClInclude Include="SerialPort.h" />
|
||||
@@ -286,7 +285,6 @@
|
||||
<ClCompile Include="DMRSlot.cpp" />
|
||||
<ClCompile Include="DMRSlotType.cpp" />
|
||||
<ClCompile Include="DMRTA.cpp" />
|
||||
<ClCompile Include="DMRTrellis.cpp" />
|
||||
<ClCompile Include="DStarControl.cpp" />
|
||||
<ClCompile Include="DStarHeader.cpp" />
|
||||
<ClCompile Include="DStarNetwork.cpp" />
|
||||
@@ -328,7 +326,6 @@
|
||||
<ClCompile Include="P25LowSpeedData.cpp" />
|
||||
<ClCompile Include="P25Network.cpp" />
|
||||
<ClCompile Include="P25NID.cpp" />
|
||||
<ClCompile Include="P25Trellis.cpp" />
|
||||
<ClCompile Include="P25Utils.cpp" />
|
||||
<ClCompile Include="POCSAGControl.cpp" />
|
||||
<ClCompile Include="POCSAGNetwork.cpp" />
|
||||
@@ -337,6 +334,7 @@
|
||||
<ClCompile Include="RS129.cpp" />
|
||||
<ClCompile Include="RS634717.cpp" />
|
||||
<ClCompile Include="RSSIInterpolator.cpp" />
|
||||
<ClCompile Include="Trellis.cpp" />
|
||||
<ClCompile Include="UARTController.cpp" />
|
||||
<ClCompile Include="Modem.cpp" />
|
||||
<ClCompile Include="SerialPort.cpp" />
|
||||
|
||||
@@ -146,9 +146,6 @@
|
||||
<ClInclude Include="Thread.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DMRTrellis.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DMRAccessControl.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
@@ -191,9 +188,6 @@
|
||||
<ClInclude Include="RSSIInterpolator.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="P25Trellis.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="NXDNDefines.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
@@ -317,6 +311,9 @@
|
||||
<ClInclude Include="RS.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Trellis.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="BPTC19696.cpp">
|
||||
@@ -436,9 +433,6 @@
|
||||
<ClCompile Include="Thread.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DMRTrellis.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DMRAccessControl.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@@ -478,9 +472,6 @@
|
||||
<ClCompile Include="RSSIInterpolator.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="P25Trellis.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="NXDNControl.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@@ -589,5 +580,8 @@
|
||||
<ClCompile Include="RS634717.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Trellis.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
19
Makefile
19
Makefile
@@ -7,17 +7,16 @@ LIBS = -lpthread -lutil -lsamplerate -lmosquitto
|
||||
LDFLAGS = -g -L/usr/local/lib
|
||||
|
||||
OBJECTS = \
|
||||
AMBEFEC.o BCH.o AX25Control.o AX25Network.o BPTC19696.o Conf.o CRC.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o \
|
||||
DMREMB.o DMREmbeddedData.o DMRFullLC.o DMRLookup.o DMRLC.o DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o \
|
||||
DMRAccessControl.o DMRTA.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o FMControl.o FMNetwork.o Golay2087.o Golay24128.o \
|
||||
Hamming.o I2CController.o IIRDirectForm1Filter.o Log.o M17Control.o M17Convolution.o M17CRC.o M17LSF.o M17Network.o M17Utils.o MMDVMHost.o \
|
||||
MQTTConnection.o Modem.o ModemPort.o Mutex.o NullController.o NXDNAudio.o NXDNControl.o \
|
||||
NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o NXDNIcomNetwork.o NXDNKenwoodNetwork.o NXDNLayer3.o NXDNLICH.o NXDNLookup.o NXDNNetwork.o NXDNSACCH.o \
|
||||
NXDNUDCH.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o P25NID.o P25Trellis.o P25Utils.o POCSAGControl.o \
|
||||
POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS634717.o RSSIInterpolator.o SerialPort.o StopWatch.o Sync.o Thread.o \
|
||||
Timer.o UARTController.o UDPController.o UDPSocket.o UserDB.o UserDBentry.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
|
||||
AMBEFEC.o BCH.o AX25Control.o AX25Network.o BPTC19696.o Conf.o CRC.o DMRAccessControl.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o \
|
||||
DMREmbeddedData.o DMRFullLC.o DMRLookup.o DMRLC.o DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRTA.o DStarControl.o DStarHeader.o \
|
||||
DStarNetwork.o DStarSlowData.o FMControl.o FMNetwork.o Golay2087.o Golay24128.o Hamming.o I2CController.o IIRDirectForm1Filter.o Log.o M17Control.o \
|
||||
M17Convolution.o M17CRC.o M17LSF.o M17Network.o M17Utils.o MMDVMHost.o MQTTConnection.o Modem.o ModemPort.o Mutex.o NullController.o NXDNAudio.o \
|
||||
NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o NXDNIcomNetwork.o NXDNKenwoodNetwork.o NXDNLayer3.o NXDNLICH.o NXDNLookup.o NXDNNetwork.o \
|
||||
NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o P25NID.o P25Utils.o POCSAGControl.o POCSAGNetwork.o QR1676.o \
|
||||
RemoteControl.o RS129.o RS634717.o RSSIInterpolator.o SerialPort.o StopWatch.o Sync.o Thread.o Timer.o Trellis.o UARTController.o UDPController.o \
|
||||
UDPSocket.o UserDB.o UserDBentry.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
|
||||
|
||||
all: MMDVMHost
|
||||
all: MMDVMHost
|
||||
|
||||
MMDVMHost: GitVersion.h $(OBJECTS)
|
||||
$(CXX) $(OBJECTS) $(LDFLAGS) $(LIBS) -o MMDVMHost
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
#include "P25Control.h"
|
||||
#include "P25Defines.h"
|
||||
#include "P25Trellis.h"
|
||||
#include "P25Utils.h"
|
||||
#include "Trellis.h"
|
||||
#include "Utils.h"
|
||||
#include "Sync.h"
|
||||
#include "CRC.h"
|
||||
@@ -539,7 +539,7 @@ bool CP25Control::writeModem(unsigned char* data, unsigned int len)
|
||||
}
|
||||
|
||||
if (m_rfPDUCount == 0U) {
|
||||
CP25Trellis trellis;
|
||||
CTrellis trellis;
|
||||
unsigned char header[P25_PDU_HEADER_LENGTH_BYTES];
|
||||
bool valid = trellis.decode12(m_rfPDU + P25_SYNC_LENGTH_BYTES + P25_NID_LENGTH_BYTES, header);
|
||||
if (valid)
|
||||
@@ -568,7 +568,7 @@ bool CP25Control::writeModem(unsigned char* data, unsigned int len)
|
||||
unsigned int offset = P25_SYNC_LENGTH_BYTES + P25_NID_LENGTH_BYTES;
|
||||
|
||||
// Regenerate the PDU header
|
||||
CP25Trellis trellis;
|
||||
CTrellis trellis;
|
||||
unsigned char header[P25_PDU_HEADER_LENGTH_BYTES];
|
||||
trellis.decode12(m_rfPDU + offset, header);
|
||||
trellis.encode12(header, m_rfPDU + offset);
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#define P25Data_H
|
||||
|
||||
#include "RS634717.h"
|
||||
#include "P25Trellis.h"
|
||||
#include "Trellis.h"
|
||||
#include "Defines.h"
|
||||
|
||||
#if defined(USE_P25)
|
||||
@@ -85,7 +85,7 @@ private:
|
||||
unsigned int m_dstId;
|
||||
unsigned char m_serviceType;
|
||||
CRS634717 m_rs;
|
||||
CP25Trellis m_trellis;
|
||||
CTrellis m_trellis;
|
||||
|
||||
void decodeLDUHamming(const unsigned char* raw, unsigned char* data);
|
||||
void encodeLDUHamming(unsigned char* data, const unsigned char* raw);
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "P25Trellis.h"
|
||||
#include "Trellis.h"
|
||||
#include "Log.h"
|
||||
|
||||
#if defined(USE_P25)
|
||||
#if defined(USE_P25) || defined(USE_DMR)
|
||||
|
||||
#include <cstdio>
|
||||
#include <cassert>
|
||||
@@ -46,15 +46,15 @@ const unsigned char BIT_MASK_TABLE[] = {0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U
|
||||
#define WRITE_BIT(p,i,b) p[(i)>>3] = (b) ? (p[(i)>>3] | BIT_MASK_TABLE[(i)&7]) : (p[(i)>>3] & ~BIT_MASK_TABLE[(i)&7])
|
||||
#define READ_BIT(p,i) (p[(i)>>3] & BIT_MASK_TABLE[(i)&7])
|
||||
|
||||
CP25Trellis::CP25Trellis()
|
||||
CTrellis::CTrellis()
|
||||
{
|
||||
}
|
||||
|
||||
CP25Trellis::~CP25Trellis()
|
||||
CTrellis::~CTrellis()
|
||||
{
|
||||
}
|
||||
|
||||
bool CP25Trellis::decode34(const unsigned char* data, unsigned char* payload)
|
||||
bool CTrellis::decode34(const unsigned char* data, unsigned char* payload)
|
||||
{
|
||||
assert(data != NULL);
|
||||
assert(payload != NULL);
|
||||
@@ -88,7 +88,7 @@ bool CP25Trellis::decode34(const unsigned char* data, unsigned char* payload)
|
||||
return fixCode34(savePoints, failPos - 1U, payload);
|
||||
}
|
||||
|
||||
void CP25Trellis::encode34(const unsigned char* payload, unsigned char* data)
|
||||
void CTrellis::encode34(const unsigned char* payload, unsigned char* data)
|
||||
{
|
||||
assert(payload != NULL);
|
||||
assert(data != NULL);
|
||||
@@ -113,7 +113,7 @@ void CP25Trellis::encode34(const unsigned char* payload, unsigned char* data)
|
||||
interleave(dibits, data);
|
||||
}
|
||||
|
||||
bool CP25Trellis::decode12(const unsigned char* data, unsigned char* payload)
|
||||
bool CTrellis::decode12(const unsigned char* data, unsigned char* payload)
|
||||
{
|
||||
assert(data != NULL);
|
||||
assert(payload != NULL);
|
||||
@@ -147,7 +147,7 @@ bool CP25Trellis::decode12(const unsigned char* data, unsigned char* payload)
|
||||
return fixCode12(savePoints, failPos - 1U, payload);
|
||||
}
|
||||
|
||||
void CP25Trellis::encode12(const unsigned char* payload, unsigned char* data)
|
||||
void CTrellis::encode12(const unsigned char* payload, unsigned char* data)
|
||||
{
|
||||
assert(payload != NULL);
|
||||
assert(data != NULL);
|
||||
@@ -172,7 +172,7 @@ void CP25Trellis::encode12(const unsigned char* payload, unsigned char* data)
|
||||
interleave(dibits, data);
|
||||
}
|
||||
|
||||
void CP25Trellis::deinterleave(const unsigned char* data, signed char* dibits) const
|
||||
void CTrellis::deinterleave(const unsigned char* data, signed char* dibits) const
|
||||
{
|
||||
for (unsigned int i = 0U; i < 98U; i++) {
|
||||
unsigned int n = i * 2U + 0U;
|
||||
@@ -196,7 +196,7 @@ void CP25Trellis::deinterleave(const unsigned char* data, signed char* dibits) c
|
||||
}
|
||||
}
|
||||
|
||||
void CP25Trellis::interleave(const signed char* dibits, unsigned char* data) const
|
||||
void CTrellis::interleave(const signed char* dibits, unsigned char* data) const
|
||||
{
|
||||
for (unsigned int i = 0U; i < 98U; i++) {
|
||||
unsigned int n = INTERLEAVE_TABLE[i];
|
||||
@@ -229,7 +229,7 @@ void CP25Trellis::interleave(const signed char* dibits, unsigned char* data) con
|
||||
}
|
||||
}
|
||||
|
||||
void CP25Trellis::dibitsToPoints(const signed char* dibits, unsigned char* points) const
|
||||
void CTrellis::dibitsToPoints(const signed char* dibits, unsigned char* points) const
|
||||
{
|
||||
for (unsigned int i = 0U; i < 49U; i++) {
|
||||
if (dibits[i * 2U + 0U] == +1 && dibits[i * 2U + 1U] == -1)
|
||||
@@ -267,7 +267,7 @@ void CP25Trellis::dibitsToPoints(const signed char* dibits, unsigned char* point
|
||||
}
|
||||
}
|
||||
|
||||
void CP25Trellis::pointsToDibits(const unsigned char* points, signed char* dibits) const
|
||||
void CTrellis::pointsToDibits(const unsigned char* points, signed char* dibits) const
|
||||
{
|
||||
for (unsigned int i = 0U; i < 49U; i++) {
|
||||
switch (points[i]) {
|
||||
@@ -339,7 +339,7 @@ void CP25Trellis::pointsToDibits(const unsigned char* points, signed char* dibit
|
||||
}
|
||||
}
|
||||
|
||||
void CP25Trellis::bitsToTribits(const unsigned char* payload, unsigned char* tribits) const
|
||||
void CTrellis::bitsToTribits(const unsigned char* payload, unsigned char* tribits) const
|
||||
{
|
||||
for (unsigned int i = 0U; i < 48U; i++) {
|
||||
unsigned int n = i * 3U;
|
||||
@@ -361,7 +361,7 @@ void CP25Trellis::bitsToTribits(const unsigned char* payload, unsigned char* tri
|
||||
tribits[48U] = 0U;
|
||||
}
|
||||
|
||||
void CP25Trellis::bitsToDibits(const unsigned char* payload, unsigned char* dibits) const
|
||||
void CTrellis::bitsToDibits(const unsigned char* payload, unsigned char* dibits) const
|
||||
{
|
||||
for (unsigned int i = 0U; i < 48U; i++) {
|
||||
unsigned int n = i * 2U;
|
||||
@@ -380,7 +380,7 @@ void CP25Trellis::bitsToDibits(const unsigned char* payload, unsigned char* dibi
|
||||
dibits[48U] = 0U;
|
||||
}
|
||||
|
||||
void CP25Trellis::tribitsToBits(const unsigned char* tribits, unsigned char* payload) const
|
||||
void CTrellis::tribitsToBits(const unsigned char* tribits, unsigned char* payload) const
|
||||
{
|
||||
for (unsigned int i = 0U; i < 48U; i++) {
|
||||
unsigned char tribit = tribits[i];
|
||||
@@ -399,7 +399,7 @@ void CP25Trellis::tribitsToBits(const unsigned char* tribits, unsigned char* pay
|
||||
}
|
||||
}
|
||||
|
||||
void CP25Trellis::dibitsToBits(const unsigned char* dibits, unsigned char* payload) const
|
||||
void CTrellis::dibitsToBits(const unsigned char* dibits, unsigned char* payload) const
|
||||
{
|
||||
for (unsigned int i = 0U; i < 48U; i++) {
|
||||
unsigned char dibit = dibits[i];
|
||||
@@ -415,7 +415,7 @@ void CP25Trellis::dibitsToBits(const unsigned char* dibits, unsigned char* paylo
|
||||
}
|
||||
}
|
||||
|
||||
bool CP25Trellis::fixCode34(unsigned char* points, unsigned int failPos, unsigned char* payload) const
|
||||
bool CTrellis::fixCode34(unsigned char* points, unsigned int failPos, unsigned char* payload) const
|
||||
{
|
||||
for (unsigned j = 0U; j < 20U; j++) {
|
||||
unsigned int bestPos = 0U;
|
||||
@@ -444,7 +444,7 @@ bool CP25Trellis::fixCode34(unsigned char* points, unsigned int failPos, unsigne
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int CP25Trellis::checkCode34(const unsigned char* points, unsigned char* tribits) const
|
||||
unsigned int CTrellis::checkCode34(const unsigned char* points, unsigned char* tribits) const
|
||||
{
|
||||
unsigned char state = 0U;
|
||||
|
||||
@@ -471,7 +471,7 @@ unsigned int CP25Trellis::checkCode34(const unsigned char* points, unsigned char
|
||||
}
|
||||
|
||||
|
||||
bool CP25Trellis::fixCode12(unsigned char* points, unsigned int failPos, unsigned char* payload) const
|
||||
bool CTrellis::fixCode12(unsigned char* points, unsigned int failPos, unsigned char* payload) const
|
||||
{
|
||||
for (unsigned j = 0U; j < 20U; j++) {
|
||||
unsigned int bestPos = 0U;
|
||||
@@ -500,7 +500,7 @@ bool CP25Trellis::fixCode12(unsigned char* points, unsigned int failPos, unsigne
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int CP25Trellis::checkCode12(const unsigned char* points, unsigned char* dibits) const
|
||||
unsigned int CTrellis::checkCode12(const unsigned char* points, unsigned char* dibits) const
|
||||
{
|
||||
unsigned char state = 0U;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2016,2018,2023 by Jonathan Naylor, G4KLX
|
||||
* Copyright (C) 2016,2018,2023,2024 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
|
||||
@@ -11,17 +11,17 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef P25Trellis_H
|
||||
#define P25Trellis_H
|
||||
#ifndef Trellis_H
|
||||
#define Trellis_H
|
||||
|
||||
#include "Defines.h"
|
||||
|
||||
#if defined(USE_P25)
|
||||
#if defined(USE_P25) || defined(USE_DMR)
|
||||
|
||||
class CP25Trellis {
|
||||
class CTrellis {
|
||||
public:
|
||||
CP25Trellis();
|
||||
~CP25Trellis();
|
||||
CTrellis();
|
||||
~CTrellis();
|
||||
|
||||
bool decode34(const unsigned char* data, unsigned char* payload);
|
||||
void encode34(const unsigned char* payload, unsigned char* data);
|
||||
Reference in New Issue
Block a user