Skip to content

Commit

Permalink
Add extra debughing of the output queues.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed Mar 7, 2016
1 parent 7e31a22 commit bfb74d3
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 28 deletions.
34 changes: 24 additions & 10 deletions DMRSlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ bool CDMRSlot::m_voice2 = true;

CDMRSlot::CDMRSlot(unsigned int slotNo, unsigned int timeout) :
m_slotNo(slotNo),
m_rfQueue(1000U, "DMR Slot"),
m_queue(1000U, "DMR Slot"),
m_rfState(RS_RF_LISTENING),
m_netState(RS_NET_IDLE),
m_rfEmbeddedLC(),
Expand Down Expand Up @@ -502,13 +502,13 @@ void CDMRSlot::writeModem(unsigned char *data)

unsigned int CDMRSlot::readModem(unsigned char* data)
{
if (m_rfQueue.isEmpty())
if (m_queue.isEmpty())
return 0U;

unsigned char len = 0U;
m_rfQueue.getData(&len, 1U);
m_queue.getData(&len, 1U);

m_rfQueue.getData(data, len);
m_queue.getData(data, len);

return len;
}
Expand Down Expand Up @@ -1059,13 +1059,20 @@ void CDMRSlot::writeQueueRF(const unsigned char *data)
return;

unsigned char len = DMR_FRAME_LENGTH_BYTES + 2U;
m_rfQueue.addData(&len, 1U);

unsigned int space = m_queue.freeSpace();
if (space < (len + 1U)) {
LogError("DMR Slot %u, overflow in the DMR slot RF queue", m_slotNo);
return;
}

m_queue.addData(&len, 1U);

// If the timeout has expired, replace the audio with idles to keep the slot busy
if (m_rfTimeoutTimer.isRunning() && m_rfTimeoutTimer.hasExpired())
m_rfQueue.addData(m_idle, len);
m_queue.addData(m_idle, len);
else
m_rfQueue.addData(data, len);
m_queue.addData(data, len);
}

void CDMRSlot::writeNetworkRF(const unsigned char* data, unsigned char dataType, FLCO flco, unsigned int srcId, unsigned int dstId)
Expand Down Expand Up @@ -1109,13 +1116,20 @@ void CDMRSlot::writeNetworkRF(const unsigned char* data, unsigned char dataType)
void CDMRSlot::writeQueueNet(const unsigned char *data)
{
unsigned char len = DMR_FRAME_LENGTH_BYTES + 2U;
m_rfQueue.addData(&len, 1U);

unsigned int space = m_queue.freeSpace();
if (space < (len + 1U)) {
LogError("DMR Slot %u, overflow in the DMR slot RF queue", m_slotNo);
return;
}

m_queue.addData(&len, 1U);

// If the timeout has expired, replace the audio with idles to keep the slot busy
if (m_netTimeoutTimer.isRunning() && m_netTimeoutTimer.hasExpired())
m_rfQueue.addData(m_idle, len);
m_queue.addData(m_idle, len);
else
m_rfQueue.addData(data, len);
m_queue.addData(data, len);
}

void CDMRSlot::init(unsigned int colorCode, CModem* modem, CDMRIPSC* network, IDisplay* display, bool duplex)
Expand Down
2 changes: 1 addition & 1 deletion DMRSlot.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class CDMRSlot {

private:
unsigned int m_slotNo;
CRingBuffer<unsigned char> m_rfQueue;
CRingBuffer<unsigned char> m_queue;
RPT_RF_STATE m_rfState;
RPT_NET_STATE m_netState;
CDMREmbeddedLC m_rfEmbeddedLC;
Expand Down
74 changes: 58 additions & 16 deletions DStarControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ m_gateway(NULL),
m_network(network),
m_display(display),
m_duplex(duplex),
m_rfQueue(1000U, "D-Star Control"),
m_queue(1000U, "D-Star Control"),
m_rfHeader(),
m_netHeader(),
m_rfState(RS_RF_LISTENING),
Expand Down Expand Up @@ -343,17 +343,17 @@ bool CDStarControl::writeModem(unsigned char *data)

unsigned int CDStarControl::readModem(unsigned char* data)
{
if (m_rfQueue.isEmpty())
if (m_queue.isEmpty())
return 0U;

// Don't relay data until the timer has stopped.
if (m_holdoffTimer.isRunning())
return 0U;

unsigned char len = 0U;
m_rfQueue.getData(&len, 1U);
m_queue.getData(&len, 1U);

m_rfQueue.getData(data, len);
m_queue.getData(data, len);

return len;
}
Expand Down Expand Up @@ -565,9 +565,16 @@ void CDStarControl::writeQueueHeaderRF(const unsigned char *data)
return;

unsigned char len = DSTAR_HEADER_LENGTH_BYTES + 1U;
m_rfQueue.addData(&len, 1U);

m_rfQueue.addData(data, len);
unsigned int space = m_queue.freeSpace();
if (space < (len + 1U)) {
LogError("D-Star, overflow in the D-Star RF queue");
return;
}

m_queue.addData(&len, 1U);

m_queue.addData(data, len);
}

