From 9796b400c8053c553ee4bae0020c4e5cf4c49235 Mon Sep 17 00:00:00 2001 From: m0vse Date: Sat, 2 May 2020 21:40:55 +0100 Subject: [PATCH 1/5] Add enable/disable commands to RemoteCommand --- MMDVMHost.cpp | 61 +++++++++++++++++++++++++++++++++++++++++++++++ MMDVMHost.h | 1 + Modem.cpp | 5 ++++ Modem.h | 1 + RemoteControl.cpp | 28 ++++++++++++++++++++++ RemoteControl.h | 13 ++++++++++ 6 files changed, 109 insertions(+) diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 2134223..b9449e0 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -1975,6 +1975,58 @@ void CMMDVMHost::remoteControl() if (m_nxdn != NULL) processModeCommand(MODE_NXDN, m_nxdnRFModeHang); break; + case RCD_MODE_FM: + if (m_fmEnabled != false) + processModeCommand(MODE_FM, 0); + break; + case RCD_ENABLE_DSTAR: + if (m_dstar != NULL && m_dstarEnabled==false) + processEnableCommand(m_dstarEnabled, true); + break; + case RCD_ENABLE_DMR: + if (m_dmr != NULL && m_dmrEnabled==false) + processEnableCommand(m_dmrEnabled, true); + break; + case RCD_ENABLE_YSF: + if (m_ysf != NULL && m_ysfEnabled==false) + processEnableCommand(m_ysfEnabled, true); + break; + case RCD_ENABLE_P25: + if (m_p25 != NULL && m_p25Enabled==false) + processEnableCommand(m_p25Enabled, true); + break; + case RCD_ENABLE_NXDN: + if (m_nxdn != NULL && m_nxdnEnabled==false) + processEnableCommand(m_nxdnEnabled, true); + break; + case RCD_ENABLE_FM: + if (m_fmEnabled==false) + processEnableCommand(m_fmEnabled, true); + break; + case RCD_DISABLE_DSTAR: + if (m_dstar != NULL && m_dstarEnabled==true) + processEnableCommand(m_dstarEnabled, false); + break; + case RCD_DISABLE_DMR: + if (m_dmr != NULL && m_dmrEnabled==true) + processEnableCommand(m_dmrEnabled, false); + break; + case RCD_DISABLE_YSF: + if (m_ysf != NULL && m_ysfEnabled==true) + processEnableCommand(m_ysfEnabled, false); + break; + case RCD_DISABLE_P25: + if (m_p25 != NULL && m_p25Enabled==true) + processEnableCommand(m_p25Enabled, false); + break; + case RCD_DISABLE_NXDN: + if (m_nxdn != NULL && m_nxdnEnabled==true) + processEnableCommand(m_nxdnEnabled, false); + break; + case RCD_DISABLE_FM: + if (m_fmEnabled == true) + processEnableCommand(m_fmEnabled, false); + break; case RCD_PAGE: if (m_pocsag != NULL) { unsigned int ric = m_remoteControl->getArgUInt(0U); @@ -2008,3 +2060,12 @@ void CMMDVMHost::processModeCommand(unsigned char mode, unsigned int timeout) setMode(mode); } + +void CMMDVMHost::processEnableCommand(bool& mode, bool enabled) +{ + LogDebug("Setting mode current=%s new=%s",mode ? "true" : "false",enabled ? "true" : "false"); + mode=enabled; + m_modem->setModeParams(m_dstarEnabled, m_dmrEnabled, m_ysfEnabled, m_p25Enabled, m_nxdnEnabled, m_pocsagEnabled, m_fmEnabled); + if (!m_modem->writeConfig()) + LogError("Cannot write Config to MMDVM"); +} diff --git a/MMDVMHost.h b/MMDVMHost.h index de22de2..17d6786 100644 --- a/MMDVMHost.h +++ b/MMDVMHost.h @@ -117,6 +117,7 @@ private: void remoteControl(); void processModeCommand(unsigned char mode, unsigned int timeout); + void processEnableCommand(bool& mode, bool enabled); void setMode(unsigned char mode); diff --git a/Modem.cpp b/Modem.cpp index 729dd59..784aa3e 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -1491,6 +1491,11 @@ bool CModem::readStatus() return m_serial->write(buffer, 3U) == 3; } +bool CModem::writeConfig() +{ + return setConfig(); +} + bool CModem::setConfig() { assert(m_serial != NULL); diff --git a/Modem.h b/Modem.h index c12466f..0533fa1 100644 --- a/Modem.h +++ b/Modem.h @@ -75,6 +75,7 @@ public: virtual bool hasLockout() const; virtual bool hasError() const; + virtual bool writeConfig(); virtual bool writeDStarData(const unsigned char* data, unsigned int length); virtual bool writeDMRData1(const unsigned char* data, unsigned int length); virtual bool writeDMRData2(const unsigned char* data, unsigned int length); diff --git a/RemoteControl.cpp b/RemoteControl.cpp index afa1473..3a62213 100644 --- a/RemoteControl.cpp +++ b/RemoteControl.cpp @@ -25,6 +25,8 @@ #include const unsigned int SET_MODE_ARGS = 2U; +const unsigned int ENABLE_ARGS = 2U; +const unsigned int DISABLE_ARGS = 2U; const unsigned int PAGE_ARGS = 3U; const unsigned int BUFFER_LENGTH = 100U; @@ -86,6 +88,32 @@ REMOTE_COMMAND CRemoteControl::getCommand() m_command = RCD_MODE_P25; else if (m_args.at(1U) == "nxdn") m_command = RCD_MODE_NXDN; + } else if (m_args.at(0U) == "enable" && m_args.size() >= ENABLE_ARGS) { + if (m_args.at(1U) == "dstar") + m_command = RCD_ENABLE_DSTAR; + else if (m_args.at(1U) == "dmr") + m_command = RCD_ENABLE_DMR; + else if (m_args.at(1U) == "ysf") + m_command = RCD_ENABLE_YSF; + else if (m_args.at(1U) == "p25") + m_command = RCD_ENABLE_P25; + else if (m_args.at(1U) == "nxdn") + m_command = RCD_ENABLE_NXDN; + else if (m_args.at(1U) == "fm") + m_command = RCD_ENABLE_FM; + } else if (m_args.at(0U) == "disable" && m_args.size() >= DISABLE_ARGS) { + if (m_args.at(1U) == "dstar") + m_command = RCD_DISABLE_DSTAR; + else if (m_args.at(1U) == "dmr") + m_command = RCD_DISABLE_DMR; + else if (m_args.at(1U) == "ysf") + m_command = RCD_DISABLE_YSF; + else if (m_args.at(1U) == "p25") + m_command = RCD_DISABLE_P25; + else if (m_args.at(1U) == "nxdn") + m_command = RCD_DISABLE_NXDN; + else if (m_args.at(1U) == "fm") + m_command = RCD_DISABLE_FM; } else if (m_args.at(0U) == "page" && m_args.size() >= PAGE_ARGS) { // Page command is in the form of "page " m_command = RCD_PAGE; diff --git a/RemoteControl.h b/RemoteControl.h index 479987a..31d546d 100644 --- a/RemoteControl.h +++ b/RemoteControl.h @@ -33,6 +33,19 @@ enum REMOTE_COMMAND { RCD_MODE_YSF, RCD_MODE_P25, RCD_MODE_NXDN, + RCD_MODE_FM, + RCD_ENABLE_DSTAR, + RCD_ENABLE_DMR, + RCD_ENABLE_YSF, + RCD_ENABLE_P25, + RCD_ENABLE_NXDN, + RCD_ENABLE_FM, + RCD_DISABLE_DSTAR, + RCD_DISABLE_DMR, + RCD_DISABLE_YSF, + RCD_DISABLE_P25, + RCD_DISABLE_NXDN, + RCD_DISABLE_FM, RCD_PAGE }; From 1a142e36cb1dc794c1cacd2cf57f7f23e358ce08 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 4 May 2020 22:30:16 +0100 Subject: [PATCH 2/5] Host support for the CallsignAtLatch option. --- Conf.cpp | 8 ++++++++ Conf.h | 2 ++ MMDVM.ini | 1 + MMDVMHost.cpp | 4 +++- Modem.cpp | 6 +++++- Modem.h | 3 ++- Version.h | 2 +- 7 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index e204fa9..23f7596 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -182,6 +182,7 @@ m_fmCallsignHighLevel(35.0F), m_fmCallsignLowLevel(15.0F), m_fmCallsignAtStart(true), m_fmCallsignAtEnd(true), +m_fmCallsignAtLatch(true), m_fmRFAck("K"), m_fmExtAck("N"), m_fmAckSpeed(20U), @@ -716,6 +717,8 @@ bool CConf::read() m_fmCallsignAtStart = ::atoi(value) == 1; else if (::strcmp(key, "CallsignAtEnd") == 0) m_fmCallsignAtEnd = ::atoi(value) == 1; + else if (::strcmp(key, "CallsignAtLatch") == 0) + m_fmCallsignAtLatch = ::atoi(value) == 1; else if (::strcmp(key, "RFAck") == 0) { // Convert the ack to upper case for (unsigned int i = 0U; value[i] != 0; i++) @@ -1545,6 +1548,11 @@ bool CConf::getFMCallsignAtEnd() const return m_fmCallsignAtEnd; } +bool CConf::getFMCallsignAtLatch() const +{ + return m_fmCallsignAtLatch; +} + std::string CConf::getFMRFAck() const { return m_fmRFAck; diff --git a/Conf.h b/Conf.h index 14678e1..0ba0955 100644 --- a/Conf.h +++ b/Conf.h @@ -180,6 +180,7 @@ public: float getFMCallsignLowLevel() const; bool getFMCallsignAtStart() const; bool getFMCallsignAtEnd() const; + bool getFMCallsignAtLatch() const; std::string getFMRFAck() const; std::string getFMExtAck() const; unsigned int getFMAckSpeed() const; @@ -445,6 +446,7 @@ private: float m_fmCallsignLowLevel; bool m_fmCallsignAtStart; bool m_fmCallsignAtEnd; + bool m_fmCallsignAtLatch; std::string m_fmRFAck; std::string m_fmExtAck; unsigned int m_fmAckSpeed; diff --git a/MMDVM.ini b/MMDVM.ini index d504978..9faaecc 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -150,6 +150,7 @@ CallsignHighLevel=50 CallsignLowLevel=20 CallsignAtStart=1 CallsignAtEnd=1 +CallsignAtLatch=0 RFAck=K ExtAck=N AckSpeed=20 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index b9449e0..961d9a2 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -1215,6 +1215,7 @@ bool CMMDVMHost::createModem() float callsignLowLevel = m_conf.getFMCallsignLowLevel(); bool callsignAtStart = m_conf.getFMCallsignAtStart(); bool callsignAtEnd = m_conf.getFMCallsignAtEnd(); + bool callsignAtLatch = m_conf.getFMCallsignAtLatch(); std::string rfAck = m_conf.getFMRFAck(); std::string extAck = m_conf.getFMExtAck(); unsigned int ackSpeed = m_conf.getFMAckSpeed(); @@ -1244,6 +1245,7 @@ bool CMMDVMHost::createModem() LogInfo(" Callsign Low Level: %.1f%%", callsignLowLevel); LogInfo(" Callsign At Start: %s", callsignAtStart ? "yes" : "no"); LogInfo(" Callsign At End: %s", callsignAtEnd ? "yes" : "no"); + LogInfo(" Callsign At Latch: %s", callsignAtLatch ? "yes" : "no"); LogInfo(" RF Ack: %s", rfAck.c_str()); // LogInfo(" Ext. Ack: %s", extAck.c_str()); LogInfo(" Ack Speed: %uWPM", ackSpeed); @@ -1263,7 +1265,7 @@ bool CMMDVMHost::createModem() LogInfo(" Max. Deviation Level: %.1f%%", maxDevLevel); // LogInfo(" Ext. Audio Boost: x%u", extAudioBoost); - m_modem->setFMCallsignParams(callsign, callsignSpeed, callsignFrequency, callsignTime, callsignHoldoff, callsignHighLevel, callsignLowLevel, callsignAtStart, callsignAtEnd); + m_modem->setFMCallsignParams(callsign, callsignSpeed, callsignFrequency, callsignTime, callsignHoldoff, callsignHighLevel, callsignLowLevel, callsignAtStart, callsignAtEnd, callsignAtLatch); m_modem->setFMAckParams(rfAck, ackSpeed, ackFrequency, ackMinTime, ackDelay, ackLevel); m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime, useCOS, rfAudioBoost, maxDevLevel); } diff --git a/Modem.cpp b/Modem.cpp index 784aa3e..3041567 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -178,6 +178,7 @@ m_fmCallsignHighLevel(35.0F), m_fmCallsignLowLevel(15.0F), m_fmCallsignAtStart(true), m_fmCallsignAtEnd(true), +m_fmCallsignAtLatch(true), m_fmRfAck("K"), m_fmAckSpeed(20U), m_fmAckFrequency(1750U), @@ -1887,7 +1888,7 @@ bool CModem::writeDMRShortLC(const unsigned char* lc) return m_serial->write(buffer, 12U) == 12; } -void CModem::setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignHighLevel, float callsignLowLevel, bool callsignAtStart, bool callsignAtEnd) +void CModem::setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignHighLevel, float callsignLowLevel, bool callsignAtStart, bool callsignAtEnd, bool callsignAtLatch) { m_fmCallsign = callsign; m_fmCallsignSpeed = callsignSpeed; @@ -1898,6 +1899,7 @@ void CModem::setFMCallsignParams(const std::string& callsign, unsigned int calls m_fmCallsignLowLevel = callsignLowLevel; m_fmCallsignAtStart = callsignAtStart; m_fmCallsignAtEnd = callsignAtEnd; + m_fmCallsignAtLatch = callsignAtLatch; } void CModem::setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackMinTime, unsigned int ackDelay, float ackLevel) @@ -1951,6 +1953,8 @@ bool CModem::setFMCallsignParams() buffer[9U] |= 0x01U; if (m_fmCallsignAtEnd) buffer[9U] |= 0x02U; + if (m_fmCallsignAtLatch) + buffer[9U] |= 0x04U; for (unsigned int i = 0U; i < m_fmCallsign.size(); i++) buffer[10U + i] = m_fmCallsign.at(i); diff --git a/Modem.h b/Modem.h index 0533fa1..edb30ec 100644 --- a/Modem.h +++ b/Modem.h @@ -45,7 +45,7 @@ public: virtual void setYSFParams(bool loDev, unsigned int txHang); virtual void setTransparentDataParams(unsigned int sendFrameType); - virtual void setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignHighLevel, float callsignLowLevel, bool callsignAtStart, bool callsignAtEnd); + virtual void setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignHighLevel, float callsignLowLevel, bool callsignAtStart, bool callsignAtEnd, bool callsignAtLatch); virtual void setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackMinTime, unsigned int ackDelay, float ackLevel); virtual void setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, unsigned int rfAudioBoost, float maxDevLevel); @@ -194,6 +194,7 @@ private: float m_fmCallsignLowLevel; bool m_fmCallsignAtStart; bool m_fmCallsignAtEnd; + bool m_fmCallsignAtLatch; std::string m_fmRfAck; unsigned int m_fmAckSpeed; unsigned int m_fmAckFrequency; diff --git a/Version.h b/Version.h index 8e901ee..4b0d9cc 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200428"; +const char* VERSION = "20200504"; #endif From 5410ca3ce8361789b93e7db14b6c34b24c25c83f Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Wed, 6 May 2020 11:26:54 +0100 Subject: [PATCH 3/5] Add the COSInvert parameter. --- Conf.cpp | 8 ++++++++ Conf.h | 2 ++ MMDVM.ini | 1 + MMDVMHost.cpp | 4 +++- Modem.cpp | 7 ++++++- Modem.h | 3 ++- Version.h | 2 +- 7 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index 23f7596..8c07bc6 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -198,6 +198,7 @@ m_fmCTCSSLevel(2.0F), m_fmKerchunkTime(0U), m_fmHangTime(7U), m_fmUseCOS(true), +m_fmCOSInvert(false), m_fmRFAudioBoost(1U), m_fmMaxDevLevel(90.0F), m_fmExtAudioBoost(1U), @@ -755,6 +756,8 @@ bool CConf::read() m_fmHangTime = (unsigned int)::atoi(value); else if (::strcmp(key, "UseCOS") == 0) m_fmUseCOS = ::atoi(value) == 1; + else if (::strcmp(key, "COSInvert") == 0) + m_fmCOSInvert = ::atoi(value) == 1; else if (::strcmp(key, "RFAudioBoost") == 0) m_fmRFAudioBoost = (unsigned int)::atoi(value); else if (::strcmp(key, "MaxDevLevel") == 0) @@ -1628,6 +1631,11 @@ bool CConf::getFMUseCOS() const return m_fmUseCOS; } +bool CConf::getFMCOSInvert() const +{ + return m_fmCOSInvert; +} + unsigned int CConf::getFMRFAudioBoost() const { return m_fmRFAudioBoost; diff --git a/Conf.h b/Conf.h index 0ba0955..f5a40bd 100644 --- a/Conf.h +++ b/Conf.h @@ -196,6 +196,7 @@ public: unsigned int getFMKerchunkTime() const; unsigned int getFMHangTime() const; bool getFMUseCOS() const; + bool getFMCOSInvert() const; unsigned int getFMRFAudioBoost() const; float getFMMaxDevLevel() const; unsigned int getFMExtAudioBoost() const; @@ -462,6 +463,7 @@ private: unsigned int m_fmKerchunkTime; unsigned int m_fmHangTime; bool m_fmUseCOS; + bool m_fmCOSInvert; unsigned int m_fmRFAudioBoost; float m_fmMaxDevLevel; unsigned int m_fmExtAudioBoost; diff --git a/MMDVM.ini b/MMDVM.ini index 9faaecc..5e71a84 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -166,6 +166,7 @@ CTCSSLevel=20 KerchunkTime=0 HangTime=7 UseCOS=1 +COSInvert=0 RFAudioBoost=1 MaxDevLevel=90 ExtAudioBoost=1 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index b3314be..e2a7766 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -1231,6 +1231,7 @@ bool CMMDVMHost::createModem() unsigned int kerchunkTime = m_conf.getFMKerchunkTime(); unsigned int hangTime = m_conf.getFMHangTime(); bool useCOS = m_conf.getFMUseCOS(); + bool cosInvert = m_conf.getFMCOSInvert(); unsigned int rfAudioBoost = m_conf.getFMRFAudioBoost(); float maxDevLevel = m_conf.getFMMaxDevLevel(); unsigned int extAudioBoost = m_conf.getFMExtAudioBoost(); @@ -1261,13 +1262,14 @@ bool CMMDVMHost::createModem() LogInfo(" Kerchunk Time: %us", kerchunkTime); LogInfo(" Hang Time: %us", hangTime); LogInfo(" Use COS: %s", useCOS ? "yes" : "no"); + LogInfo(" COS Invert: %s", cosInvert ? "yes" : "no"); LogInfo(" RF Audio Boost: x%u", rfAudioBoost); LogInfo(" Max. Deviation Level: %.1f%%", maxDevLevel); // LogInfo(" Ext. Audio Boost: x%u", extAudioBoost); m_modem->setFMCallsignParams(callsign, callsignSpeed, callsignFrequency, callsignTime, callsignHoldoff, callsignHighLevel, callsignLowLevel, callsignAtStart, callsignAtEnd, callsignAtLatch); m_modem->setFMAckParams(rfAck, ackSpeed, ackFrequency, ackMinTime, ackDelay, ackLevel); - m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime, useCOS, rfAudioBoost, maxDevLevel); + m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime, useCOS, cosInvert, rfAudioBoost, maxDevLevel); } bool ret = m_modem->open(); diff --git a/Modem.cpp b/Modem.cpp index 3041567..edbebec 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -193,6 +193,7 @@ m_fmCtcssLevel(10.0F), m_fmKerchunkTime(0U), m_fmHangTime(5U), m_fmUseCOS(true), +m_fmCOSInvert(false), m_fmRFAudioBoost(1U), m_fmMaxDevLevel(90.0F) { @@ -1912,7 +1913,7 @@ void CModem::setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, uns m_fmAckLevel = ackLevel; } -void CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, unsigned int rfAudioBoost, float maxDevLevel) +void CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, bool cosInvert, unsigned int rfAudioBoost, float maxDevLevel) { m_fmTimeout = timeout; m_fmTimeoutLevel = timeoutLevel; @@ -1925,6 +1926,8 @@ void CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctc m_fmHangTime = hangTime; m_fmUseCOS = useCOS; + m_fmCOSInvert = cosInvert; + m_fmRFAudioBoost = rfAudioBoost; m_fmMaxDevLevel = maxDevLevel; } @@ -2065,6 +2068,8 @@ bool CModem::setFMMiscParams() buffer[10U] = 0x00U; if (m_fmUseCOS) buffer[10U] |= 0x01U; + if (m_fmCOSInvert) + buffer[10U] |= 0x02U; buffer[11U] = m_fmRFAudioBoost; diff --git a/Modem.h b/Modem.h index edb30ec..6404d89 100644 --- a/Modem.h +++ b/Modem.h @@ -47,7 +47,7 @@ public: virtual void setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignHighLevel, float callsignLowLevel, bool callsignAtStart, bool callsignAtEnd, bool callsignAtLatch); virtual void setFMAckParams(const std::string& rfAck, unsigned int ackSpeed, unsigned int ackFrequency, unsigned int ackMinTime, unsigned int ackDelay, float ackLevel); - virtual void setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, unsigned int rfAudioBoost, float maxDevLevel); + virtual void setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, bool cosInvert, unsigned int rfAudioBoost, float maxDevLevel); virtual bool open(); @@ -209,6 +209,7 @@ private: unsigned int m_fmKerchunkTime; unsigned int m_fmHangTime; bool m_fmUseCOS; + bool m_fmCOSInvert; unsigned int m_fmRFAudioBoost; float m_fmMaxDevLevel; diff --git a/Version.h b/Version.h index 4b0d9cc..7bf2d5a 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200504"; +const char* VERSION = "20200506"; #endif From c3efabf56c5b664f6edd0ac7706f413bb8e5030d Mon Sep 17 00:00:00 2001 From: Daniel Caujolle-Bert Date: Sat, 9 May 2020 12:11:08 +0200 Subject: [PATCH 4/5] Redirect stderr messages to the log file, as in daemon mode assert() failure are silent and make wrong INI file hard to fix. --- Log.cpp | 20 +++++++++++++++++--- Log.h | 2 +- MMDVMHost.cpp | 3 +-- RemoteCommand.cpp | 2 +- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Log.cpp b/Log.cpp index fc37ebf..f600b90 100644 --- a/Log.cpp +++ b/Log.cpp @@ -22,6 +22,7 @@ #include #else #include +#include #endif #include @@ -36,6 +37,7 @@ static std::string m_filePath; static std::string m_fileRoot; static FILE* m_fpLog = NULL; +static bool m_daemon = false; static unsigned int m_displayLevel = 2U; @@ -45,6 +47,8 @@ static char LEVELS[] = " DMIWEF"; static bool LogOpen() { + bool status = false; + if (m_fileLevel == 0U) return true; @@ -68,18 +72,28 @@ static bool LogOpen() ::sprintf(filename, "%s/%s-%04d-%02d-%02d.log", m_filePath.c_str(), m_fileRoot.c_str(), tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday); #endif - m_fpLog = ::fopen(filename, "a+t"); + if ((m_fpLog = ::fopen(filename, "a+t")) != NULL) + { + status = true; + +#if !defined(_WIN32) && !defined(_WIN64) + if (m_daemon) + dup2(fileno(m_fpLog), fileno(stderr)); +#endif + } + m_tm = *tm; - return m_fpLog != NULL; + return status; } -bool LogInitialise(const std::string& filePath, const std::string& fileRoot, unsigned int fileLevel, unsigned int displayLevel) +bool LogInitialise(bool daemon, const std::string& filePath, const std::string& fileRoot, unsigned int fileLevel, unsigned int displayLevel) { m_filePath = filePath; m_fileRoot = fileRoot; m_fileLevel = fileLevel; m_displayLevel = displayLevel; + m_daemon = daemon; return ::LogOpen(); } diff --git a/Log.h b/Log.h index d671ef9..0d00653 100644 --- a/Log.h +++ b/Log.h @@ -30,7 +30,7 @@ extern void Log(unsigned int level, const char* fmt, ...); -extern bool LogInitialise(const std::string& filePath, const std::string& fileRoot, unsigned int fileLevel, unsigned int displayLevel); +extern bool LogInitialise(bool daemon, const std::string& filePath, const std::string& fileRoot, unsigned int fileLevel, unsigned int displayLevel); extern void LogFinalise(); #endif diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index e2a7766..00619e8 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -237,7 +237,7 @@ int CMMDVMHost::run() #endif #endif - ret = ::LogInitialise(m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), m_conf.getLogDisplayLevel()); + ret = ::LogInitialise(m_daemon, m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), m_conf.getLogDisplayLevel()); if (!ret) { ::fprintf(stderr, "MMDVMHost: unable to open the log file\n"); return 1; @@ -247,7 +247,6 @@ int CMMDVMHost::run() if (m_daemon) { ::close(STDIN_FILENO); ::close(STDOUT_FILENO); - ::close(STDERR_FILENO); } #endif diff --git a/RemoteCommand.cpp b/RemoteCommand.cpp index bf3fb1e..fd96e46 100644 --- a/RemoteCommand.cpp +++ b/RemoteCommand.cpp @@ -51,7 +51,7 @@ int main(int argc, char** argv) CRemoteCommand::CRemoteCommand(unsigned int port) : m_port(port) { - ::LogInitialise(".", "RemoteCommand", 2U, 2U); + ::LogInitialise(false, ".", "RemoteCommand", 2U, 2U); } CRemoteCommand::~CRemoteCommand() From 2ae966b7fbb1189ca9f40e75d018bff2b40ef5ba Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Sat, 9 May 2020 12:47:26 +0100 Subject: [PATCH 5/5] Fix for Windows compilation. --- MMDVMHost.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 00619e8..6b17c16 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -237,7 +237,11 @@ int CMMDVMHost::run() #endif #endif +#if !defined(_WIN32) && !defined(_WIN64) ret = ::LogInitialise(m_daemon, m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), m_conf.getLogDisplayLevel()); +#else + ret = ::LogInitialise(false, m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), m_conf.getLogDisplayLevel()); +#endif if (!ret) { ::fprintf(stderr, "MMDVMHost: unable to open the log file\n"); return 1;