From c85aa2c9f328f3b04c2654dec0d1c855e57fc522 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 26 Feb 2018 19:12:26 +0000 Subject: [PATCH] Add sequence number reset code. --- YSFGateway/FCSNetwork.cpp | 22 ++++++++++++++++------ YSFGateway/FCSNetwork.h | 1 + 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/YSFGateway/FCSNetwork.cpp b/YSFGateway/FCSNetwork.cpp index 4b64c89..a9e52b8 100644 --- a/YSFGateway/FCSNetwork.cpp +++ b/YSFGateway/FCSNetwork.cpp @@ -39,6 +39,7 @@ m_reflector(), m_buffer(1000U, "FCS Network Buffer"), m_n(0U), m_pingTimer(1000U, 0U, 800U), +m_resetTimer(1000U, 1U), m_state(FCS_UNLINKED) { m_info = new unsigned char[100U]; @@ -73,6 +74,7 @@ bool CFCSNetwork::open() void CFCSNetwork::clearDestination() { m_pingTimer.stop(); + m_resetTimer.stop(); m_state = FCS_UNLINKED; } @@ -134,6 +136,18 @@ void CFCSNetwork::writeUnlink(unsigned int count) void CFCSNetwork::clock(unsigned int ms) { + m_pingTimer.clock(ms); + if (m_pingTimer.isRunning() && m_pingTimer.hasExpired()) { + writePing(); + m_pingTimer.start(); + } + + m_resetTimer.clock(ms); + if (m_resetTimer.isRunning() && m_resetTimer.hasExpired()) { + m_n = 0U; + m_resetTimer.stop(); + } + unsigned char buffer[BUFFER_LENGTH]; in_addr address; @@ -145,12 +159,6 @@ void CFCSNetwork::clock(unsigned int ms) if (m_state == FCS_UNLINKED) return; - m_pingTimer.clock(ms); - if (m_pingTimer.isRunning() && m_pingTimer.hasExpired()) { - writePing(); - m_pingTimer.start(); - } - if (address.s_addr != m_address.s_addr || port != FCS_PORT) return; @@ -197,6 +205,8 @@ unsigned int CFCSNetwork::read(unsigned char* data) return 14U; } + m_resetTimer.start(); + unsigned char buffer[130U]; m_buffer.getData(buffer, len); diff --git a/YSFGateway/FCSNetwork.h b/YSFGateway/FCSNetwork.h index 11ea3f2..486b26c 100644 --- a/YSFGateway/FCSNetwork.h +++ b/YSFGateway/FCSNetwork.h @@ -66,6 +66,7 @@ private: std::map m_addresses; unsigned char m_n; CTimer m_pingTimer; + CTimer m_resetTimer; FCS_STATE m_state; void writeInfo();