Small cleanups of the DMR trunking code.

This commit is contained in:
Jonathan Naylor 2026-04-24 16:54:23 +01:00
parent 841d7505c2
commit 57e692ad8c
3 changed files with 24 additions and 25 deletions

View File

@ -225,8 +225,10 @@ uint8_t CDMRTX::writeAloha(const uint8_t* data, uint16_t length)
{ {
if (length != DMR_FRAME_LENGTH_BYTES) if (length != DMR_FRAME_LENGTH_BYTES)
return 4U; return 4U;
::memcpy(m_aloha, data, length); ::memcpy(m_aloha, data, length);
m_controlChannel = true; m_controlChannel = true;
return 0U; return 0U;
} }
@ -313,7 +315,7 @@ uint8_t CDMRTX::getSpace2() const
void CDMRTX::createData(uint8_t slotIndex) void CDMRTX::createData(uint8_t slotIndex)
{ {
if (m_fifo[slotIndex].getData() >= DMR_FRAME_LENGTH_BYTES && m_frameCount >= STARTUP_COUNT && m_abortCount[slotIndex] >= ABORT_COUNT) { if ((m_fifo[slotIndex].getData() >= DMR_FRAME_LENGTH_BYTES) && (m_frameCount >= STARTUP_COUNT) && (m_abortCount[slotIndex] >= ABORT_COUNT)) {
for (unsigned int i = 0U; i < DMR_FRAME_LENGTH_BYTES; i++) { for (unsigned int i = 0U; i < DMR_FRAME_LENGTH_BYTES; i++) {
m_fifo[slotIndex].get(m_poBuffer[i]); m_fifo[slotIndex].get(m_poBuffer[i]);
m_markBuffer[i] = MARK_NONE; m_markBuffer[i] = MARK_NONE;
@ -322,12 +324,11 @@ void CDMRTX::createData(uint8_t slotIndex)
m_abort[slotIndex] = false; m_abort[slotIndex] = false;
// Transmit an idle message // Transmit an idle message
for (unsigned int i = 0U; i < DMR_FRAME_LENGTH_BYTES; i++) { for (unsigned int i = 0U; i < DMR_FRAME_LENGTH_BYTES; i++) {
if(slotIndex == 0 && m_controlChannel && m_trunking) { if ((slotIndex == 0U) && m_controlChannel && m_trunking)
m_poBuffer[i] = m_aloha[i]; m_poBuffer[i] = m_aloha[i];
} else
else {
m_poBuffer[i] = m_idle[i]; m_poBuffer[i] = m_idle[i];
}
m_markBuffer[i] = MARK_NONE; m_markBuffer[i] = MARK_NONE;
} }
} }
@ -378,10 +379,12 @@ void CDMRTX::createCACH(uint8_t txSlotIndex, uint8_t rxSlotIndex)
m_cachPtr = 0U; m_cachPtr = 0U;
if (m_cachPtr == 0U) { if (m_cachPtr == 0U) {
if (m_fifo[0U].getData() == 0U && m_fifo[1U].getData() == 0U) { if ((m_fifo[0U].getData() == 0U) && (m_fifo[1U].getData() == 0U)) {
if(!m_trunking) if (m_trunking)
::memcpy(m_shortLC, EMPTY_SHORT_LC, 12U); ::memcpy(m_shortLC, m_newShortLC, 12U);
else else
::memcpy(m_shortLC, EMPTY_SHORT_LC, 12U);
} else {
::memcpy(m_shortLC, m_newShortLC, 12U); ::memcpy(m_shortLC, m_newShortLC, 12U);
} }
} }
@ -393,8 +396,8 @@ void CDMRTX::createCACH(uint8_t txSlotIndex, uint8_t rxSlotIndex)
bool at = false; bool at = false;
if (m_frameCount >= STARTUP_COUNT) if (m_frameCount >= STARTUP_COUNT)
at = m_fifo[rxSlotIndex].getData() > 0U; at = (m_fifo[rxSlotIndex].getData() > 0U);
bool tc = txSlotIndex == 1U; bool tc = (txSlotIndex == 1U);
bool ls0 = true; // For 1 and 2 bool ls0 = true; // For 1 and 2
bool ls1 = true; bool ls1 = true;
@ -432,8 +435,7 @@ void CDMRTX::setColorCode(uint8_t colorCode)
if (m_trunking) { if (m_trunking) {
slotType.encode(colorCode, DT_TERMINATOR_WITH_LC, m_idle); slotType.encode(colorCode, DT_TERMINATOR_WITH_LC, m_idle);
slotType.encode(colorCode, DT_CSBK, m_aloha); slotType.encode(colorCode, DT_CSBK, m_aloha);
} } else {
else {
slotType.encode(colorCode, DT_IDLE, m_idle); slotType.encode(colorCode, DT_IDLE, m_idle);
} }
} }
@ -458,6 +460,4 @@ void CDMRTX::setTrunking(bool trunking)
m_trunking = trunking; m_trunking = trunking;
} }
#endif #endif

View File

@ -93,4 +93,3 @@ private:
#endif #endif
#endif #endif

View File

@ -19,6 +19,6 @@
#if !defined(VERSION_H) #if !defined(VERSION_H)
#define VERSION_H #define VERSION_H
#define VERSION "20260219" #define VERSION "20260424"
#endif #endif