diff --git a/DMRNetwork.cpp b/DMRNetwork.cpp index 15bf3bc..e3337d1 100644 --- a/DMRNetwork.cpp +++ b/DMRNetwork.cpp @@ -26,6 +26,7 @@ #include #include #include +#include const unsigned int BUFFER_LENGTH = 500U; @@ -33,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), @@ -121,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; 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 d92eae9..8f3594f 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -46,6 +46,7 @@ #include #include +#include #if !defined(_WIN32) && !defined(_WIN64) #include @@ -206,7 +207,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 +238,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 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) diff --git a/StopWatch.cpp b/StopWatch.cpp index 77d539d..37925d4 100644 --- a/StopWatch.cpp +++ b/StopWatch.cpp @@ -17,6 +17,7 @@ */ #include "StopWatch.h" +#include #if defined(_WIN32) || defined(_WIN64) @@ -64,21 +65,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 * 1000UL) + (m_start.tv_nsec / 1000000UL); } 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 };