Display the FICH errors and fix minor bugs.
This commit is contained in:
parent
d5bb3e6a8a
commit
7e560c7e3b
4 changed files with 41 additions and 7 deletions
|
@ -102,11 +102,15 @@ bool CYSFControl::writeModem(unsigned char *data)
|
||||||
if (valid && fi == YSF_FI_TERMINATOR) {
|
if (valid && fi == YSF_FI_TERMINATOR) {
|
||||||
CSync::addYSFSync(data + 2U);
|
CSync::addYSFSync(data + 2U);
|
||||||
|
|
||||||
|
m_fich.encode(data + 2U);
|
||||||
|
|
||||||
unsigned char fn = m_fich.getFN();
|
unsigned char fn = m_fich.getFN();
|
||||||
unsigned char ft = m_fich.getFT();
|
unsigned char ft = m_fich.getFT();
|
||||||
unsigned char dt = m_fich.getDT();
|
unsigned char dt = m_fich.getDT();
|
||||||
|
|
||||||
LogDebug("YSF, FI=%X FN=%u FT=%u DT=%X", fi, fn, ft, dt);
|
unsigned int errs = m_fich.getErrors();
|
||||||
|
|
||||||
|
LogDebug("YSF, FI=%X FN=%u FT=%u DT=%X Errs=%u", fi, fn, ft, dt, errs);
|
||||||
|
|
||||||
// m_payload.process(data + 2U, fi, fn, ft, dt);
|
// m_payload.process(data + 2U, fi, fn, ft, dt);
|
||||||
|
|
||||||
|
@ -142,12 +146,16 @@ bool CYSFControl::writeModem(unsigned char *data)
|
||||||
CSync::addYSFSync(data + 2U);
|
CSync::addYSFSync(data + 2U);
|
||||||
|
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
m_fich.encode(data + 2U);
|
||||||
|
|
||||||
unsigned char cm = m_fich.getCM();
|
unsigned char cm = m_fich.getCM();
|
||||||
unsigned char fn = m_fich.getFN();
|
unsigned char fn = m_fich.getFN();
|
||||||
unsigned char ft = m_fich.getFT();
|
unsigned char ft = m_fich.getFT();
|
||||||
unsigned char dt = m_fich.getDT();
|
unsigned char dt = m_fich.getDT();
|
||||||
|
|
||||||
LogDebug("YSF, FI=%X FN=%u FT=%u DT=%X", fi, fn, ft, dt);
|
unsigned int errs = m_fich.getErrors();
|
||||||
|
|
||||||
|
LogDebug("YSF, FI=%X FN=%u FT=%u DT=%X Errs=%u", fi, fn, ft, dt, errs);
|
||||||
|
|
||||||
// m_payload.process(data + 2U, fi, fn, ft, dt);
|
// m_payload.process(data + 2U, fi, fn, ft, dt);
|
||||||
|
|
||||||
|
|
24
YSFFICH.cpp
24
YSFFICH.cpp
|
@ -55,13 +55,17 @@ const unsigned int INTERLEAVE_TABLE[] = {
|
||||||
38U, 78U, 118U, 158U, 198U};
|
38U, 78U, 118U, 158U, 198U};
|
||||||
|
|
||||||
CYSFFICH::CYSFFICH() :
|
CYSFFICH::CYSFFICH() :
|
||||||
m_fich(NULL)
|
m_bytes(NULL),
|
||||||
|
m_fich(NULL),
|
||||||
|
m_errors(0U)
|
||||||
{
|
{
|
||||||
|
m_bytes = new unsigned char[YSF_FICH_LENGTH_BYTES];
|
||||||
m_fich = new unsigned char[6U];
|
m_fich = new unsigned char[6U];
|
||||||
}
|
}
|
||||||
|
|
||||||
CYSFFICH::~CYSFFICH()
|
CYSFFICH::~CYSFFICH()
|
||||||
{
|
{
|
||||||
|
delete[] m_bytes;
|
||||||
delete[] m_fich;
|
delete[] m_fich;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,6 +76,9 @@ bool CYSFFICH::decode(const unsigned char* bytes)
|
||||||
// Skip the sync bytes
|
// Skip the sync bytes
|
||||||
bytes += YSF_SYNC_LENGTH_BYTES;
|
bytes += YSF_SYNC_LENGTH_BYTES;
|
||||||
|
|
||||||
|
// Save a copy of the FICH for later error rate calculations
|
||||||
|
::memcpy(m_bytes, bytes, YSF_FICH_LENGTH_BYTES);
|
||||||
|
|
||||||
CYSFConvolution viterbi;
|
CYSFConvolution viterbi;
|
||||||
viterbi.start();
|
viterbi.start();
|
||||||
|
|
||||||
|
@ -157,6 +164,16 @@ void CYSFFICH::encode(unsigned char* bytes)
|
||||||
n++;
|
n++;
|
||||||
WRITE_BIT1(bytes, n, s1);
|
WRITE_BIT1(bytes, n, s1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Calculate the errors
|
||||||
|
m_errors = 0U;
|
||||||
|
for (unsigned int i = 0U; i < YSF_FICH_LENGTH_BYTES; i++) {
|
||||||
|
unsigned char v = bytes[i] ^ m_bytes[i];
|
||||||
|
while (v != 0U) {
|
||||||
|
v &= v - 1U;
|
||||||
|
m_errors++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char CYSFFICH::getFI() const
|
unsigned char CYSFFICH::getFI() const
|
||||||
|
@ -203,3 +220,8 @@ void CYSFFICH::setVoIP(bool on)
|
||||||
else
|
else
|
||||||
m_fich[2U] &= 0xFBU;
|
m_fich[2U] &= 0xFBU;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int CYSFFICH::getErrors() const
|
||||||
|
{
|
||||||
|
return m_errors;
|
||||||
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@ public:
|
||||||
|
|
||||||
void encode(unsigned char* bytes);
|
void encode(unsigned char* bytes);
|
||||||
|
|
||||||
|
unsigned int getErrors() const;
|
||||||
|
|
||||||
unsigned char getFI() const;
|
unsigned char getFI() const;
|
||||||
unsigned char getCM() const;
|
unsigned char getCM() const;
|
||||||
unsigned char getFN() const;
|
unsigned char getFN() const;
|
||||||
|
@ -39,7 +41,9 @@ public:
|
||||||
void setVoIP(bool set);
|
void setVoIP(bool set);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
unsigned char* m_bytes;
|
||||||
unsigned char* m_fich;
|
unsigned char* m_fich;
|
||||||
|
unsigned int m_errors;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -96,7 +96,7 @@ void CYSFPayload::process(unsigned char* bytes, unsigned char fi, unsigned char
|
||||||
assert(bytes != NULL);
|
assert(bytes != NULL);
|
||||||
|
|
||||||
// Header and trailer
|
// Header and trailer
|
||||||
if (fi == 0U || fi == 2U) {
|
if (fi == YSF_FI_HEADER || fi == YSF_FI_TERMINATOR) {
|
||||||
processHeader(bytes + YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES);
|
processHeader(bytes + YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -248,7 +248,7 @@ void CYSFPayload::processVDMode1(unsigned char* data, unsigned char fn)
|
||||||
errors += m_fec.regenerateDMR(data + 63U);
|
errors += m_fec.regenerateDMR(data + 63U);
|
||||||
errors += m_fec.regenerateDMR(data + 81U);
|
errors += m_fec.regenerateDMR(data + 81U);
|
||||||
|
|
||||||
LogMessage("YSF, V/D Mode 1, AMBE FEC %u/235 (%.1f%%)", errors, float(errors) / 235.0F);
|
LogMessage("YSF, V/D Mode 1, AMBE FEC %u/235 (%.1f%%)", errors, float(errors) / 2.35F);
|
||||||
|
|
||||||
unsigned char dch[45U];
|
unsigned char dch[45U];
|
||||||
|
|
||||||
|
@ -640,7 +640,7 @@ void CYSFPayload::processVoiceFRMode(unsigned char* data)
|
||||||
errors += m_fec.regenerateYSF3(data + 54U);
|
errors += m_fec.regenerateYSF3(data + 54U);
|
||||||
errors += m_fec.regenerateYSF3(data + 72U);
|
errors += m_fec.regenerateYSF3(data + 72U);
|
||||||
|
|
||||||
LogMessage("YSF, V Mode 3, AMBE FEC %u/720 (%.1f%%)", errors, float(errors) / 720.0F);
|
LogMessage("YSF, V Mode 3, AMBE FEC %u/720 (%.1f%%)", errors, float(errors) / 7.2F);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CYSFPayload::setUplink(const std::string& callsign)
|
void CYSFPayload::setUplink(const std::string& callsign)
|
||||||
|
|
Loading…
Reference in a new issue