Skip to content

Commit

Permalink
Fixes for more reliable P25 decode at the start of calls (#8)
Browse files Browse the repository at this point in the history
* DO NOT USE THIS BRANCH; remove sync position settings from processSample(); use calculateLevels for the NID;

* whoops put back NID decode dumping;

* don't calculateLevels for the NID (it breaks TSDUs, but doesn't seem to impact HDU decoding??);

* correlateSync() after handling HDU and set state to P25RXS_VOICE;

* Revert: correlateSync() after handling HDU and set state to P25RXS_VOICE;

* added state machine debug and removed HDU state reset()

---------

Co-authored-by: Bryan Biedenkapp <gatekeep@gmail.com>
Co-authored-by: axel <axel@deb.trac>
  • Loading branch information
3 people committed Jul 31, 2024
1 parent 5623f5c commit a5b0952
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions p25/P25RX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ void P25RX::reset()
m_lostCount = 0U;
m_countdown = 0U;

DEBUG1("P25RX::samples() m_state = P25RXS_NONE");
m_state = P25RXS_NONE;

m_duid = 0xFFU;
Expand Down Expand Up @@ -152,6 +153,7 @@ void P25RX::samples(const q15_t* samples, uint16_t* rssi, uint8_t length)
DEBUG4("P25RX::samples() dataPtr/startPtr/endPtr", m_dataPtr, m_startPtr, m_endPtr);
DEBUG4("P25RX::samples() lostCount/maxSyncPtr/minSyncPtr", m_lostCount, m_maxSyncPtr, m_minSyncPtr);

DEBUG1("P25RX::samples() m_state = P25RXS_SYNC");
m_state = P25RXS_SYNC;
m_countdown = 0U;
}
Expand Down Expand Up @@ -198,21 +200,14 @@ void P25RX::setCorrCount(uint8_t count)

void P25RX::processSample(q15_t sample)
{
if (m_minSyncPtr < m_maxSyncPtr) {
if (m_dataPtr >= m_minSyncPtr && m_dataPtr <= m_maxSyncPtr)
correlateSync();
}
else {
if (m_dataPtr >= m_minSyncPtr || m_dataPtr <= m_maxSyncPtr)
correlateSync();
}

// initial sample processing does not have an end pointer -- we simply wait till we've read
// the samples up to the maximum sync pointer
if (m_dataPtr == m_maxSyncPtr) {
DEBUG4("P25RX::processSample() dataPtr/startPtr/endPtr", m_dataPtr, m_startPtr, m_maxSyncPtr);
DEBUG4("P25RX::processSample() lostCount/maxSyncPtr/minSyncPtr", m_lostCount, m_maxSyncPtr, m_minSyncPtr);

// calculateLevels(m_startPtr, P25_NID_LENGTH_SYMBOLS);

if (!decodeNid(m_startPtr)) {
io.setDecode(false);
io.setADCDetection(false);
Expand All @@ -233,7 +228,7 @@ void P25RX::processSample(q15_t sample)

frame[0U] = 0x01U; // has sync
serial.writeP25Data(frame, P25_HDU_FRAME_LENGTH_BYTES + 1U);
reset();
//reset();
}
return;
case P25_DUID_TDU:
Expand All @@ -252,6 +247,7 @@ void P25RX::processSample(q15_t sample)
return;
case P25_DUID_LDU1:
case P25_DUID_VSELP1:
DEBUG1("P25RX::samples() m_state = P25RXS_VOICE");
m_state = P25RXS_VOICE;
break;
case P25_DUID_TSDU:
Expand All @@ -270,9 +266,11 @@ void P25RX::processSample(q15_t sample)
return;
case P25_DUID_LDU2:
case P25_DUID_VSELP2:
DEBUG1("P25RX::samples() m_state = P25RXS_VOICE");
m_state = P25RXS_VOICE;
break;
case P25_DUID_PDU:
DEBUG1("P25RX::samples() m_state = P25RXS_DATA");
m_state = P25RXS_DATA;
break;
case P25_DUID_TDULC:
Expand Down Expand Up @@ -598,6 +596,8 @@ bool P25RX::decodeNid(uint16_t start)
uint8_t nid[P25_NID_LENGTH_BYTES];
samplesToBits(nidStartPtr, P25_NID_LENGTH_SYMBOLS, nid, 0U, m_centreVal, m_thresholdVal);

DEBUG3("P25RX::decodeNid() sync [b0 - b1]", nid[0], nid[1]);

if (m_nac == 0xF7EU) {
m_duid = nid[1U] & 0x0FU;
DEBUG2("P25RX::decodeNid() DUID for xDU", m_duid);
Expand Down

0 comments on commit a5b0952

Please sign in to comment.