From 3b09e2cf2f1988395ae6bca5216446bcfbf80fa5 Mon Sep 17 00:00:00 2001 From: phl0 Date: Wed, 22 Jun 2016 14:13:22 +0200 Subject: [PATCH 1/4] Renamed English to British and added American (MDY) --- Conf.cpp | 4 ++-- HD44780.cpp | 4 +++- MMDVM.ini | 3 ++- Nextion.cpp | 4 +++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index bbbdbf6..a9d0220 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -135,12 +135,12 @@ m_hd44780PWMBright(), m_hd44780PWMDim(), m_hd44780DisplayClock(false), m_hd44780UTC(false), -m_hd44780DateFormat("English"), +m_hd44780DateFormat("British"), m_nextionPort("/dev/ttyAMA0"), m_nextionBrightness(50U), m_nextionDisplayClock(false), m_nextionUTC(false), -m_nextionDateFormat("English"), +m_nextionDateFormat("British"), m_oledType(3), m_oledBrightness(0), m_oledInvert(0) diff --git a/HD44780.cpp b/HD44780.cpp index 6429570..7721ea7 100644 --- a/HD44780.cpp +++ b/HD44780.cpp @@ -735,10 +735,12 @@ void CHD44780::clockInt(unsigned int ms) if (m_cols != 16U && m_rows != 2U) { ::lcdPosition(m_fd, (m_cols - 8) / 2, m_rows == 2 ? 0 : 1); - if (strcmp(m_dateformat.c_str(), "English") == 0) { + if (strcmp(m_dateformat.c_str(), "British") == 0) { ::lcdPrintf(m_fd, "%02d/%02d/%2d", Day, Month, Year%100); } else if (strcmp(m_dateformat.c_str(), "German") == 0) { ::lcdPrintf(m_fd, "%02d.%02d.%2d", Day, Month, Year%100); + } else if (strcmp(m_dateformat.c_str(), "American") == 0) { + ::lcdPrintf(m_fd, "%02d/%02d/%2d", Month, Day, Year%100); } } m_clockDisplayTimer.start(); diff --git a/MMDVM.ini b/MMDVM.ini index 1f74d33..470b5ff 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -118,13 +118,14 @@ PWMBright=100 PWMDim=16 DisplayClock=1 UTC=0 +DateFormat=British [Nextion] Port=/dev/ttyAMA0 Brightness=50 DisplayClock=1 UTC=0 -DateFormat=English +DateFormat=British [OLED] Type=3 diff --git a/Nextion.cpp b/Nextion.cpp index dfe75ca..f3e503d 100644 --- a/Nextion.cpp +++ b/Nextion.cpp @@ -242,10 +242,12 @@ void CNextion::clockInt(unsigned int ms) int Sec = Time->tm_sec; char text[50U]; - if (strcmp(m_dateformat.c_str(), "English") == 0) { + if (strcmp(m_dateformat.c_str(), "British") == 0) { ::sprintf(text, "t2.txt=\"%02d:%02d:%02d %02d/%02d/%2d\"", Hour, Min, Sec, Day, Month, Year % 100); } else if (strcmp(m_dateformat.c_str(), "German") == 0) { ::sprintf(text, "t2.txt=\"%02d:%02d:%02d %02d.%02d.%2d\"", Hour, Min, Sec, Day, Month, Year % 100); + } else if (strcmp(m_dateformat.c_str(), "American") == 0) { + ::sprintf(text, "t2.txt=\"%02d:%02d:%02d %02d/%02d/%2d\"", Hour, Min, Sec, Month, Day, Year % 100); } sendCommand(text); From 10e3a85691f8cb09df2f77f1d9de7406e4133f02 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Wed, 22 Jun 2016 18:03:56 +0100 Subject: [PATCH 2/4] Add seperate RF and Network mode timeouts. --- Conf.cpp | 18 +++++++++--- Conf.h | 6 ++-- MMDVM.ini | 4 ++- MMDVMHost.cpp | 77 ++++++++++++++++++++++++++++++++++----------------- MMDVMHost.h | 3 ++ 5 files changed, 76 insertions(+), 32 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index a9d0220..bef277a 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -51,7 +51,8 @@ m_file(file), m_callsign(), m_timeout(120U), m_duplex(true), -m_modeHang(10U), +m_rfModeHang(10U), +m_netModeHang(3U), m_display(), m_daemon(false), m_rxFrequency(0U), @@ -219,7 +220,11 @@ bool CConf::read() else if (::strcmp(key, "Duplex") == 0) m_duplex = ::atoi(value) == 1; else if (::strcmp(key, "ModeHang") == 0) - m_modeHang = (unsigned int)::atoi(value); + m_rfModeHang = m_netModeHang = (unsigned int)::atoi(value); + else if (::strcmp(key, "RFModeHang") == 0) + m_rfModeHang = (unsigned int)::atoi(value); + else if (::strcmp(key, "NetModeHang") == 0) + m_netModeHang = (unsigned int)::atoi(value); else if (::strcmp(key, "Display") == 0) m_display = value; else if (::strcmp(key, "Daemon") == 0) @@ -498,9 +503,14 @@ bool CConf::getDuplex() const return m_duplex; } -unsigned int CConf::getModeHang() const +unsigned int CConf::getRFModeHang() const { - return m_modeHang; + return m_rfModeHang; +} + +unsigned int CConf::getNetModeHang() const +{ + return m_netModeHang; } std::string CConf::getDisplay() const diff --git a/Conf.h b/Conf.h index 3fb3f19..d15fb7f 100644 --- a/Conf.h +++ b/Conf.h @@ -34,7 +34,8 @@ public: std::string getCallsign() const; unsigned int getTimeout() const; bool getDuplex() const; - unsigned int getModeHang() const; + unsigned int getRFModeHang() const; + unsigned int getNetModeHang() const; std::string getDisplay() const; bool getDaemon() const; @@ -161,7 +162,8 @@ private: std::string m_callsign; unsigned int m_timeout; bool m_duplex; - unsigned int m_modeHang; + unsigned int m_rfModeHang; + unsigned int m_netModeHang; std::string m_display; bool m_daemon; diff --git a/MMDVM.ini b/MMDVM.ini index 470b5ff..12c75f4 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -2,7 +2,9 @@ Callsign=G9BF Timeout=180 Duplex=1 -ModeHang=10 +# ModeHang=10 +RFModeHang=10 +NetModeHang=3 Display=None Daemon=0 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 55a4ff9..8e9918f 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -123,10 +123,13 @@ m_dmrNetwork(NULL), m_ysfNetwork(NULL), m_display(NULL), m_mode(MODE_IDLE), +m_rfModeHang(10U), +m_netModeHang(3U), m_modeTimer(1000U), m_dmrTXTimer(1000U), m_cwIdTimer(1000U), m_duplex(false), +m_timeout(180U), m_dstarEnabled(false), m_dmrEnabled(false), m_ysfEnabled(false), @@ -268,19 +271,16 @@ int CMMDVMHost::run() CDStarControl* dstar = NULL; if (m_dstarEnabled) { std::string module = m_conf.getDStarModule(); - bool selfOnly = m_conf.getDStarSelfOnly(); - unsigned int timeout = m_conf.getTimeout(); + bool selfOnly = m_conf.getDStarSelfOnly(); std::vector blackList = m_conf.getDStarBlackList(); LogInfo("D-Star Parameters"); - LogInfo(" Callsign: %s", m_callsign.c_str()); LogInfo(" Module: %s", module.c_str()); LogInfo(" Self Only: %s", selfOnly ? "yes" : "no"); if (blackList.size() > 0U) LogInfo(" Black List: %u", blackList.size()); - LogInfo(" Timeout: %us", timeout); - dstar = new CDStarControl(m_callsign, module, selfOnly, blackList, m_dstarNetwork, m_display, timeout, m_duplex); + dstar = new CDStarControl(m_callsign, module, selfOnly, blackList, m_dstarNetwork, m_display, m_timeout, m_duplex); } CDMRControl* dmr = NULL; @@ -294,11 +294,18 @@ int CMMDVMHost::run() std::vector dstIDBlackListSlot2 = m_conf.getDMRDstIdBlacklistSlot2(); std::vector dstIDWhiteListSlot1 = m_conf.getDMRDstIdWhitelistSlot1(); std::vector dstIDWhiteListSlot2 = m_conf.getDMRDstIdWhitelistSlot2(); - unsigned int timeout = m_conf.getTimeout(); std::string lookupFile = m_conf.getDMRLookupFile(); unsigned int callHang = m_conf.getDMRCallHang(); unsigned int txHang = m_conf.getDMRTXHang(); + if (txHang > m_rfModeHang) + txHang = m_rfModeHang; + if (txHang > m_netModeHang) + txHang = m_netModeHang; + + if (callHang > txHang) + callHang = txHang; + LogInfo("DMR Parameters"); LogInfo(" Id: %u", id); LogInfo(" Color Code: %u", colorCode); @@ -316,28 +323,18 @@ int CMMDVMHost::run() if (dstIDWhiteListSlot2.size() > 0U) LogInfo(" Slot 2 Destination ID White List: %u entries", dstIDWhiteListSlot2.size()); - LogInfo(" Timeout: %us", timeout); LogInfo(" Lookup File: %s", lookupFile.length() > 0U ? lookupFile.c_str() : "None"); LogInfo(" Call Hang: %us", callHang); LogInfo(" TX Hang: %us", txHang); - dmr = new CDMRControl(id, colorCode, callHang, selfOnly, prefixes, blackList,dstIDBlackListSlot1,dstIDWhiteListSlot1, dstIDBlackListSlot2, dstIDWhiteListSlot2, timeout, m_modem, m_dmrNetwork, m_display, m_duplex, lookupFile); + dmr = new CDMRControl(id, colorCode, callHang, selfOnly, prefixes, blackList,dstIDBlackListSlot1,dstIDWhiteListSlot1, dstIDBlackListSlot2, dstIDWhiteListSlot2, m_timeout, m_modem, m_dmrNetwork, m_display, m_duplex, lookupFile); m_dmrTXTimer.setTimeout(txHang); } CYSFControl* ysf = NULL; - if (m_ysfEnabled) { - unsigned int timeout = m_conf.getTimeout(); - - LogInfo("System Fusion Parameters"); - LogInfo(" Callsign: %s", m_callsign.c_str()); - LogInfo(" Timeout: %us", timeout); - - ysf = new CYSFControl(m_callsign, m_ysfNetwork, m_display, timeout, m_duplex); - } - - m_modeTimer.setTimeout(m_conf.getModeHang()); + if (m_ysfEnabled) + ysf = new CYSFControl(m_callsign, m_ysfNetwork, m_display, m_timeout, m_duplex); setMode(MODE_IDLE); @@ -364,8 +361,10 @@ int CMMDVMHost::run() if (dstar != NULL && len > 0U) { if (m_mode == MODE_IDLE) { bool ret = dstar->writeModem(data); - if (ret) + if (ret) { + m_modeTimer.setTimeout(m_rfModeHang); setMode(MODE_DSTAR); + } } else if (m_mode == MODE_DSTAR) { dstar->writeModem(data); m_modeTimer.start(); @@ -380,10 +379,12 @@ int CMMDVMHost::run() if (m_duplex) { bool ret = dmr->processWakeup(data); if (ret) { + m_modeTimer.setTimeout(m_rfModeHang); setMode(MODE_DMR); dmrBeaconTimer.stop(); } } else { + m_modeTimer.setTimeout(m_rfModeHang); setMode(MODE_DMR); dmr->writeModemSlot1(data); dmrBeaconTimer.stop(); @@ -413,10 +414,12 @@ int CMMDVMHost::run() if (m_duplex) { bool ret = dmr->processWakeup(data); if (ret) { + m_modeTimer.setTimeout(m_rfModeHang); setMode(MODE_DMR); dmrBeaconTimer.stop(); } } else { + m_modeTimer.setTimeout(m_rfModeHang); setMode(MODE_DMR); dmr->writeModemSlot2(data); dmrBeaconTimer.stop(); @@ -444,8 +447,10 @@ int CMMDVMHost::run() if (ysf != NULL && len > 0U) { if (m_mode == MODE_IDLE) { bool ret = ysf->writeModem(data); - if (ret) + if (ret) { + m_modeTimer.setTimeout(m_rfModeHang); setMode(MODE_YSF); + } } else if (m_mode == MODE_YSF) { ysf->writeModem(data); m_modeTimer.start(); @@ -462,8 +467,10 @@ int CMMDVMHost::run() if (ret) { len = dstar->readModem(data); if (len > 0U) { - if (m_mode == MODE_IDLE) + if (m_mode == MODE_IDLE) { + m_modeTimer.setTimeout(m_netModeHang); setMode(MODE_DSTAR); + } if (m_mode == MODE_DSTAR) { m_modem->writeDStarData(data, len); m_modeTimer.start(); @@ -479,8 +486,10 @@ int CMMDVMHost::run() if (ret) { len = dmr->readModemSlot1(data); if (len > 0U) { - if (m_mode == MODE_IDLE) + if (m_mode == MODE_IDLE) { + m_modeTimer.setTimeout(m_netModeHang); setMode(MODE_DMR); + } if (m_mode == MODE_DMR) { if (m_duplex) { m_modem->writeDMRStart(true); @@ -499,8 +508,10 @@ int CMMDVMHost::run() if (ret) { len = dmr->readModemSlot2(data); if (len > 0U) { - if (m_mode == MODE_IDLE) + if (m_mode == MODE_IDLE) { + m_modeTimer.setTimeout(m_netModeHang); setMode(MODE_DMR); + } if (m_mode == MODE_DMR) { if (m_duplex) { m_modem->writeDMRStart(true); @@ -521,8 +532,10 @@ int CMMDVMHost::run() if (ret) { len = ysf->readModem(data); if (len > 0U) { - if (m_mode == MODE_IDLE) + if (m_mode == MODE_IDLE) { + m_modeTimer.setTimeout(m_netModeHang); setMode(MODE_YSF); + } if (m_mode == MODE_YSF) { m_modem->writeYSFData(data, len); m_modeTimer.start(); @@ -810,6 +823,20 @@ void CMMDVMHost::readParams() m_ysfEnabled = m_conf.getFusionEnabled(); m_duplex = m_conf.getDuplex(); m_callsign = m_conf.getCallsign(); + m_timeout = m_conf.getTimeout(); + + m_rfModeHang = m_conf.getRFModeHang(); + m_netModeHang = m_conf.getNetModeHang(); + + LogInfo("General Parameters"); + LogInfo(" Callsign: %s", m_callsign.c_str()); + LogInfo(" Duplex: %s", m_duplex ? "yes" : "no"); + LogInfo(" Timeout: %us", m_timeout); + LogInfo(" RF Mode Hang: %us", m_rfModeHang); + LogInfo(" Net Mode Hang: %us", m_netModeHang); + LogInfo(" D-Star: %s", m_dstarEnabled ? "enabled" : "disabled"); + LogInfo(" DMR: %s", m_dmrEnabled ? "enabled" : "disabled"); + LogInfo(" YSF: %s", m_ysfEnabled ? "enabled" : "disabled"); } void CMMDVMHost::createDisplay() diff --git a/MMDVMHost.h b/MMDVMHost.h index 3f656fd..333780d 100644 --- a/MMDVMHost.h +++ b/MMDVMHost.h @@ -45,10 +45,13 @@ private: CYSFNetwork* m_ysfNetwork; CDisplay* m_display; unsigned char m_mode; + unsigned int m_rfModeHang; + unsigned int m_netModeHang; CTimer m_modeTimer; CTimer m_dmrTXTimer; CTimer m_cwIdTimer; bool m_duplex; + unsigned int m_timeout; bool m_dstarEnabled; bool m_dmrEnabled; bool m_ysfEnabled; From 05e08a232fb42fa79414347d860d3858775fba5f Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Wed, 22 Jun 2016 20:42:14 +0100 Subject: [PATCH 3/4] Keep the SET_CONFIG command unchanged for DVMegas. --- MMDVMHost.cpp | 2 +- Modem.cpp | 13 ++++++++----- Modem.h | 3 ++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 8e9918f..a2854f1 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -686,7 +686,7 @@ bool CMMDVMHost::createModem() LogInfo(" Osc. Offset: %dppm", oscOffset); - m_modem = new CModem(port, rxInvert, txInvert, pttInvert, txDelay, rxLevel, txLevel, dmrDelay, oscOffset, debug); + m_modem = new CModem(port, m_duplex, rxInvert, txInvert, pttInvert, txDelay, rxLevel, txLevel, dmrDelay, oscOffset, debug); m_modem->setModeParams(m_dstarEnabled, m_dmrEnabled, m_ysfEnabled); m_modem->setModeLevels(dstarLevel, dmrLevel1, dmrLevel3, ysfLevel1, ysfLevel3, dmrThreshold, ysfThreshold); m_modem->setRFParams(rxFrequency, txFrequency); diff --git a/Modem.cpp b/Modem.cpp index a317987..0b9971e 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -76,9 +76,10 @@ const unsigned int MAX_RESPONSES = 30U; const unsigned int BUFFER_LENGTH = 500U; -CModem::CModem(const std::string& port, bool rxInvert, bool txInvert, bool pttInvert, unsigned int txDelay, unsigned int rxLevel, unsigned int txLevel, unsigned int dmrDelay, int oscOffset, bool debug) : +CModem::CModem(const std::string& port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, unsigned int txDelay, unsigned int rxLevel, unsigned int txLevel, unsigned int dmrDelay, int oscOffset, bool debug) : m_port(port), m_colorCode(0U), +m_duplex(duplex), m_rxInvert(rxInvert), m_txInvert(txInvert), m_pttInvert(pttInvert), @@ -760,11 +761,13 @@ bool CModem::readStatus() bool CModem::setConfig() { + unsigned int length = m_duplex ? 19U : 12U; + unsigned char buffer[20U]; buffer[0U] = MMDVM_FRAME_START; - buffer[1U] = 19U; + buffer[1U] = length; buffer[2U] = MMDVM_SET_CONFIG; @@ -805,10 +808,10 @@ bool CModem::setConfig() buffer[17U] = (unsigned char)(m_dmrThreshold + 128); buffer[18U] = (unsigned char)(m_ysfThreshold + 128); - // CUtils::dump(1U, "Written", buffer, 19U); + // CUtils::dump(1U, "Written", buffer, length); - int ret = m_serial.write(buffer, 19U); - if (ret != 19) + int ret = m_serial.write(buffer, length); + if (ret != int(length)) return false; unsigned int count = 0U; diff --git a/Modem.h b/Modem.h index 6664832..07300a8 100644 --- a/Modem.h +++ b/Modem.h @@ -33,7 +33,7 @@ enum RESP_TYPE_MMDVM { class CModem { public: - CModem(const std::string& port, bool rxInvert, bool txInvert, bool pttInvert, unsigned int txDelay, unsigned int rxLevel, unsigned int txLevel, unsigned int dmrDelay, int oscOffset, bool debug = false); + CModem(const std::string& port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, unsigned int txDelay, unsigned int rxLevel, unsigned int txLevel, unsigned int dmrDelay, int oscOffset, bool debug = false); ~CModem(); void setRFParams(unsigned int rxFrequency, unsigned int txFrequency); @@ -78,6 +78,7 @@ public: private: std::string m_port; unsigned int m_colorCode; + bool m_duplex; bool m_rxInvert; bool m_txInvert; bool m_pttInvert; From 45bc8c736ec0309bf4a2291133413dee63aeee1a Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Wed, 22 Jun 2016 20:44:28 +0100 Subject: [PATCH 4/4] Do duplicate removal by sequence number always. --- YSFControl.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/YSFControl.cpp b/YSFControl.cpp index 013c32f..3a533f9 100644 --- a/YSFControl.cpp +++ b/YSFControl.cpp @@ -395,8 +395,7 @@ void CYSFControl::writeNetwork() m_netSeqNo = 0U; } else { // Check for duplicate frames, if we can - // XXX this needs changing in the future - if (m_netSeqNo == data[34U] && m_netSeqNo != 0U) { + if (m_netSeqNo == data[34U]) { LogDebug("YSF, removing network duplicate, seq %u", data[34U] >> 1); return; }