Improve timing within the protocol engines.

This commit is contained in:
Jonathan Naylor
2016-03-14 20:55:15 +00:00
parent 1d4443eafd
commit 2cfb1f458e
9 changed files with 36 additions and 14 deletions

View File

@@ -94,7 +94,7 @@ unsigned int CDMRControl::readModemSlot2(unsigned char *data)
return m_slot2.readModem(data); return m_slot2.readModem(data);
} }
void CDMRControl::clock(unsigned int ms) void CDMRControl::clock()
{ {
if (m_network != NULL) { if (m_network != NULL) {
CDMRData data; CDMRData data;
@@ -109,6 +109,6 @@ void CDMRControl::clock(unsigned int ms)
} }
} }
m_slot1.clock(ms); m_slot1.clock();
m_slot2.clock(ms); m_slot2.clock();
} }

View File

@@ -39,7 +39,7 @@ public:
unsigned int readModemSlot1(unsigned char* data); unsigned int readModemSlot1(unsigned char* data);
unsigned int readModemSlot2(unsigned char* data); unsigned int readModemSlot2(unsigned char* data);
void clock(unsigned int ms); void clock();
private: private:
unsigned int m_id; unsigned int m_id;

View File

@@ -62,6 +62,7 @@ m_networkWatchdog(1000U, 0U, 1500U),
m_rfTimeoutTimer(1000U, timeout), m_rfTimeoutTimer(1000U, timeout),
m_netTimeoutTimer(1000U, timeout), m_netTimeoutTimer(1000U, timeout),
m_packetTimer(1000U, 0U, 300U), m_packetTimer(1000U, 0U, 300U),
m_interval(),
m_elapsed(), m_elapsed(),
m_rfFrames(0U), m_rfFrames(0U),
m_netFrames(0U), m_netFrames(0U),
@@ -76,6 +77,8 @@ m_lastEMB(),
m_fp(NULL) m_fp(NULL)
{ {
m_lastFrame = new unsigned char[DMR_FRAME_LENGTH_BYTES + 2U]; m_lastFrame = new unsigned char[DMR_FRAME_LENGTH_BYTES + 2U];
m_interval.start();
} }
CDMRSlot::~CDMRSlot() CDMRSlot::~CDMRSlot()
@@ -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_rfTimeoutTimer.clock(ms);
m_netTimeoutTimer.clock(ms); m_netTimeoutTimer.clock(ms);

View File

@@ -45,7 +45,7 @@ public:
void writeNetwork(const CDMRData& data); 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); static void init(unsigned int colorCode, CModem* modem, CDMRIPSC* network, IDisplay* display, bool duplex);
@@ -68,6 +68,7 @@ private:
CTimer m_rfTimeoutTimer; CTimer m_rfTimeoutTimer;
CTimer m_netTimeoutTimer; CTimer m_netTimeoutTimer;
CTimer m_packetTimer; CTimer m_packetTimer;
CStopWatch m_interval;
CStopWatch m_elapsed; CStopWatch m_elapsed;
unsigned int m_rfFrames; unsigned int m_rfFrames;
unsigned int m_netFrames; unsigned int m_netFrames;

View File

@@ -45,6 +45,7 @@ m_rfTimeoutTimer(1000U, timeout),
m_netTimeoutTimer(1000U, timeout), m_netTimeoutTimer(1000U, timeout),
m_packetTimer(1000U, 0U, 200U), m_packetTimer(1000U, 0U, 200U),
m_ackTimer(1000U, 0U, 750U), m_ackTimer(1000U, 0U, 750U),
m_interval(),
m_elapsed(), m_elapsed(),
m_rfFrames(0U), m_rfFrames(0U),
m_netFrames(0U), m_netFrames(0U),
@@ -78,6 +79,8 @@ m_fp(NULL)
m_callsign[i] = call.at(i); m_callsign[i] = call.at(i);
m_gateway[i] = gate.at(i); m_gateway[i] = gate.at(i);
} }
m_interval.start();
} }
CDStarControl::~CDStarControl() CDStarControl::~CDStarControl()
@@ -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) if (m_network != NULL)
writeNetwork(); writeNetwork();

View File

