From 6937f3962bafeaefb62b2c97e26588f0a07ec6f4 Mon Sep 17 00:00:00 2001 From: Tom Early Date: Wed, 13 Feb 2019 11:39:36 -0700 Subject: [PATCH] identical log_debug output --- QnetGateway.cpp | 23 ++++++++++++++--------- QnetGateway.h | 1 + 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/QnetGateway.cpp b/QnetGateway.cpp index 436c453..1f5fb0b 100644 --- a/QnetGateway.cpp +++ b/QnetGateway.cpp @@ -64,6 +64,8 @@ extern int dstar_dv_decode(const unsigned char *d, int data[3]); static std::atomic keep_running(true); + + /* signal catching function */ static void sigCatch(int signum) { @@ -74,6 +76,10 @@ static void sigCatch(int signum) return; } +bool CQnetGateway::VoicePacketIsSync(const unsigned char *text) +{ + return *text==0x55U && *(text+1)==0x2DU && *(text+2)==0x16U; +} void CQnetGateway::UnpackCallsigns(const std::string &str, std::set &set, const std::string &delimiters) { @@ -1095,17 +1101,16 @@ void CQnetGateway::ProcessG2(const ssize_t g2buflen, const SDSVT &g2buf, const b if (match) { if (LOG_DEBUG) { const unsigned int ctrl = g2buf.ctrl & 0x3FU; - const unsigned char sync_data[3] = { 0x55U, 0x2DU, 0x16U }; - if (memcmp(sync_data, g2buf.vasd.text, 3U)) { - const char *ch = "!1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - superframe[i].append(1, (ctrl<37U) ? ch[ctrl] : '*' ); - } else { + if (VoicePacketIsSync(g2buf.vasd.text)) { + if (superframe[i].size() > 65U) { + printf("Frame[%c]: %s\n", 'A'+i, superframe[i].c_str()); + superframe[i].clear(); + } const char *ch = "#abcdefghijklmnopqrstuvwxyz"; superframe[i].append(1, (ctrl<27U) ? ch[ctrl] : '%' ); - } - if (superframe[i].size() > 65U && ctrl == 20U) { - printf("Frame[%c]: %s\n", 'A'+i, superframe[i].c_str()); - superframe[i].clear(); + } else { + const char *ch = "!1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + superframe[i].append(1, (ctrl<37U) ? ch[ctrl] : '*' ); } } Gate2Modem[i].Write(g2buf.title, 27); diff --git a/QnetGateway.h b/QnetGateway.h index 0c6ec56..2afc5d4 100644 --- a/QnetGateway.h +++ b/QnetGateway.h @@ -158,6 +158,7 @@ private: int dtmf_last_frame[3]; unsigned int dtmf_counter[3]; + bool VoicePacketIsSync(const unsigned char *text); void AddFDSet(int &max, int newfd, fd_set *set); int open_port(const SPORTIP &pip); void calcPFCS(unsigned char *packet, int len);