mirror of
https://github.com/g4klx/MMDVMHost
synced 2025-12-26 12:15:39 +08:00
Handle the P25 low speed data.
This commit is contained in:
@@ -18,16 +18,81 @@
|
||||
|
||||
#include "P25LowSpeedData.h"
|
||||
#include "P25Utils.h"
|
||||
#include "Utils.h"
|
||||
#include "Log.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cassert>
|
||||
|
||||
const unsigned int MAX_CCS_ERRS = 4U;
|
||||
|
||||
CP25LowSpeedData::CP25LowSpeedData()
|
||||
{
|
||||
}
|
||||
|
||||
CP25LowSpeedData::~CP25LowSpeedData()
|
||||
{
|
||||
}
|
||||
|
||||
void CP25LowSpeedData::process(unsigned char* data)
|
||||
{
|
||||
assert(data != NULL);
|
||||
|
||||
unsigned char lsd[4U];
|
||||
CP25Utils::decode(data, lsd, 1546U, 1578U);
|
||||
|
||||
CUtils::dump(1U, "P25, Low Speed Data", lsd, 4U);
|
||||
for (unsigned int a = 0x00U; a < 0x100U; a++) {
|
||||
unsigned char ccs[2U];
|
||||
ccs[0U] = a;
|
||||
ccs[1U] = encode(ccs[0U]);
|
||||
|
||||
unsigned int errs = CP25Utils::compare(ccs, lsd + 0U, 2U);
|
||||
if (errs < MAX_CCS_ERRS) {
|
||||
lsd[0U] = ccs[0U];
|
||||
lsd[1U] = ccs[1U];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned int a = 0x00U; a < 0x100U; a++) {
|
||||
unsigned char ccs[2U];
|
||||
ccs[0U] = a;
|
||||
ccs[1U] = encode(ccs[0U]);
|
||||
|
||||
unsigned int errs = CP25Utils::compare(ccs, lsd + 2U, 2U);
|
||||
if (errs < MAX_CCS_ERRS) {
|
||||
lsd[2U] = ccs[0U];
|
||||
lsd[3U] = ccs[1U];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char CP25LowSpeedData::encode(unsigned char in)
|
||||
{
|
||||
unsigned char result = 0x00U;
|
||||
|
||||
if ((in & 0x01U) == 0x01U)
|
||||
result ^= 0x39U;
|
||||
|
||||
if ((in & 0x02U) == 0x02U)
|
||||
result ^= 0x72U;
|
||||
|
||||
if ((in & 0x04U) == 0x04U)
|
||||
result ^= 0xE4U;
|
||||
|
||||
if ((in & 0x08U) == 0x08U)
|
||||
result ^= 0xF1U;
|
||||
|
||||
if ((in & 0x10U) == 0x10U)
|
||||
result ^= 0xDBU;
|
||||
|
||||
if ((in & 0x20U) == 0x20U)
|
||||
result ^= 0x8FU;
|
||||
|
||||
if ((in & 0x40U) == 0x40U)
|
||||
result ^= 0x27U;
|
||||
|
||||
if ((in & 0x80U) == 0x80U)
|
||||
result ^= 0x4EU;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user