From 2cfb1f458ef89caf1484a0eab5f1e975f79f9734 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 14 Mar 2016 20:55:15 +0000 Subject: [PATCH] Improve timing within the protocol engines. --- DMRControl.cpp | 6 +++--- DMRControl.h | 2 +- DMRSlot.cpp | 8 +++++++- DMRSlot.h | 3 ++- DStarControl.cpp | 8 +++++++- DStarControl.h | 5 +++-- MMDVMHost.cpp | 6 +++--- YSFControl.cpp | 8 +++++++- YSFControl.h | 4 +++- 9 files changed, 36 insertions(+), 14 deletions(-) diff --git a/DMRControl.cpp b/DMRControl.cpp index 3e50b9c16..66077c9f7 100644 --- a/DMRControl.cpp +++ b/DMRControl.cpp @@ -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; @@ -109,6 +109,6 @@ void CDMRControl::clock(unsigned int ms) } } - m_slot1.clock(ms); - m_slot2.clock(ms); + m_slot1.clock(); + m_slot2.clock(); } diff --git a/DMRControl.h b/DMRControl.h index 4e0848563..4a94dbfd7 100644 --- a/DMRControl.h +++ b/DMRControl.h @@ -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; diff --git a/DMRSlot.cpp b/DMRSlot.cpp index 2daf62544..2a6fa34c3 100644 --- a/DMRSlot.cpp +++ b/DMRSlot.cpp @@ -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), @@ -76,6 +77,8 @@ m_lastEMB(), m_fp(NULL) { m_lastFrame = new unsigned char[DMR_FRAME_LENGTH_BYTES + 2U]; + + m_interval.start(); } 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_netTimeoutTimer.clock(ms); diff --git a/DMRSlot.h b/DMRSlot.h index 3edd08490..a12d14a36 100644 --- a/DMRSlot.h +++ b/DMRSlot.h @@ -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); @@ -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; diff --git a/DStarControl.cpp b/DStarControl.cpp index 9425810da..8a77f02c5 100644 --- a/DStarControl.cpp +++ b/DStarControl.cpp @@ -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), @@ -78,6 +79,8 @@ m_fp(NULL) m_callsign[i] = call.at(i); m_gateway[i] = gate.at(i); } + + m_interval.start(); } 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) writeNetwork(); diff --git a/DStarControl.h b/DStarControl.h index 8e5ee9316..90966d58c 100644 --- a/DStarControl.h +++ b/DStarControl.h @@ -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" @@ -42,7 +42,7 @@ class CDStarControl { unsigned int readModem(unsigned char* data); - void clock(unsigned int ms); + void clock(); private: unsigned char* m_callsign; @@ -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; diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index c271478fc..d0c720db4 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -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); diff --git a/YSFControl.cpp b/YSFControl.cpp index 9db55ad83..8f2697f0f 100644 --- a/YSFControl.cpp +++ b/YSFControl.cpp @@ -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), @@ -50,6 +51,8 @@ m_fp(NULL) m_payload.setUplink(callsign); m_payload.setDownlink(callsign); + + m_interval.start(); } CYSFControl::~CYSFControl() @@ -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) { diff --git a/YSFControl.h b/YSFControl.h index ffa61e381..04b744eaf 100644 --- a/YSFControl.h +++ b/YSFControl.h @@ -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" @@ -40,7 +41,7 @@ class CYSFControl { unsigned int readModem(unsigned char* data); - void clock(unsigned int ms); + void clock(); private: IDisplay* m_display; @@ -48,6 +49,7 @@ class CYSFControl { CRingBuffer m_queue; RPT_RF_STATE m_state; CTimer m_timeoutTimer; + CStopWatch m_interval; unsigned int m_frames; CYSFFICH m_fich; unsigned char* m_source;