@@ -23,8 +23,8 @@
#include "DStarSlowData.h" #include "DStarSlowData.h"
#include "DStarDefines.h" #include "DStarDefines.h"
#include "DStarHeader.h" #include "DStarHeader.h"
#include "StopWatch.h"
#include "RingBuffer.h" #include "RingBuffer.h"
#include "StopWatch.h"
#include "AMBEFEC.h" #include "AMBEFEC.h"
#include "Display.h" #include "Display.h"
#include "Defines.h" #include "Defines.h"
@@ -42,7 +42,7 @@ public:
unsigned int readModem(unsigned char* data); unsigned int readModem(unsigned char* data);
void clock(unsigned int ms); void clock();
private: private:
unsigned char* m_callsign; unsigned char* m_callsign;
@@ -65,6 +65,7 @@ private:
CTimer m_netTimeoutTimer; CTimer m_netTimeoutTimer;
CTimer m_packetTimer; CTimer m_packetTimer;
CTimer m_ackTimer; CTimer m_ackTimer;
CStopWatch m_interval;
CStopWatch m_elapsed; CStopWatch m_elapsed;
unsigned int m_rfFrames; unsigned int m_rfFrames;
unsigned int m_netFrames; unsigned int m_netFrames;

View File

@@ -348,11 +348,11 @@ int CMMDVMHost::run()
m_modeTimer.clock(ms); m_modeTimer.clock(ms);
if (dstar != NULL) if (dstar != NULL)
dstar->clock(ms); dstar->clock();
if (dmr != NULL) if (dmr != NULL)
dmr->clock(ms); dmr->clock();
if (ysf != NULL) if (ysf != NULL)
ysf->clock(ms); ysf->clock();
if (m_dstarNetwork != NULL) if (m_dstarNetwork != NULL)
m_dstarNetwork->clock(ms); m_dstarNetwork->clock(ms);

View File

@@ -35,6 +35,7 @@ m_duplex(duplex),
m_queue(1000U, "YSF Control"), m_queue(1000U, "YSF Control"),
m_state(RS_RF_LISTENING), m_state(RS_RF_LISTENING),
m_timeoutTimer(1000U, timeout), m_timeoutTimer(1000U, timeout),
m_interval(),
m_frames(0U), m_frames(0U),
m_fich(), m_fich(),
m_source(NULL), m_source(NULL),
@@ -50,6 +51,8 @@ m_fp(NULL)
m_payload.setUplink(callsign); m_payload.setUplink(callsign);
m_payload.setDownlink(callsign); m_payload.setDownlink(callsign);
m_interval.start();
} }
CYSFControl::~CYSFControl() CYSFControl::~CYSFControl()
@@ -250,8 +253,11 @@ void CYSFControl::writeEndOfTransmission()
#endif #endif
} }
void CYSFControl::clock(unsigned int ms) void CYSFControl::clock()
{ {
unsigned int ms = m_interval.elapsed();
m_interval.start();
m_timeoutTimer.clock(ms); m_timeoutTimer.clock(ms);
if (m_parrot != NULL) { if (m_parrot != NULL) {

View File

@@ -22,6 +22,7 @@
#include "YSFDefines.h" #include "YSFDefines.h"
#include "YSFPayload.h" #include "YSFPayload.h"
#include "RingBuffer.h" #include "RingBuffer.h"
#include "StopWatch.h"
#include "YSFParrot.h" #include "YSFParrot.h"
#include "Display.h" #include "Display.h"
#include "Defines.h" #include "Defines.h"
@@ -40,7 +41,7 @@ public:
unsigned int readModem(unsigned char* data); unsigned int readModem(unsigned char* data);
void clock(unsigned int ms); void clock();
private: private:
IDisplay* m_display; IDisplay* m_display;
@@ -48,6 +49,7 @@ private:
CRingBuffer<unsigned char> m_queue; CRingBuffer<unsigned char> m_queue;
RPT_RF_STATE m_state; RPT_RF_STATE m_state;
CTimer m_timeoutTimer; CTimer m_timeoutTimer;
CStopWatch m_interval;
unsigned int m_frames; unsigned int m_frames;
CYSFFICH m_fich; CYSFFICH m_fich;
unsigned char* m_source; unsigned char* m_source;