mirror of https://github.com/g4klx/MMDVM.git
Add enhancements suggested by IZ1MLT.
This commit is contained in:
parent
669acb99e8
commit
04ca97e5f8
32
DStarRX.cpp
32
DStarRX.cpp
|
@ -28,11 +28,7 @@ const uint32_t PLLMAX = 0x10000U;
|
|||
const uint32_t PLLINC = PLLMAX / DSTAR_RADIO_BIT_LENGTH;
|
||||
const uint32_t INC = PLLINC / 32U;
|
||||
|
||||
const unsigned int MAX_SYNC_BITS = 50U * DSTAR_DATA_LENGTH_BITS;
|
||||
|
||||
const unsigned int SYNC_POS = 21U * DSTAR_DATA_LENGTH_BITS;
|
||||
const unsigned int SYNC_SCAN_START = SYNC_POS - 3U;
|
||||
const unsigned int SYNC_SCAN_END = SYNC_POS + 3U;
|
||||
const unsigned int MAX_SYNC_BITS = 100U * DSTAR_DATA_LENGTH_BITS;
|
||||
|
||||
// D-Star bit order version of 0x55 0x55 0x6E 0x0A
|
||||
const uint32_t FRAME_SYNC_DATA = 0x00557650U;
|
||||
|
@ -372,7 +368,7 @@ void CDStarRX::processNone(bool bit)
|
|||
::memset(m_rxBuffer, 0x00U, DSTAR_DATA_LENGTH_BYTES + 2U);
|
||||
m_rxBufferBits = 0U;
|
||||
|
||||
m_dataBits = 0U;
|
||||
m_dataBits = MAX_SYNC_BITS;
|
||||
m_rxState = DSRXS_DATA;
|
||||
return;
|
||||
}
|
||||
|
@ -401,8 +397,8 @@ void CDStarRX::processHeader(bool bit)
|
|||
::memset(m_rxBuffer, 0x00U, DSTAR_DATA_LENGTH_BYTES + 2U);
|
||||
m_rxBufferBits = 0U;
|
||||
|
||||
m_rxState = DSRXS_DATA;
|
||||
m_dataBits = SYNC_POS - DSTAR_DATA_LENGTH_BITS + 1U;
|
||||
m_rxState = DSRXS_DATA;
|
||||
m_dataBits = MAX_SYNC_BITS;
|
||||
} else {
|
||||
// The checksum failed, return to looking for syncs
|
||||
m_rxState = DSRXS_NONE;
|
||||
|
@ -434,37 +430,29 @@ void CDStarRX::processData(bool bit)
|
|||
|
||||
// Fuzzy matching of the data sync bit sequence
|
||||
bool syncSeen = false;
|
||||
if (m_dataBits >= SYNC_SCAN_START && m_dataBits <= (SYNC_POS + 1U)) {
|
||||
if (m_rxBufferBits >= (DSTAR_DATA_LENGTH_BITS - 3U)) {
|
||||
if (countBits32((m_patternBuffer & DATA_SYNC_MASK) ^ DATA_SYNC_DATA) <= DATA_SYNC_ERRS) {
|
||||
if (m_dataBits < SYNC_POS)
|
||||
DEBUG2("DStarRX: found data sync in Data, early", SYNC_POS - m_dataBits);
|
||||
else
|
||||
DEBUG1("DStarRX: found data sync in Data");
|
||||
|
||||
m_rxBufferBits = DSTAR_DATA_LENGTH_BITS;
|
||||
m_dataBits = 0U;
|
||||
syncSeen = true;
|
||||
m_dataBits = MAX_SYNC_BITS;
|
||||
syncSeen = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check to see if the sync is arriving late
|
||||
if (m_dataBits == SYNC_POS) {
|
||||
if (m_rxBufferBits == DSTAR_DATA_LENGTH_BITS && !syncSeen) {
|
||||
for (uint8_t i = 1U; i <= 3U; i++) {
|
||||
uint32_t syncMask = DATA_SYNC_MASK >> i;
|
||||
uint32_t syncData = DATA_SYNC_DATA >> i;
|
||||
if (countBits32((m_patternBuffer & syncMask) ^ syncData) <= DATA_SYNC_ERRS) {
|
||||
DEBUG2("DStarRX: found data sync in Data, late", i);
|
||||
m_rxBufferBits -= i;
|
||||
m_dataBits -= i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_dataBits++;
|
||||
m_dataBits--;
|
||||
|
||||
// We've not seen a data sync for too long, signal RXLOST and change to RX_NONE
|
||||
if (m_dataBits >= MAX_SYNC_BITS) {
|
||||
if (m_dataBits == 0U) {
|
||||
DEBUG1("DStarRX: data sync timed out, lost lock");
|
||||
|
||||
io.setDecode(false);
|
||||
|
|
Loading…
Reference in New Issue