From 1ded19c5b2c00490c0f4f16c872e5a926d4f5b9f Mon Sep 17 00:00:00 2001 From: SASANO Takayoshi Date: Sat, 4 Jul 2020 17:58:00 +0900 Subject: [PATCH 1/2] permit inline comment (2) To implement this feature, using strtok() is not enough. This cannot handle this case: Key=#value#comment it will be #value is the contents of Key. And, Key=value #comment (there is a space and a tab between value and #comment) this will be value. Sometimes these trailing spaces and tabs makes thing wrong. Whether in-line comment is used or not, delete trailing space/tab after value. --- Conf.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Conf.cpp b/Conf.cpp index 6602b3c..d2ee258 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -391,8 +391,16 @@ bool CConf::read() value[len - 1U] = '\0'; value++; } else { + char *p; + // if value is not quoted, remove after # (to make comment) - strtok(value, "#"); + if ((p = strchr(value, '#')) != NULL) + *p = '\0'; + + // remove trailing tab/space + for (p = value + strlen(value) - 1; + p >= value && (*p == '\t' || *p == ' '); p--) + *p = '\0'; } if (section == SECTION_GENERAL) { From 3e6d5d5a7f24448a49063ca9bda6413f8076f878 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 13 Jul 2020 16:02:04 +0100 Subject: [PATCH 2/2] Add UseCOSAsLockout and FM Access Mode parameters. --- Conf.cpp | 18 +++++++++++++----- Conf.h | 6 ++++-- MMDVM.ini | 3 ++- MMDVMHost.cpp | 12 +++++++----- Modem.cpp | 42 ++++++++++++++++++++++-------------------- Modem.h | 9 +++++---- NullModem.cpp | 6 +++--- NullModem.h | 4 ++-- Version.h | 2 +- 9 files changed, 59 insertions(+), 43 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index d2ee258..fce38b5 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -112,6 +112,7 @@ m_modemNXDNTXLevel(50.0F), m_modemPOCSAGTXLevel(50.0F), m_modemFMTXLevel(50.0F), m_modemRSSIMappingFile(), +m_modemUseCOSAsLockout(false), m_modemTrace(false), m_modemDebug(false), m_transparentEnabled(false), @@ -200,7 +201,7 @@ m_fmCTCSSLowThreshold(20U), m_fmCTCSSLevel(2.0F), m_fmKerchunkTime(0U), m_fmHangTime(7U), -m_fmUseCOS(true), +m_fmAccessMode(1U), m_fmCOSInvert(false), m_fmRFAudioBoost(1U), m_fmMaxDevLevel(90.0F), @@ -524,6 +525,8 @@ bool CConf::read() m_modemFMTXLevel = float(::atof(value)); else if (::strcmp(key, "RSSIMappingFile") == 0) m_modemRSSIMappingFile = value; + else if (::strcmp(key, "UseCOSAsLockout") == 0) + m_modemUseCOSAsLockout = ::atoi(value) == 1; else if (::strcmp(key, "Trace") == 0) m_modemTrace = ::atoi(value) == 1; else if (::strcmp(key, "Debug") == 0) @@ -777,8 +780,8 @@ bool CConf::read() m_fmKerchunkTime = (unsigned int)::atoi(value); else if (::strcmp(key, "HangTime") == 0) m_fmHangTime = (unsigned int)::atoi(value); - else if (::strcmp(key, "UseCOS") == 0) - m_fmUseCOS = ::atoi(value) == 1; + else if (::strcmp(key, "AccessMode") == 0) + m_fmAccessMode = (unsigned int)::atoi(value); else if (::strcmp(key, "COSInvert") == 0) m_fmCOSInvert = ::atoi(value) == 1; else if (::strcmp(key, "RFAudioBoost") == 0) @@ -1226,6 +1229,11 @@ std::string CConf::getModemRSSIMappingFile () const return m_modemRSSIMappingFile; } +bool CConf::getModemUseCOSAsLockout() const +{ + return m_modemUseCOSAsLockout; +} + bool CConf::getModemTrace() const { return m_modemTrace; @@ -1666,9 +1674,9 @@ unsigned int CConf::getFMHangTime() const return m_fmHangTime; } -bool CConf::getFMUseCOS() const +unsigned int CConf::getFMAccessMode() const { - return m_fmUseCOS; + return m_fmAccessMode; } bool CConf::getFMCOSInvert() const diff --git a/Conf.h b/Conf.h index a4f94eb..2c698df 100644 --- a/Conf.h +++ b/Conf.h @@ -92,6 +92,7 @@ public: float getModemPOCSAGTXLevel() const; float getModemFMTXLevel() const; std::string getModemRSSIMappingFile() const; + bool getModemUseCOSAsLockout() const; bool getModemTrace() const; bool getModemDebug() const; @@ -198,7 +199,7 @@ public: float getFMCTCSSLevel() const; unsigned int getFMKerchunkTime() const; unsigned int getFMHangTime() const; - bool getFMUseCOS() const; + unsigned int getFMAccessMode() const; bool getFMCOSInvert() const; unsigned int getFMRFAudioBoost() const; float getFMMaxDevLevel() const; @@ -372,6 +373,7 @@ private: float m_modemPOCSAGTXLevel; float m_modemFMTXLevel; std::string m_modemRSSIMappingFile; + bool m_modemUseCOSAsLockout; bool m_modemTrace; bool m_modemDebug; @@ -469,7 +471,7 @@ private: float m_fmCTCSSLevel; unsigned int m_fmKerchunkTime; unsigned int m_fmHangTime; - bool m_fmUseCOS; + unsigned int m_fmAccessMode; bool m_fmCOSInvert; unsigned int m_fmRFAudioBoost; float m_fmMaxDevLevel; diff --git a/MMDVM.ini b/MMDVM.ini index fc0e4db..2eed9b9 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -67,6 +67,7 @@ RFLevel=100 # POCSAGTXLevel=50 # FMTXLevel=50 RSSIMappingFile=RSSI.dat +UseCOSAsLockout=0 Trace=0 Debug=0 @@ -169,7 +170,7 @@ CTCSSThreshold=30 CTCSSLevel=20 KerchunkTime=0 HangTime=7 -UseCOS=1 +AccessMode=1 COSInvert=0 RFAudioBoost=1 MaxDevLevel=90 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index b5a8aef..4869818 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -1188,6 +1188,7 @@ bool CMMDVMHost::createModem() int rxDCOffset = m_conf.getModemRXDCOffset(); int txDCOffset = m_conf.getModemTXDCOffset(); float rfLevel = m_conf.getModemRFLevel(); + bool useCOSAsLockout = m_conf.getModemUseCOSAsLockout(); LogInfo("Modem Parameters"); LogInfo(" Port: %s", port.c_str()); @@ -1214,9 +1215,10 @@ bool CMMDVMHost::createModem() LogInfo(" POCSAG TX Level: %.1f%%", pocsagTXLevel); LogInfo(" FM TX Level: %.1f%%", fmTXLevel); LogInfo(" TX Frequency: %uHz (%uHz)", txFrequency, txFrequency + txOffset); + LogInfo(" Use COS as Lockout: %s", useCOSAsLockout ? "yes" : "no"); - m_modem = CModem::createModem(port, m_duplex, rxInvert, txInvert, pttInvert, txDelay, dmrDelay, trace, debug); - m_modem->setSerialParams(protocol,address); + m_modem = CModem::createModem(port, m_duplex, rxInvert, txInvert, pttInvert, txDelay, dmrDelay, useCOSAsLockout, trace, debug); + m_modem->setSerialParams(protocol, address); m_modem->setModeParams(m_dstarEnabled, m_dmrEnabled, m_ysfEnabled, m_p25Enabled, m_nxdnEnabled, m_pocsagEnabled, m_fmEnabled); m_modem->setLevels(rxLevel, cwIdTXLevel, dstarTXLevel, dmrTXLevel, ysfTXLevel, p25TXLevel, nxdnTXLevel, pocsagTXLevel, fmTXLevel); m_modem->setRFParams(rxFrequency, rxOffset, txFrequency, txOffset, txDCOffset, rxDCOffset, rfLevel, pocsagFrequency); @@ -1251,7 +1253,7 @@ bool CMMDVMHost::createModem() float ctcssLevel = m_conf.getFMCTCSSLevel(); unsigned int kerchunkTime = m_conf.getFMKerchunkTime(); unsigned int hangTime = m_conf.getFMHangTime(); - bool useCOS = m_conf.getFMUseCOS(); + unsigned int accessMode = m_conf.getFMAccessMode(); bool cosInvert = m_conf.getFMCOSInvert(); unsigned int rfAudioBoost = m_conf.getFMRFAudioBoost(); float maxDevLevel = m_conf.getFMMaxDevLevel(); @@ -1283,7 +1285,7 @@ bool CMMDVMHost::createModem() LogInfo(" CTCSS Level: %.1f%%", ctcssLevel); LogInfo(" Kerchunk Time: %us", kerchunkTime); LogInfo(" Hang Time: %us", hangTime); - LogInfo(" Use COS: %s", useCOS ? "yes" : "no"); + LogInfo(" Access Mode: %u", accessMode); LogInfo(" COS Invert: %s", cosInvert ? "yes" : "no"); LogInfo(" RF Audio Boost: x%u", rfAudioBoost); LogInfo(" Max. Deviation Level: %.1f%%", maxDevLevel); @@ -1291,7 +1293,7 @@ bool CMMDVMHost::createModem() 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, ctcssHighThreshold, ctcssLowThreshold, ctcssLevel, kerchunkTime, hangTime, useCOS, cosInvert, rfAudioBoost, maxDevLevel); + m_modem->setFMMiscParams(timeout, timeoutLevel, ctcssFrequency, ctcssHighThreshold, ctcssLowThreshold, ctcssLevel, kerchunkTime, hangTime, accessMode, cosInvert, rfAudioBoost, maxDevLevel); } bool ret = m_modem->open(); diff --git a/Modem.cpp b/Modem.cpp index 93319be..b7ed505 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -99,7 +99,7 @@ const unsigned int MAX_RESPONSES = 30U; const unsigned int BUFFER_LENGTH = 2000U; -CModem::CModem(const std::string& port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, unsigned int txDelay, unsigned int dmrDelay, bool trace, bool debug) : +CModem::CModem(const std::string& port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, unsigned int txDelay, unsigned int dmrDelay, bool useCOSAsLockout, bool trace, bool debug) : m_port(port), m_dmrColorCode(0U), m_ysfLoDev(false), @@ -112,15 +112,17 @@ m_txInvert(txInvert), m_pttInvert(pttInvert), m_txDelay(txDelay), m_dmrDelay(dmrDelay), -m_rxLevel(0U), -m_cwIdTXLevel(0U), -m_dstarTXLevel(0U), -m_dmrTXLevel(0U), -m_ysfTXLevel(0U), -m_p25TXLevel(0U), -m_nxdnTXLevel(0U), -m_pocsagTXLevel(0U), -m_fmTXLevel(0U), +m_rxLevel(0.0F), +m_cwIdTXLevel(0.0F), +m_dstarTXLevel(0.0F), +m_dmrTXLevel(0.0F), +m_ysfTXLevel(0.0F), +m_p25TXLevel(0.0F), +m_nxdnTXLevel(0.0F), +m_pocsagTXLevel(0.0F), +m_fmTXLevel(0.0F), +m_rfLevel(0.0F), +m_useCOSAsLockout(useCOSAsLockout), m_trace(trace), m_debug(debug), m_rxFrequency(0U), @@ -195,7 +197,7 @@ m_fmCtcssLowThreshold(20U), m_fmCtcssLevel(10.0F), m_fmKerchunkTime(0U), m_fmHangTime(5U), -m_fmUseCOS(true), +m_fmAccessMode(1U), m_fmCOSInvert(false), m_fmRFAudioBoost(1U), m_fmMaxDevLevel(90.0F) @@ -1534,6 +1536,8 @@ bool CModem::setConfig() buffer[3U] |= 0x08U; if (m_debug) buffer[3U] |= 0x10U; + if (m_useCOSAsLockout) + buffer[3U] |= 0x20U; if (!m_duplex) buffer[3U] |= 0x80U; @@ -1930,7 +1934,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 ctcssHighThreshold, unsigned int ctcssLowThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, bool cosInvert, unsigned int rfAudioBoost, float maxDevLevel) +void CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssHighThreshold, unsigned int ctcssLowThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, unsigned int accessMode, bool cosInvert, unsigned int rfAudioBoost, float maxDevLevel) { m_fmTimeout = timeout; m_fmTimeoutLevel = timeoutLevel; @@ -1943,7 +1947,7 @@ void CModem::setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctc m_fmKerchunkTime = kerchunkTime; m_fmHangTime = hangTime; - m_fmUseCOS = useCOS; + m_fmAccessMode = accessMode; m_fmCOSInvert = cosInvert; m_fmRFAudioBoost = rfAudioBoost; @@ -2084,11 +2088,9 @@ bool CModem::setFMMiscParams() buffer[9U] = m_fmKerchunkTime; buffer[10U] = m_fmHangTime; - buffer[11U] = 0x00U; - if (m_fmUseCOS) - buffer[11U] |= 0x01U; + buffer[11U] = m_fmAccessMode; if (m_fmCOSInvert) - buffer[11U] |= 0x02U; + buffer[11U] |= 0x80U; buffer[12U] = m_fmRFAudioBoost; @@ -2152,9 +2154,9 @@ void CModem::printDebug() } } -CModem* CModem::createModem(const std::string& port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, unsigned int txDelay, unsigned int dmrDelay, bool trace, bool debug){ +CModem* CModem::createModem(const std::string& port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, unsigned int txDelay, unsigned int dmrDelay, bool useCOSAsLockout, bool trace, bool debug){ if (port == "NullModem") - return new CNullModem(port, duplex, rxInvert, txInvert, pttInvert, txDelay, dmrDelay, trace, debug); + return new CNullModem(port, duplex, rxInvert, txInvert, pttInvert, txDelay, dmrDelay, useCOSAsLockout, trace, debug); else - return new CModem(port, duplex, rxInvert, txInvert, pttInvert, txDelay, dmrDelay, trace, debug); + return new CModem(port, duplex, rxInvert, txInvert, pttInvert, txDelay, dmrDelay, useCOSAsLockout, trace, debug); } diff --git a/Modem.h b/Modem.h index 069fe46..62ae25f 100644 --- a/Modem.h +++ b/Modem.h @@ -34,7 +34,7 @@ enum RESP_TYPE_MMDVM { class CModem { public: - CModem(const std::string& port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, unsigned int txDelay, unsigned int dmrDelay, bool trace, bool debug); + CModem(const std::string& port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, unsigned int txDelay, unsigned int dmrDelay, bool useCOSAsLockout, bool trace, bool debug); virtual ~CModem(); virtual void setSerialParams(const std::string& protocol, unsigned int address); @@ -49,7 +49,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 ctcssHighThreshold, unsigned int ctcssLowThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, bool useCOS, bool cosInvert, unsigned int rfAudioBoost, float maxDevLevel); + virtual void setFMMiscParams(unsigned int timeout, float timeoutLevel, float ctcssFrequency, unsigned int ctcssHighThreshold, unsigned int ctcssLowThreshold, float ctcssLevel, unsigned int kerchunkTime, unsigned int hangTime, unsigned int accessMode, bool cosInvert, unsigned int rfAudioBoost, float maxDevLevel); virtual bool open(); @@ -113,7 +113,7 @@ public: virtual void close(); - static CModem* createModem(const std::string& port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, unsigned int txDelay, unsigned int dmrDelay, bool trace, bool debug); + static CModem* createModem(const std::string& port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, unsigned int txDelay, unsigned int dmrDelay, bool useCOSAsLockout, bool trace, bool debug); private: std::string m_port; @@ -138,6 +138,7 @@ private: float m_pocsagTXLevel; float m_fmTXLevel; float m_rfLevel; + bool m_useCOSAsLockout; bool m_trace; bool m_debug; unsigned int m_rxFrequency; @@ -213,7 +214,7 @@ private: float m_fmCtcssLevel; unsigned int m_fmKerchunkTime; unsigned int m_fmHangTime; - bool m_fmUseCOS; + unsigned int m_fmAccessMode; bool m_fmCOSInvert; unsigned int m_fmRFAudioBoost; float m_fmMaxDevLevel; diff --git a/NullModem.cpp b/NullModem.cpp index 8539f1b..f60e500 100644 --- a/NullModem.cpp +++ b/NullModem.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011-2018 by Jonathan Naylor G4KLX + * Copyright (C) 2011-2018,2020 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,8 +19,8 @@ #include "NullModem.h" #include "Log.h" -CNullModem::CNullModem(const std::string& port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, unsigned int txDelay, unsigned int dmrDelay, bool trace, bool debug) : -CModem(port, duplex,rxInvert, txInvert,pttInvert,txDelay, dmrDelay, trace, debug), +CNullModem::CNullModem(const std::string& port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, unsigned int txDelay, unsigned int dmrDelay, bool useCOSAsLockout, bool trace, bool debug) : +CModem(port, duplex,rxInvert, txInvert,pttInvert,txDelay, dmrDelay, useCOSAsLockout, trace, debug), m_hwType(HWT_MMDVM) { } diff --git a/NullModem.h b/NullModem.h index a7ec68f..b6bd80f 100644 --- a/NullModem.h +++ b/NullModem.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011-2018 by Jonathan Naylor G4KLX + * Copyright (C) 2011-2018,2020 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,7 +27,7 @@ class CNullModem : public CModem { public: - CNullModem(const std::string& port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, unsigned int txDelay, unsigned int dmrDelay, bool trace, bool debug); + CNullModem(const std::string& port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, unsigned int txDelay, unsigned int dmrDelay, bool useCOSAsLockout, bool trace, bool debug); virtual ~CNullModem(); virtual void setSerialParams(const std::string& protocol, unsigned int address){}; diff --git a/Version.h b/Version.h index bb444d2..874077c 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200630"; +const char* VERSION = "20200713"; #endif