Skip to content

Commit

Permalink
Improve timing within the protocol engines.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed Mar 14, 2016
1 parent 1d4443e commit 2cfb1f4
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 14 deletions.
6 changes: 3 additions & 3 deletions DMRControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ unsigned int CDMRControl::readModemSlot2(unsigned char *data)
return m_slot2.readModem(data);
}

void CDMRControl::clock(unsigned int ms)
void CDMRControl::clock()
{
if (m_network != NULL) {
CDMRData data;
Expand All @@ -109,6 +109,6 @@ void CDMRControl::clock(unsigned int ms)
}
}

m_slot1.clock(ms);
m_slot2.clock(ms);
m_slot1.clock();
m_slot2.clock();
}
2 changes: 1 addition & 1 deletion DMRControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CDMRControl {
unsigned int readModemSlot1(unsigned char* data);
unsigned int readModemSlot2(unsigned char* data);

void clock(unsigned int ms);
void clock();

private:
unsigned int m_id;
Expand Down
8 changes: 7 additions & 1 deletion DMRSlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ m_networkWatchdog(1000U, 0U, 1500U),
m_rfTimeoutTimer(1000U, timeout),
m_netTimeoutTimer(1000U, timeout),
m_packetTimer(1000U, 0U, 300U),
m_interval(),
m_elapsed(),
m_rfFrames(0U),
m_netFrames(0U),
Expand All @@ -76,6 +77,8 @@ m_lastEMB(),
m_fp(NULL)
{
m_lastFrame = new unsigned char[DMR_FRAME_LENGTH_BYTES + 2U];

m_interval.start();
}

CDMRSlot::~CDMRSlot()
Expand Down Expand Up @@ -1038,8 +1041,11 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
}
}

void CDMRSlot::clock(unsigned int ms)
void CDMRSlot::clock()
{
unsigned int ms = m_interval.elapsed();
m_interval.start();

m_rfTimeoutTimer.clock(ms);
m_netTimeoutTimer.clock(ms);

Expand Down
3 changes: 2 additions & 1 deletion DMRSlot.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class CDMRSlot {

void writeNetwork(const CDMRData& data);

void clock(unsigned int ms);
void clock();

static void init(unsigned int colorCode, CModem* modem, CDMRIPSC* network, IDisplay* display, bool duplex);

Expand All @@ -68,6 +68,7 @@ class CDMRSlot {
CTimer m_rfTimeoutTimer;
CTimer m_netTimeoutTimer;
CTimer m_packetTimer;
CStopWatch m_interval;
CStopWatch m_elapsed;
unsigned int m_rfFrames;
unsigned int m_netFrames;
Expand Down
8 changes: 7 additions & 1 deletion DStarControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ m_rfTimeoutTimer(1000U, timeout),
m_netTimeoutTimer(1000U, timeout),
m_packetTimer(1000U, 0U, 200U),
m_ackTimer(1000U, 0U, 750U),
m_interval(),
m_elapsed(),
m_rfFrames(0U),
m_netFrames(0U),
Expand Down Expand Up @@ -78,6 +79,8 @@ m_fp(NULL)
m_callsign[i] = call.at(i);
m_gateway[i] = gate.at(i);
}

m_interval.start();
}

CDStarControl::~CDStarControl()
Expand Down Expand Up @@ -506,8 +509,11 @@ void CDStarControl::writeNetwork()
}
}

void CDStarControl::clock(unsigned int ms)
void CDStarControl::clock()
{
unsigned int ms = m_interval.elapsed();
m_interval.start();

if (m_network != NULL)
writeNetwork();

Expand Down
5 changes: 3 additions & 2 deletions DStarControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
#include "DStarSlowData.h"
#include "DStarDefines.h"
#include "DStarHeader.h"
#include "StopWatch.h"
#include "RingBuffer.h"
#include "StopWatch.h"
#include "AMBEFEC.h"
#include "Display.h"
#include "Defines.h"
Expand All @@ -42,7 +42,7 @@ class CDStarControl {

unsigned int readModem(unsigned char* data);

void clock(unsigned int ms);
void clock();

private:
unsigned char* m_callsign;
Expand All @@ -65,6 +65,7 @@ class CDStarControl {
CTimer m_netTimeoutTimer;
CTimer m_packetTimer;
CTimer m_ackTimer;
CStopWatch m_interval;
CStopWatch m_elapsed;
unsigned int m_rfFrames;
unsigned int m_netFrames;
Expand Down
6 changes: 3 additions & 3 deletions MMDVMHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,11 @@ int CMMDVMHost::run()
m_modeTimer.clock(ms);

if (dstar != NULL)
dstar->clock(ms);
dstar->clock();
if (dmr != NULL)
dmr->clock(ms);
dmr->clock();
if (ysf != NULL)
ysf->clock(ms);
ysf->clock();

if (m_dstarNetwork != NULL)
m_dstarNetwork->clock(ms);
Expand Down
8 changes: 7 additions & 1 deletion YSFControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ m_duplex(duplex),
m_queue(1000U, "YSF Control"),
m_state(RS_RF_LISTENING),
m_timeoutTimer(1000U, timeout),
m_interval(),
m_frames(0U),
m_fich(),
m_source(NULL),
Expand All @@ -50,6 +51,8 @@ m_fp(NULL)

m_payload.setUplink(callsign);
m_payload.setDownlink(callsign);

m_interval.start();
}

CYSFControl::~CYSFControl()
Expand Down Expand Up @@ -250,8 +253,11 @@ void CYSFControl::writeEndOfTransmission()
#endif
}

void CYSFControl::clock(unsigned int ms)
void CYSFControl::clock()
{
unsigned int ms = m_interval.elapsed();
m_interval.start();

m_timeoutTimer.clock(ms);

if (m_parrot != NULL) {
Expand Down
4 changes: 3 additions & 1 deletion YSFControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "YSFDefines.h"
#include "YSFPayload.h"
#include "RingBuffer.h"
#include "StopWatch.h"
#include "YSFParrot.h"
#include "Display.h"
#include "Defines.h"
Expand All @@ -40,14 +41,15 @@ class CYSFControl {

unsigned int readModem(unsigned char* data);

void clock(unsigned int ms);
void clock();

private:
IDisplay* m_display;
bool m_duplex;
CRingBuffer<unsigned char> m_queue;
RPT_RF_STATE m_state;
CTimer m_timeoutTimer;
CStopWatch m_interval;
unsigned int m_frames;
CYSFFICH m_fich;
unsigned char* m_source;
Expand Down

0 comments on commit 2cfb1f4

Please sign in to comment.