|
|
|
|
@ -73,8 +73,8 @@ const unsigned int INTERLEAVE_TABLE_5_20[] =
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// This one differs from the others in that it interleaves bits and not dibits
|
|
|
|
|
const unsigned char WHITENING_DATA[] = {0x93U, 0xD7U, 0x51U, 0x21U, 0x9CU, 0x2FU, 0x6CU, 0xD0U, 0xEFU, 0x0FU,
|
|
|
|
|
0xF8U, 0x3DU, 0xF1U, 0x73U, 0x20U, 0x94U, 0xEDU, 0x1EU, 0x7CU, 0xD8U
|
|
|
|
|
const unsigned char WHITENING_DATA[] = {
|
|
|
|
|
0x93U, 0xD7U, 0x51U, 0x21U, 0x9CU, 0x2FU, 0x6CU, 0xD0U, 0xEFU, 0x0FU, 0xF8U, 0x3DU, 0xF1U, 0x73U, 0x20U, 0x94U, 0xEDU, 0x1EU, 0x7CU, 0xD8U
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const unsigned char BIT_MASK_TABLE[] = { 0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U, 0x02U, 0x01U };
|
|
|
|
|
@ -82,22 +82,6 @@ const unsigned char BIT_MASK_TABLE[] = {0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U
|
|
|
|
|
#define WRITE_BIT1(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_BIT1(p,i) (p[(i)>>3] & BIT_MASK_TABLE[(i)&7])
|
|
|
|
|
|
|
|
|
|
CYSFPayload::CYSFPayload() :
|
|
|
|
|
m_uplink(nullptr),
|
|
|
|
|
m_downlink(nullptr),
|
|
|
|
|
m_source(nullptr),
|
|
|
|
|
m_dest(nullptr)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CYSFPayload::~CYSFPayload()
|
|
|
|
|
{
|
|
|
|
|
delete[] m_uplink;
|
|
|
|
|
delete[] m_downlink;
|
|
|
|
|
delete[] m_source;
|
|
|
|
|
delete[] m_dest;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CYSFPayload::processHeaderData(unsigned char* data)
|
|
|
|
|
{
|
|
|
|
|
assert(data != nullptr);
|
|
|
|
|
@ -140,14 +124,14 @@ bool CYSFPayload::processHeaderData(unsigned char* data)
|
|
|
|
|
|
|
|
|
|
if (m_dest == nullptr)
|
|
|
|
|
{
|
|
|
|
|
m_dest = new unsigned char[YSF_CALLSIGN_LENGTH];
|
|
|
|
|
::memcpy(m_dest, output + 0U, YSF_CALLSIGN_LENGTH);
|
|
|
|
|
m_dest = std::unique_ptr<unsigned char[]>(new unsigned char[YSF_CALLSIGN_LENGTH]);
|
|
|
|
|
::memcpy(m_dest.get(), output, YSF_CALLSIGN_LENGTH);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_source == nullptr)
|
|
|
|
|
{
|
|
|
|
|
m_source = new unsigned char[YSF_CALLSIGN_LENGTH];
|
|
|
|
|
::memcpy(m_source, output + YSF_CALLSIGN_LENGTH, YSF_CALLSIGN_LENGTH);
|
|
|
|
|
m_source = std::unique_ptr<unsigned char[]>(new unsigned char[YSF_CALLSIGN_LENGTH]);
|
|
|
|
|
::memcpy(m_source.get(), output + YSF_CALLSIGN_LENGTH, YSF_CALLSIGN_LENGTH);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (unsigned int i = 0U; i < 20U; i++)
|
|
|
|
|
@ -217,11 +201,11 @@ bool CYSFPayload::processHeaderData(unsigned char* data)
|
|
|
|
|
for (unsigned int i = 0U; i < 20U; i++)
|
|
|
|
|
output[i] ^= WHITENING_DATA[i];
|
|
|
|
|
|
|
|
|
|
if (m_downlink != nullptr)
|
|
|
|
|
::memcpy(output + 0U, m_downlink, YSF_CALLSIGN_LENGTH);
|
|
|
|
|
if (m_downlink)
|
|
|
|
|
::memcpy(output + 0U, m_downlink.get(), YSF_CALLSIGN_LENGTH);
|
|
|
|
|
|
|
|
|
|
if (m_uplink != nullptr)
|
|
|
|
|
::memcpy(output + YSF_CALLSIGN_LENGTH, m_uplink, YSF_CALLSIGN_LENGTH);
|
|
|
|
|
if (m_uplink)
|
|
|
|
|
::memcpy(output + YSF_CALLSIGN_LENGTH, m_uplink.get(), YSF_CALLSIGN_LENGTH);
|
|
|
|
|
|
|
|
|
|
for (unsigned int i = 0U; i < 20U; i++)
|
|
|
|
|
output[i] ^= WHITENING_DATA[i];
|
|
|
|
|
@ -618,7 +602,7 @@ void CYSFPayload::writeDataFRModeData2(const unsigned char* dt, unsigned char* d
|
|
|
|
|
|
|
|
|
|
void CYSFPayload::setUplink(const std::string& callsign)
|
|
|
|
|
{
|
|
|
|
|
m_uplink = new unsigned char[YSF_CALLSIGN_LENGTH];
|
|
|
|
|
m_uplink = std::unique_ptr<unsigned char[]>(new unsigned char[YSF_CALLSIGN_LENGTH]);
|
|
|
|
|
|
|
|
|
|
std::string uplink = callsign;
|
|
|
|
|
uplink.resize(YSF_CALLSIGN_LENGTH, ' ');
|
|
|
|
|
@ -629,7 +613,7 @@ void CYSFPayload::setUplink(const std::string& callsign)
|
|
|
|
|
|
|
|
|
|
void CYSFPayload::setDownlink(const std::string& callsign)
|
|
|
|
|
{
|
|
|
|
|
m_downlink = new unsigned char[YSF_CALLSIGN_LENGTH];
|
|
|
|
|
m_downlink = std::unique_ptr<unsigned char[]>(new unsigned char[YSF_CALLSIGN_LENGTH]);
|
|
|
|
|
|
|
|
|
|
std::string downlink = callsign;
|
|
|
|
|
downlink.resize(YSF_CALLSIGN_LENGTH, ' ');
|
|
|
|
|
@ -643,7 +627,7 @@ std::string CYSFPayload::getSource()
|
|
|
|
|
std::string tmp;
|
|
|
|
|
|
|
|
|
|
if (m_dest)
|
|
|
|
|
tmp.assign((const char *)m_source, YSF_CALLSIGN_LENGTH);
|
|
|
|
|
tmp.assign((const char *)m_source.get(), YSF_CALLSIGN_LENGTH);
|
|
|
|
|
else
|
|
|
|
|
tmp = "";
|
|
|
|
|
|
|
|
|
|
@ -655,7 +639,7 @@ std::string CYSFPayload::getDest()
|
|
|
|
|
std::string tmp;
|
|
|
|
|
|
|
|
|
|
if (m_dest)
|
|
|
|
|
tmp.assign((const char *)m_dest, YSF_CALLSIGN_LENGTH);
|
|
|
|
|
tmp.assign((const char *)m_dest.get(), YSF_CALLSIGN_LENGTH);
|
|
|
|
|
else
|
|
|
|
|
tmp = "";
|
|
|
|
|
|
|
|
|
|
@ -664,9 +648,6 @@ std::string CYSFPayload::getDest()
|
|
|
|
|
|
|
|
|
|
void CYSFPayload::reset()
|
|
|
|
|
{
|
|
|
|
|
delete[] m_source;
|
|
|
|
|
delete[] m_dest;
|
|
|
|
|
|
|
|
|
|
m_source = nullptr;
|
|
|
|
|
m_dest = nullptr;
|
|
|
|
|
m_source.reset();
|
|
|
|
|
m_dest.reset();
|
|
|
|
|
}
|
|
|
|
|
|