Merge pull request #435 from shawnchain/master

MMDVMHost patches from BG5HHP
This commit is contained in:
Jonathan Naylor
2018-07-04 18:47:23 +01:00
committed by GitHub
7 changed files with 22 additions and 16 deletions

View File

@@ -26,6 +26,7 @@
#include <cstdio> #include <cstdio>
#include <cassert> #include <cassert>
#include <cstring> #include <cstring>
#include <stdlib.h>
const unsigned int BUFFER_LENGTH = 500U; 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) : 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_address(),
m_port(port), m_port(port),
m_id(NULL), m_id(NULL),
@@ -121,7 +123,10 @@ void CDMRNetwork::setConfig(const std::string& callsign, unsigned int rxFrequenc
bool CDMRNetwork::open() bool CDMRNetwork::open()
{ {
LogMessage("DMR, Opening DMR Network"); LogMessage("DMR, Opening DMR Network");
if (m_address.s_addr == INADDR_NONE)
{
m_address = CUDPSocket::lookup(m_addressStr);
}
m_status = WAITING_CONNECT; m_status = WAITING_CONNECT;
m_timeoutTimer.stop(); m_timeoutTimer.stop();
m_retryTimer.start(); m_retryTimer.start();

View File

@@ -57,6 +57,7 @@ public:
void close(); void close();
private: private:
std::string m_addressStr;
in_addr m_address; in_addr m_address;
unsigned int m_port; unsigned int m_port;
uint8_t* m_id; uint8_t* m_id;

View File

@@ -26,6 +26,7 @@
#include <cstdio> #include <cstdio>
#include <cassert> #include <cassert>
#include <cstring> #include <cstring>
#include <stdlib.h>
const unsigned int BUFFER_LENGTH = 100U; const unsigned int BUFFER_LENGTH = 100U;

View File

@@ -46,6 +46,7 @@
#include <cstdio> #include <cstdio>
#include <vector> #include <vector>
#include <stdlib.h>
#if !defined(_WIN32) && !defined(_WIN64) #if !defined(_WIN32) && !defined(_WIN64)
#include <sys/types.h> #include <sys/types.h>
@@ -206,7 +207,7 @@ int CMMDVMHost::run()
::close(STDOUT_FILENO); ::close(STDOUT_FILENO);
::close(STDERR_FILENO); ::close(STDERR_FILENO);
#if !defined(HD44780) && !defined(OLED) #if !defined(HD44780) && !defined(OLED) && !defined(_OPENWRT)
// If we are currently root... // If we are currently root...
if (getuid() == 0) { if (getuid() == 0) {
struct passwd* user = ::getpwnam("mmdvm"); struct passwd* user = ::getpwnam("mmdvm");
@@ -237,7 +238,7 @@ int CMMDVMHost::run()
} }
} }
#else #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
#endif #endif

View File

@@ -34,7 +34,8 @@ m_ldu1(NULL),
m_ldu2(NULL), m_ldu2(NULL),
m_termlc(NULL), m_termlc(NULL),
m_term(NULL), m_term(NULL),
m_pdu(NULL) m_pdu(NULL),
m_tsdu(NULL)
{ {
CBCH bch; CBCH bch;
@@ -96,6 +97,7 @@ CP25NID::~CP25NID()
delete[] m_termlc; delete[] m_termlc;
delete[] m_term; delete[] m_term;
delete[] m_pdu; delete[] m_pdu;
delete[] m_tsdu;
} }
bool CP25NID::decode(const unsigned char* data) bool CP25NID::decode(const unsigned char* data)

View File

@@ -17,6 +17,7 @@
*/ */
#include "StopWatch.h" #include "StopWatch.h"
#include <time.h>
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
@@ -64,21 +65,16 @@ CStopWatch::~CStopWatch()
unsigned long CStopWatch::start() unsigned long CStopWatch::start()
{ {
::gettimeofday(&m_start, NULL); ::clock_gettime(CLOCK_MONOTONIC, &m_start);
return (m_start.tv_sec * 1000UL) + (m_start.tv_nsec / 1000000UL);
return m_start.tv_usec;
} }
unsigned int CStopWatch::elapsed() unsigned int CStopWatch::elapsed()
{ {
struct timeval now; struct timespec now;
::gettimeofday(&now, NULL); ::clock_gettime(CLOCK_MONOTONIC, &now);
int offset = ((now.tv_sec - m_start.tv_sec) * 1000000000UL + now.tv_nsec - m_start.tv_nsec ) / 1000000UL;
unsigned int elapsed = (now.tv_sec - m_start.tv_sec) * 1000U; return (unsigned int)offset;
elapsed += now.tv_usec / 1000U;
elapsed -= m_start.tv_usec / 1000U;
return elapsed;
} }
#endif #endif

View File

@@ -39,7 +39,7 @@ private:
LARGE_INTEGER m_frequency; LARGE_INTEGER m_frequency;
LARGE_INTEGER m_start; LARGE_INTEGER m_start;
#else #else
struct timeval m_start; struct timespec m_start;
#endif #endif
}; };