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 <cassert>
#include <cstring>
#include <stdlib.h>
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();

View File

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

View File

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

View File

@@ -46,6 +46,7 @@
#include <cstdio>
#include <vector>
#include <stdlib.h>
#if !defined(_WIN32) && !defined(_WIN64)
#include <sys/types.h>
@@ -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

View File

@@ -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)

View File

@@ -17,6 +17,7 @@
*/
#include "StopWatch.h"
#include <time.h>
#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

View File

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