void CDStarControl::writeQueueDataRF(const unsigned char *data)
Expand All @@ -581,9 +588,16 @@ void CDStarControl::writeQueueDataRF(const unsigned char *data)
return;

unsigned char len = DSTAR_FRAME_LENGTH_BYTES + 1U;
m_rfQueue.addData(&len, 1U);

m_rfQueue.addData(data, len);
unsigned int space = m_queue.freeSpace();
if (space < (len + 1U)) {
LogError("D-Star, overflow in the D-Star RF queue");
return;
}

m_queue.addData(&len, 1U);

m_queue.addData(data, len);
}

void CDStarControl::writeQueueEOTRF()
Expand All @@ -595,10 +609,17 @@ void CDStarControl::writeQueueEOTRF()
return;

unsigned char len = 1U;
m_rfQueue.addData(&len, 1U);

unsigned int space = m_queue.freeSpace();
if (space < (len + 1U)) {
LogError("D-Star, overflow in the D-Star RF queue");
return;
}

m_queue.addData(&len, 1U);

unsigned char data = TAG_EOT;
m_rfQueue.addData(&data, len);
m_queue.addData(&data, len);
}

void CDStarControl::writeQueueHeaderNet(const unsigned char *data)
Expand All @@ -609,9 +630,16 @@ void CDStarControl::writeQueueHeaderNet(const unsigned char *data)
return;

unsigned char len = DSTAR_HEADER_LENGTH_BYTES + 1U;
m_rfQueue.addData(&len, 1U);

m_rfQueue.addData(data, len);
unsigned int space = m_queue.freeSpace();
if (space < (len + 1U)) {
LogError("D-Star, overflow in the D-Star RF queue");
return;
}

m_queue.addData(&len, 1U);

m_queue.addData(data, len);
}

void CDStarControl::writeQueueDataNet(const unsigned char *data)
Expand All @@ -622,9 +650,16 @@ void CDStarControl::writeQueueDataNet(const unsigned char *data)
return;

unsigned char len = DSTAR_FRAME_LENGTH_BYTES + 1U;
m_rfQueue.addData(&len, 1U);

m_rfQueue.addData(data, len);
unsigned int space = m_queue.freeSpace();
if (space < (len + 1U)) {
LogError("D-Star, overflow in the D-Star RF queue");
return;
}

m_queue.addData(&len, 1U);

m_queue.addData(data, len);
}

void CDStarControl::writeQueueEOTNet()
Expand All @@ -633,10 +668,17 @@ void CDStarControl::writeQueueEOTNet()
return;

unsigned char len = 1U;
m_rfQueue.addData(&len, 1U);

unsigned int space = m_queue.freeSpace();
if (space < (len + 1U)) {
LogError("D-Star, overflow in the D-Star RF queue");
return;
}

m_queue.addData(&len, 1U);

unsigned char data = TAG_EOT;
m_rfQueue.addData(&data, len);
m_queue.addData(&data, len);
}

void CDStarControl::writeNetworkHeaderRF(const unsigned char* data)
Expand Down
2 changes: 1 addition & 1 deletion DStarControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class CDStarControl {
CDStarNetwork* m_network;
IDisplay* m_display;
bool m_duplex;
CRingBuffer<unsigned char> m_rfQueue;
CRingBuffer<unsigned char> m_queue;
CDStarHeader m_rfHeader;
CDStarHeader m_netHeader;
RPT_RF_STATE m_rfState;
Expand Down
7 changes: 7 additions & 0 deletions YSFControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,13 @@ void CYSFControl::writeQueue(const unsigned char *data)
return;

unsigned char len = YSF_FRAME_LENGTH_BYTES + 2U;

unsigned int space = m_queue.freeSpace();
if (space < (len + 1U)) {
LogError("YSF, overflow in the System Fusion RF queue");
return;
}

m_queue.addData(&len, 1U);

m_queue.addData(data, len);
Expand Down

0 comments on commit bfb74d3

Please sign in to comment.