From 0ee26a5a9810dec99db19a4246cf81346d5cfb5a Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Tue, 3 Jul 2018 10:01:19 +0800 Subject: [PATCH 1/9] patch to keep root permision for openwrt --- MMDVMHost.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index d92eae9..3eef883 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -206,7 +206,7 @@ int CMMDVMHost::run() ::close(STDOUT_FILENO); ::close(STDERR_FILENO); -#if !defined(HD44780) && !defined(OLED) +#if !defined(HD44780) && !defined(OLED) && !defined(_OPENWRT) // If we are currently root... if (getuid() == 0) { struct passwd* user = ::getpwnam("mmdvm"); @@ -237,7 +237,7 @@ int CMMDVMHost::run() } } #else - ::fprintf(stderr, "Dropping root permissions in daemon mode is disabled with HD44780 display\n"); + ::fprintf(stderr, "Dropping root permissions in daemon mode is disabled.\n"); } #endif #endif From 1ab0610543fa76186fb46eec3b73c0a91972eb82 Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Tue, 3 Jul 2018 10:04:44 +0800 Subject: [PATCH 2/9] patch stdlib header --- DMRNetwork.cpp | 1 + DStarNetwork.cpp | 1 + MMDVMHost.cpp | 1 + 3 files changed, 3 insertions(+) diff --git a/DMRNetwork.cpp b/DMRNetwork.cpp index 15bf3bc..ede4a5a 100644 --- a/DMRNetwork.cpp +++ b/DMRNetwork.cpp @@ -26,6 +26,7 @@ #include #include #include +#include const unsigned int BUFFER_LENGTH = 500U; diff --git a/DStarNetwork.cpp b/DStarNetwork.cpp index 443fcac..8da0740 100644 --- a/DStarNetwork.cpp +++ b/DStarNetwork.cpp @@ -26,6 +26,7 @@ #include #include #include +#include const unsigned int BUFFER_LENGTH = 100U; diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 3eef883..8f3594f 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -46,6 +46,7 @@ #include #include +#include #if !defined(_WIN32) && !defined(_WIN64) #include From 1b7abded6749e9579ffb7bf901cb61190b5e9585 Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Tue, 3 Jul 2018 11:35:55 +0800 Subject: [PATCH 3/9] FIX DMRNewtork infinite failure on domain name resolve --- DMRNetwork.cpp | 6 +++++- DMRNetwork.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/DMRNetwork.cpp b/DMRNetwork.cpp index ede4a5a..e3337d1 100644 --- a/DMRNetwork.cpp +++ b/DMRNetwork.cpp @@ -34,6 +34,7 @@ const unsigned int HOMEBREW_DATA_PACKET_LENGTH = 55U; CDMRNetwork::CDMRNetwork(const std::string& address, unsigned int port, unsigned int local, unsigned int id, const std::string& password, bool duplex, const char* version, bool debug, bool slot1, bool slot2, HW_TYPE hwType) : +m_addressStr(address), m_address(), m_port(port), m_id(NULL), @@ -122,7 +123,10 @@ void CDMRNetwork::setConfig(const std::string& callsign, unsigned int rxFrequenc bool CDMRNetwork::open() { LogMessage("DMR, Opening DMR Network"); - + if (m_address.s_addr == INADDR_NONE) + { + m_address = CUDPSocket::lookup(m_addressStr); + } m_status = WAITING_CONNECT; m_timeoutTimer.stop(); m_retryTimer.start(); diff --git a/DMRNetwork.h b/DMRNetwork.h index d1d12e4..9dbb812 100644 --- a/DMRNetwork.h +++ b/DMRNetwork.h @@ -57,6 +57,7 @@ public: void close(); private: + std::string m_addressStr; in_addr m_address; unsigned int m_port; uint8_t* m_id; From ae532156c5748783405f34631aa1851f90048bef Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Tue, 3 Jul 2018 15:09:11 +0800 Subject: [PATCH 4/9] fix memory leak in P25NID --- P25NID.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/P25NID.cpp b/P25NID.cpp index 7e4f1e8..dba8fb1 100644 --- a/P25NID.cpp +++ b/P25NID.cpp @@ -34,7 +34,8 @@ m_ldu1(NULL), m_ldu2(NULL), m_termlc(NULL), m_term(NULL), -m_pdu(NULL) +m_pdu(NULL), +m_tsdu(NULL) { CBCH bch; @@ -96,6 +97,7 @@ CP25NID::~CP25NID() delete[] m_termlc; delete[] m_term; delete[] m_pdu; + delete[] m_tsdu; } bool CP25NID::decode(const unsigned char* data) From 7bf82085c2e6a5e699e6ec4ab5722ffcb3708fc8 Mon Sep 17 00:00:00 2001 From: Andy CA6JAU Date: Tue, 3 Jul 2018 13:28:54 -0400 Subject: [PATCH 5/9] Fix DMR jitter default var value --- Conf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Conf.cpp b/Conf.cpp index 8f28377..2a2590a 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -171,7 +171,7 @@ m_dmrNetworkLocal(0U), m_dmrNetworkPassword(), m_dmrNetworkOptions(), m_dmrNetworkDebug(false), -m_dmrNetworkJitter(300U), +m_dmrNetworkJitter(360U), m_dmrNetworkSlot1(true), m_dmrNetworkSlot2(true), m_dmrNetworkModeHang(3U), From 657ef07b56291bb93036a24c211fdfb7d2eca1d5 Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Wed, 4 Jul 2018 17:54:38 +0800 Subject: [PATCH 6/9] Fix time measurement issud --- StopWatch.cpp | 17 ++++++----------- StopWatch.h | 2 +- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/StopWatch.cpp b/StopWatch.cpp index 77d539d..046a943 100644 --- a/StopWatch.cpp +++ b/StopWatch.cpp @@ -64,21 +64,16 @@ CStopWatch::~CStopWatch() unsigned long CStopWatch::start() { - ::gettimeofday(&m_start, NULL); - - return m_start.tv_usec; + ::clock_gettime(CLOCK_MONOTONIC, &m_start); + return m_start.tv_sec; } unsigned int CStopWatch::elapsed() { - struct timeval now; - ::gettimeofday(&now, NULL); - - unsigned int elapsed = (now.tv_sec - m_start.tv_sec) * 1000U; - elapsed += now.tv_usec / 1000U; - elapsed -= m_start.tv_usec / 1000U; - - return elapsed; + struct timespec now; + ::clock_gettime(CLOCK_MONOTONIC, &now); + int offset = ((now.tv_sec - m_start.tv_sec) * 1000000000UL + now.tv_nsec - m_start.tv_nsec ) / 1000000UL; + return (unsigned int)offset; } #endif diff --git a/StopWatch.h b/StopWatch.h index 811047e..a1e2bf8 100644 --- a/StopWatch.h +++ b/StopWatch.h @@ -39,7 +39,7 @@ private: LARGE_INTEGER m_frequency; LARGE_INTEGER m_start; #else - struct timeval m_start; + struct timespec m_start; #endif }; From 2bd988d2a7b5a636fe02b525169536d19e405d23 Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Wed, 4 Jul 2018 19:46:51 +0800 Subject: [PATCH 7/9] Missing time.h header for linux --- StopWatch.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/StopWatch.cpp b/StopWatch.cpp index 046a943..154e62d 100644 --- a/StopWatch.cpp +++ b/StopWatch.cpp @@ -17,6 +17,7 @@ */ #include "StopWatch.h" +#include #if defined(_WIN32) || defined(_WIN64) From 1ef21b5b4ffb2610d977516c90c9383c86d8d52e Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Wed, 4 Jul 2018 21:28:17 +0800 Subject: [PATCH 8/9] fix CStopWatch::start() return value to keep the compability --- StopWatch.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StopWatch.cpp b/StopWatch.cpp index 154e62d..37925d4 100644 --- a/StopWatch.cpp +++ b/StopWatch.cpp @@ -66,7 +66,7 @@ CStopWatch::~CStopWatch() unsigned long CStopWatch::start() { ::clock_gettime(CLOCK_MONOTONIC, &m_start); - return m_start.tv_sec; + return (m_start.tv_sec * 1000UL) + (m_start.tv_nsec / 1000000UL); } unsigned int CStopWatch::elapsed() From bb9db2ce93ad28cbb49fbf7b1f0f5a701aeb2cf4 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Wed, 4 Jul 2018 19:00:51 +0100 Subject: [PATCH 9/9] Clean up the merged code. --- DMRNetwork.cpp | 6 +++--- DStarNetwork.cpp | 2 +- MMDVMHost.cpp | 3 ++- StopWatch.cpp | 5 +++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/DMRNetwork.cpp b/DMRNetwork.cpp index e3337d1..86bc335 100644 --- a/DMRNetwork.cpp +++ b/DMRNetwork.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include const unsigned int BUFFER_LENGTH = 500U; @@ -123,10 +123,10 @@ void CDMRNetwork::setConfig(const std::string& callsign, unsigned int rxFrequenc bool CDMRNetwork::open() { LogMessage("DMR, Opening DMR Network"); + if (m_address.s_addr == INADDR_NONE) - { m_address = CUDPSocket::lookup(m_addressStr); - } + m_status = WAITING_CONNECT; m_timeoutTimer.stop(); m_retryTimer.start(); diff --git a/DStarNetwork.cpp b/DStarNetwork.cpp index 8da0740..ebf971f 100644 --- a/DStarNetwork.cpp +++ b/DStarNetwork.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include const unsigned int BUFFER_LENGTH = 100U; diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 8f3594f..31b8db7 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -46,7 +46,8 @@ #include #include -#include + +#include #if !defined(_WIN32) && !defined(_WIN64) #include diff --git a/StopWatch.cpp b/StopWatch.cpp index 37925d4..2f15645 100644 --- a/StopWatch.cpp +++ b/StopWatch.cpp @@ -17,7 +17,6 @@ */ #include "StopWatch.h" -#include #if defined(_WIN32) || defined(_WIN64) @@ -53,6 +52,7 @@ unsigned int CStopWatch::elapsed() #else #include +#include CStopWatch::CStopWatch() : m_start() @@ -66,7 +66,8 @@ CStopWatch::~CStopWatch() unsigned long CStopWatch::start() { ::clock_gettime(CLOCK_MONOTONIC, &m_start); - return (m_start.tv_sec * 1000UL) + (m_start.tv_nsec / 1000000UL); + + return m_start.tv_sec * 1000UL + m_start.tv_nsec / 1000000UL; } unsigned int CStopWatch::elapsed()