From 325b30d30b1111566c22cf107ed34fe3a689f79c Mon Sep 17 00:00:00 2001 From: Kimi Jin Date: Wed, 24 Jun 2020 13:33:23 +0800 Subject: [PATCH 01/14] Add install rules into Makefile. This will insatll MMDVMHost and RemoteCommand to /usr/local/bin/ path, so need exec with command 'sudo make install'. --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index e14f51c..984a3dc 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,10 @@ RemoteCommand: Log.o RemoteCommand.o UDPSocket.o %.o: %.cpp $(CXX) $(CFLAGS) -c -o $@ $< +install: + install -m 755 MMDVMHost /usr/local/bin/ + install -m 755 RemoteCommand /usr/local/bin/ + clean: $(RM) MMDVMHost RemoteCommand *.o *.d *.bak *~ GitVersion.h From 1dc91b9a6459acf59f378589f13a8bec0b2c5d7f Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Thu, 25 Jun 2020 09:55:28 +0100 Subject: [PATCH 02/14] Add the install target to the other makefiles. --- Makefile.Pi | 4 ++++ Makefile.Pi.Adafruit | 4 ++++ Makefile.Pi.HD44780 | 4 ++++ Makefile.Pi.OLED | 4 ++++ Makefile.Pi.PCF8574 | 4 ++++ Makefile.Solaris | 39 --------------------------------------- 6 files changed, 20 insertions(+), 39 deletions(-) delete mode 100644 Makefile.Solaris diff --git a/Makefile.Pi b/Makefile.Pi index d9c1acd..5a1334b 100644 --- a/Makefile.Pi +++ b/Makefile.Pi @@ -27,6 +27,10 @@ RemoteCommand: Log.o RemoteCommand.o UDPSocket.o %.o: %.cpp $(CXX) $(CFLAGS) -c -o $@ $< +install: + install -m 755 MMDVMHost /usr/local/bin/ + install -m 755 RemoteCommand /usr/local/bin/ + clean: $(RM) MMDVMHost RemoteCommand *.o *.d *.bak *~ GitVersion.h diff --git a/Makefile.Pi.Adafruit b/Makefile.Pi.Adafruit index a9c0b35..fbeaf80 100644 --- a/Makefile.Pi.Adafruit +++ b/Makefile.Pi.Adafruit @@ -28,6 +28,10 @@ RemoteCommand: Log.o RemoteCommand.o UDPSocket.o %.o: %.cpp $(CXX) $(CFLAGS) -c -o $@ $< +install: + install -m 755 MMDVMHost /usr/local/bin/ + install -m 755 RemoteCommand /usr/local/bin/ + clean: $(RM) MMDVMHost RemoteCommand *.o *.d *.bak *~ GitVersion.h diff --git a/Makefile.Pi.HD44780 b/Makefile.Pi.HD44780 index a0127af..02ff78d 100644 --- a/Makefile.Pi.HD44780 +++ b/Makefile.Pi.HD44780 @@ -27,6 +27,10 @@ RemoteCommand: Log.o RemoteCommand.o UDPSocket.o %.o: %.cpp $(CXX) $(CFLAGS) -c -o $@ $< +install: + install -m 755 MMDVMHost /usr/local/bin/ + install -m 755 RemoteCommand /usr/local/bin/ + clean: $(RM) MMDVMHost RemoteCommand *.o *.d *.bak *~ GitVersion.h diff --git a/Makefile.Pi.OLED b/Makefile.Pi.OLED index 5629489..387a0a7 100644 --- a/Makefile.Pi.OLED +++ b/Makefile.Pi.OLED @@ -27,6 +27,10 @@ RemoteCommand: Log.o RemoteCommand.o UDPSocket.o %.o: %.cpp $(CXX) $(CFLAGS) -c -o $@ $< +install: + install -m 755 MMDVMHost /usr/local/bin/ + install -m 755 RemoteCommand /usr/local/bin/ + clean: $(RM) MMDVMHost RemoteCommand *.o *.d *.bak *~ GitVersion.h diff --git a/Makefile.Pi.PCF8574 b/Makefile.Pi.PCF8574 index cd6b67f..5ac5b48 100644 --- a/Makefile.Pi.PCF8574 +++ b/Makefile.Pi.PCF8574 @@ -28,6 +28,10 @@ RemoteCommand: Log.o RemoteCommand.o UDPSocket.o %.o: %.cpp $(CXX) $(CFLAGS) -c -o $@ $< +install: + install -m 755 MMDVMHost /usr/local/bin/ + install -m 755 RemoteCommand /usr/local/bin/ + clean: $(RM) MMDVMHost RemoteCommand *.o *.d *.bak *~ GitVersion.h diff --git a/Makefile.Solaris b/Makefile.Solaris deleted file mode 100644 index 4d46985..0000000 --- a/Makefile.Solaris +++ /dev/null @@ -1,39 +0,0 @@ -# This makefile is for Solaris using gcc - -CC = gcc -CXX = g++ -CFLAGS = -g -O3 -Wall -std=c++0x -pthread -LIBS = -lpthread -lsocket -LDFLAGS = -g - -OBJECTS = \ - AMBEFEC.o BCH.o BPTC19696.o CASTInfo.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedData.o DMRFullLC.o \ - DMRLookup.o DMRLC.o DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTA.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o \ - DStarSlowData.o Golay2087.o Golay24128.o Hamming.o LCDproc.o Log.o MMDVMHost.o MobileGPS.o Modem.o ModemSerialPort.o Mutex.o NetworkInfo.o Nextion.o \ - NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o NXDNIcomNetwork.o NXDNKenwoodNetwork.o NXDNLayer3.o \ - NXDNLICH.o NXDNLookup.o NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o P25NID.o P25Trellis.o \ - P25Utils.o POCSAGControl.o POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialController.o SerialPort.o SHA256.o \ - StopWatch.o Sync.o TFTSerial.o TFTSurenoo.o Thread.o Timer.o UDPSocket.o UMP.o UserDB.o UserDBebtry.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o \ - YSFNetwork.o YSFPayload.o - -all: MMDVMHost RemoteCommand - -MMDVMHost: GitVersion.h $(OBJECTS) - $(CXX) $(OBJECTS) $(CFLAGS) $(LIBS) -o MMDVMHost - -RemoteCommand: Log.o RemoteCommand.o UDPSocket.o - $(CXX) Log.o RemoteCommand.o UDPSocket.o $(CFLAGS) $(LIBS) -o RemoteCommand - -%.o: %.cpp - $(CXX) $(CFLAGS) -c -o $@ $< - -clean: - $(RM) MMDVMHost RemoteCommand *.o *.d *.bak *~ GitVersion.h - -# Export the current git version if the index file exists, else 000... -GitVersion.h: -ifneq ("$(wildcard .git/index)","") - echo "const char *gitversion = \"$(shell git rev-parse HEAD)\";" > $@ -else - echo "const char *gitversion = \"0000000000000000000000000000000000000000\";" > $@ -endif From edce66701894d48424a0512bb9f4a20d89a8d9bc Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 29 Jun 2020 11:25:10 +0100 Subject: [PATCH 03/14] Replace MobileGPS with gpsd. --- Conf.cpp | 32 ++++++------- Conf.h | 14 +++--- GPSD.cpp | 104 ++++++++++++++++++++++++++++++++++++++++++ MobileGPS.h => GPSD.h | 42 +++++++---------- MMDVM.ini | 4 +- MMDVMHost.cpp | 42 ++++++++++------- MMDVMHost.h | 6 ++- Makefile | 9 +++- Makefile.Pi | 8 +++- Makefile.Pi.Adafruit | 8 +++- Makefile.Pi.HD44780 | 9 +++- Makefile.Pi.OLED | 9 +++- Makefile.Pi.PCF8574 | 9 +++- MobileGPS.cpp | 101 ---------------------------------------- Version.h | 2 +- 15 files changed, 222 insertions(+), 177 deletions(-) create mode 100644 GPSD.cpp rename MobileGPS.h => GPSD.h (60%) delete mode 100644 MobileGPS.cpp diff --git a/Conf.cpp b/Conf.cpp index 8d61b30..5bc7dba 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -57,7 +57,7 @@ enum SECTION { SECTION_OLED, SECTION_LCDPROC, SECTION_LOCK_FILE, - SECTION_MOBILE_GPS, + SECTION_GPSD, SECTION_REMOTE_CONTROL }; @@ -283,9 +283,9 @@ m_lcdprocUTC(false), m_lcdprocDimOnIdle(false), m_lockFileEnabled(false), m_lockFileName(), -m_mobileGPSEnabled(false), -m_mobileGPSAddress(), -m_mobileGPSPort(0U), +m_gpsdEnabled(false), +m_gpsdAddress(), +m_gpsdPort(), m_remoteControlEnabled(false), m_remoteControlPort(0U) { @@ -367,8 +367,8 @@ bool CConf::read() section = SECTION_LCDPROC; else if (::strncmp(buffer, "[Lock File]", 11U) == 0) section = SECTION_LOCK_FILE; - else if (::strncmp(buffer, "[Mobile GPS]", 12U) == 0) - section = SECTION_MOBILE_GPS; + else if (::strncmp(buffer, "[GPSD]", 6U) == 0) + section = SECTION_GPSD; else if (::strncmp(buffer, "[Remote Control]", 16U) == 0) section = SECTION_REMOTE_CONTROL; else @@ -950,13 +950,13 @@ bool CConf::read() m_lockFileEnabled = ::atoi(value) == 1; else if (::strcmp(key, "File") == 0) m_lockFileName = value; - } else if (section == SECTION_MOBILE_GPS) { + } else if (section == SECTION_GPSD) { if (::strcmp(key, "Enable") == 0) - m_mobileGPSEnabled = ::atoi(value) == 1; + m_gpsdEnabled = ::atoi(value) == 1; else if (::strcmp(key, "Address") == 0) - m_mobileGPSAddress = value; + m_gpsdAddress = value; else if (::strcmp(key, "Port") == 0) - m_mobileGPSPort = (unsigned int)::atoi(value); + m_gpsdPort = value; } else if (section == SECTION_REMOTE_CONTROL) { if (::strcmp(key, "Enable") == 0) m_remoteControlEnabled = ::atoi(value) == 1; @@ -2071,19 +2071,19 @@ std::string CConf::getLockFileName() const return m_lockFileName; } -bool CConf::getMobileGPSEnabled() const +bool CConf::getGPSDEnabled() const { - return m_mobileGPSEnabled; + return m_gpsdEnabled; } -std::string CConf::getMobileGPSAddress() const +std::string CConf::getGPSDAddress() const { - return m_mobileGPSAddress; + return m_gpsdAddress; } -unsigned int CConf::getMobileGPSPort() const +std::string CConf::getGPSDPort() const { - return m_mobileGPSPort; + return m_gpsdPort; } bool CConf::getRemoteControlEnabled() const diff --git a/Conf.h b/Conf.h index 77cff6c..a4f94eb 100644 --- a/Conf.h +++ b/Conf.h @@ -306,10 +306,10 @@ public: bool getLockFileEnabled() const; std::string getLockFileName() const; - // The Mobile GPS section - bool getMobileGPSEnabled() const; - std::string getMobileGPSAddress() const; - unsigned int getMobileGPSPort() const; + // The GPSD section + bool getGPSDEnabled() const; + std::string getGPSDAddress() const; + std::string getGPSDPort() const; // The Remote Control section bool getRemoteControlEnabled() const; @@ -565,9 +565,9 @@ private: bool m_lockFileEnabled; std::string m_lockFileName; - bool m_mobileGPSEnabled; - std::string m_mobileGPSAddress; - unsigned int m_mobileGPSPort; + bool m_gpsdEnabled; + std::string m_gpsdAddress; + std::string m_gpsdPort; bool m_remoteControlEnabled; unsigned int m_remoteControlPort; diff --git a/GPSD.cpp b/GPSD.cpp new file mode 100644 index 0000000..aec42f0 --- /dev/null +++ b/GPSD.cpp @@ -0,0 +1,104 @@ +/* + * Copyright (C) 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "GPSD.h" + +#if defined(USE_GPS) + +#include +#include +#include +#include + +CGPSD::CGPSD(const std::string& address, const std::string& port, CDMRNetwork* network) : +m_gpsdAddress(address), +m_gpsdPort(port), +m_network(network), +m_gpsdData(), +m_idTimer(1000U, 60U) +{ + assert(!address.empty()); + assert(!port.empty()); + assert(network != NULL); +} + +CGPSD::~CGPSD() +{ +} + +bool CGPSD::open() +{ + int ret = ::gps_open(m_gpsdAddress.c_str(), m_gpsdPort.c_str(), &m_gpsdData); + if (ret != 0) { + LogError("Error when opening access to gpsd - %d - %s", errno, ::gps_errstr(errno)); + return false; + } + + ::gps_stream(&m_gpsdData, WATCH_ENABLE | WATCH_JSON, NULL); + + LogMessage("Connected to GPSD"); + + m_idTimer.start(); + + return true; +} + +void CGPSD::clock(unsigned int ms) +{ + m_idTimer.clock(ms); + + if (m_idTimer.hasExpired()) { + sendReport(); + m_idTimer.start(); + } +} + +void CGPSD::close() +{ + ::gps_stream(&m_gpsdData, WATCH_DISABLE, NULL); + ::gps_close(&m_gpsdData); +} + +void CGPSD::sendReport() +{ + if (!::gps_waiting(&m_gpsdData, 0)) + return; + +#if GPSD_API_MAJOR_VERSION >= 7 + if (::gps_read(&m_gpsdData, NULL, 0) <= 0) + return; +#else + if (::gps_read(&m_gpsdData) <= 0) + return; +#endif + + if (m_gpsdData.status != STATUS_FIX) + return; + + bool latlonSet = (m_gpsdData.set & LATLON_SET) == LATLON_SET; + if (!latlonSet) + return; + + float latitude = float(m_gpsdData.fix.latitude); + float longitude = float(m_gpsdData.fix.longitude); + + m_network->writeHomePosition(latitude, longitude); +} + +#endif + diff --git a/MobileGPS.h b/GPSD.h similarity index 60% rename from MobileGPS.h rename to GPSD.h index 8d69572..d8838db 100644 --- a/MobileGPS.h +++ b/GPSD.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 by Jonathan Naylor G4KLX + * Copyright (C) 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 @@ -16,32 +16,22 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifndef MobileGPS_H -#define MobileGPS_H +#ifndef GPSD_H +#define GPSD_H + +#if defined(USE_GPS) #include "DMRNetwork.h" -#include "UDPSocket.h" #include "Timer.h" #include -#if !defined(_WIN32) && !defined(_WIN64) -#include -#include -#include -#include -#include -#include -#include -#include -#else -#include -#endif +#include -class CMobileGPS { +class CGPSD { public: - CMobileGPS(const std::string& address, unsigned int port, CDMRNetwork* network); - ~CMobileGPS(); + CGPSD(const std::string& address, const std::string& port, CDMRNetwork* network); + ~CGPSD(); bool open(); @@ -50,14 +40,16 @@ public: void close(); private: - CTimer m_idTimer; - in_addr m_address; - unsigned int m_port; - CUDPSocket m_socket; - CDMRNetwork* m_network; + std::string m_gpsdAddress; + std::string m_gpsdPort; + CDMRNetwork* m_network; + struct gps_data_t m_gpsdData; + CTimer m_idTimer; - bool pollGPS(); void sendReport(); }; #endif + +#endif + diff --git a/MMDVM.ini b/MMDVM.ini index 9b02e83..fc0e4db 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -288,10 +288,10 @@ UTC=0 Enable=0 File=/tmp/MMDVM_Active.lck -[Mobile GPS] +[GPSD] Enable=0 Address=127.0.0.1 -Port=7834 +Port=2947 [Remote Control] Enable=0 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 8cbf318..b736a42 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -161,7 +161,9 @@ m_id(0U), m_cwCallsign(), m_lockFileEnabled(false), m_lockFileName(), -m_mobileGPS(NULL), +#if defined(USE_GPS) +m_gpsd(NULL), +#endif m_remoteControl(NULL), m_fixedMode(false) { @@ -1004,8 +1006,10 @@ int CMMDVMHost::run() if (m_pocsagNetwork != NULL) m_pocsagNetwork->clock(ms); - if (m_mobileGPS != NULL) - m_mobileGPS->clock(ms); +#if defined(USE_GPS) + if (m_gpsd != NULL) + m_gpsd->clock(ms); +#endif m_cwIdTimer.clock(ms); if (m_cwIdTimer.isRunning() && m_cwIdTimer.hasExpired()) { @@ -1082,10 +1086,12 @@ int CMMDVMHost::run() m_display->close(); delete m_display; - if (m_mobileGPS != NULL) { - m_mobileGPS->close(); - delete m_mobileGPS; +#if defined(USE_GPS) + if (m_gpsd != NULL) { + m_gpsd->close(); + delete m_gpsd; } +#endif if (m_ump != NULL) { m_ump->close(); @@ -1392,23 +1398,25 @@ bool CMMDVMHost::createDMRNetwork() return false; } - bool mobileGPSEnabled = m_conf.getMobileGPSEnabled(); - if (mobileGPSEnabled) { - std::string mobileGPSAddress = m_conf.getMobileGPSAddress(); - unsigned int mobileGPSPort = m_conf.getMobileGPSPort(); +#if defined(USE_GPS) + bool gpsdEnabled = m_conf.getGPSDEnabled(); + if (gpsdEnabled) { + std::string gpsdAddress = m_conf.getGPSDAddress(); + std::string gpsdPort = m_conf.getGPSDPort(); - LogInfo("Mobile GPS Parameters"); - LogInfo(" Address: %s", mobileGPSAddress.c_str()); - LogInfo(" Port: %u", mobileGPSPort); + LogInfo("GPSD Parameters"); + LogInfo(" Address: %s", gpsdAddress.c_str()); + LogInfo(" Port: %s", gpsdPort.c_str()); - m_mobileGPS = new CMobileGPS(address, port, m_dmrNetwork); + m_gpsd = new CGPSD(gpsdAddress, gpsdPort, m_dmrNetwork); - ret = m_mobileGPS->open(); + ret = m_gpsd->open(); if (!ret) { - delete m_mobileGPS; - m_mobileGPS = NULL; + delete m_gpsd; + m_gpsd = NULL; } } +#endif m_dmrNetwork->enable(true); diff --git a/MMDVMHost.h b/MMDVMHost.h index 6b1e078..4e2b039 100644 --- a/MMDVMHost.h +++ b/MMDVMHost.h @@ -34,11 +34,11 @@ #include "P25Network.h" #include "DMRNetwork.h" #include "DMRLookup.h" -#include "MobileGPS.h" #include "Display.h" #include "Timer.h" #include "Modem.h" #include "Conf.h" +#include "GPSD.h" #include "UMP.h" #include @@ -102,7 +102,9 @@ private: std::string m_cwCallsign; bool m_lockFileEnabled; std::string m_lockFileName; - CMobileGPS* m_mobileGPS; +#if defined(USE_GPS) + CGPSD* m_gpsd; +#endif CRemoteControl* m_remoteControl; bool m_fixedMode; diff --git a/Makefile b/Makefile index 984a3dc..029f36e 100644 --- a/Makefile +++ b/Makefile @@ -2,14 +2,21 @@ CC = cc CXX = c++ + +# Use the following CFLAGS and LIBS if you don't want to use gpsd. CFLAGS = -g -O3 -Wall -std=c++0x -pthread LIBS = -lpthread + +# Use the following CFLAGS and LIBS if you do want to use gpsd. +#CFLAGS = -g -O3 -Wall -DUSE_GPS -std=c++0x -pthread +#LIBS = -lpthread -lgps + LDFLAGS = -g OBJECTS = \ AMBEFEC.o BCH.o BPTC19696.o CASTInfo.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedData.o DMRFullLC.o \ DMRLookup.o DMRLC.o DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTA.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o \ - DStarSlowData.o Golay2087.o Golay24128.o Hamming.o I2CController.o LCDproc.o Log.o MMDVMHost.o MobileGPS.o Modem.o ModemSerialPort.o Mutex.o \ + DStarSlowData.o Golay2087.o Golay24128.o GPSD.o Hamming.o I2CController.o LCDproc.o Log.o MMDVMHost.o Modem.o ModemSerialPort.o Mutex.o \ NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o NXDNIcomNetwork.o \ NXDNKenwoodNetwork.o NXDNLayer3.o NXDNLICH.o NXDNLookup.o NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o \ P25Network.o P25NID.o P25Trellis.o P25Utils.o POCSAGControl.o POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o \ diff --git a/Makefile.Pi b/Makefile.Pi index 5a1334b..24650a3 100644 --- a/Makefile.Pi +++ b/Makefile.Pi @@ -2,14 +2,20 @@ CC = gcc CXX = g++ +# Use the following CFLAGS and LIBS if you don't want to use gpsd. CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DRASPBERRY_PI -I/usr/local/include LIBS = -lwiringPi -lwiringPiDev -lpthread + +# Use the following CFLAGS and LIBS if you do want to use gpsd. +#CFLAGS = -g -O3 -Wall -DUSE_GPS -std=c++0x -pthread -DRASPBERRY_PI -I/usr/local/include +#LIBS = -lwiringPi -lwiringPiDev -lpthread -lgps + LDFLAGS = -g -L/usr/local/lib OBJECTS = \ AMBEFEC.o BCH.o BPTC19696.o CASTInfo.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedData.o DMRFullLC.o \ DMRLookup.o DMRLC.o DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTA.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o \ - DStarSlowData.o Golay2087.o Golay24128.o Hamming.o I2CController.o LCDproc.o Log.o MMDVMHost.o MobileGPS.o Modem.o ModemSerialPort.o Mutex.o \ + DStarSlowData.o Golay2087.o Golay24128.o GPSD.o Hamming.o I2CController.o LCDproc.o Log.o MMDVMHost.o Modem.o ModemSerialPort.o Mutex.o \ NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o NXDNIcomNetwork.o NXDNKenwoodNetwork.o \ NXDNLayer3.o NXDNLICH.o NXDNLookup.o NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o P25NID.o \ P25Trellis.o P25Utils.o POCSAGControl.o POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialController.o SerialPort.o \ diff --git a/Makefile.Pi.Adafruit b/Makefile.Pi.Adafruit index fbeaf80..c273ce5 100644 --- a/Makefile.Pi.Adafruit +++ b/Makefile.Pi.Adafruit @@ -3,14 +3,20 @@ CC = gcc CXX = g++ +# Use the following CFLAGS and LIBS if you don't want to use gpsd. CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DHD44780 -DADAFRUIT_DISPLAY -I/usr/local/include LIBS = -lwiringPi -lwiringPiDev -lpthread + +# Use the following CFLAGS and LIBS if you do want to use gpsd. +#CFLAGS = -g -O3 -Wall -DUSE_GPS -std=c++0x -pthread -DHD44780 -DADAFRUIT_DISPLAY -I/usr/local/include +#LIBS = -lwiringPi -lwiringPiDev -lpthread -lgps + LDFLAGS = -g -L/usr/local/lib OBJECTS = \ AMBEFEC.o BCH.o BPTC19696.o CASTInfo.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedData.o DMRFullLC.o \ DMRLookup.o DMRLC.o DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTA.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o \ - DStarSlowData.o Golay2087.o Golay24128.o Hamming.o HD44780.o I2CController.o LCDproc.o Log.o MMDVMHost.o MobileGPS.o Modem.o ModemSerialPort.o Mutex.o \ + DStarSlowData.o Golay2087.o Golay24128.o GPSD.o Hamming.o HD44780.o I2CController.o LCDproc.o Log.o MMDVMHost.o Modem.o ModemSerialPort.o Mutex.o \ NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o NXDNIcomNetwork.o NXDNKenwoodNetwork.o \ NXDNLayer3.o NXDNLICH.o NXDNLookup.o NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o P25NID.o \ P25Trellis.o P25Utils.o POCSAGControl.o POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialController.o SerialPort.o \ diff --git a/Makefile.Pi.HD44780 b/Makefile.Pi.HD44780 index 02ff78d..eccc3cc 100644 --- a/Makefile.Pi.HD44780 +++ b/Makefile.Pi.HD44780 @@ -2,14 +2,21 @@ CC = gcc CXX = g++ + +# Use the following CFLAGS and LIBS if you don't want to use gpsd. CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DHD44780 -I/usr/local/include LIBS = -lwiringPi -lwiringPiDev -lpthread + +# Use the following CFLAGS and LIBS if you do want to use gpsd. +#CFLAGS = -g -O3 -Wall -DUSE_GPS -std=c++0x -pthread -DHD44780 -I/usr/local/include +#LIBS = -lwiringPi -lwiringPiDev -lpthread -lgps + LDFLAGS = -g -L/usr/local/lib OBJECTS = \ AMBEFEC.o BCH.o BPTC19696.o CASTInfo.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedData.o DMRFullLC.o \ DMRLookup.o DMRLC.o DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTA.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o \ - DStarSlowData.o Golay2087.o Golay24128.o Hamming.o HD44780.o I2CController.o LCDproc.o Log.o MMDVMHost.o MobileGPS.o Modem.o ModemSerialPort.o Mutex.o \ + DStarSlowData.o Golay2087.o Golay24128.o GPSD.o Hamming.o HD44780.o I2CController.o LCDproc.o Log.o MMDVMHost.o Modem.o ModemSerialPort.o Mutex.o \ NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o NXDNIcomNetwork.o NXDNKenwoodNetwork.o \ NXDNLayer3.o NXDNLICH.o NXDNLookup.o NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o P25NID.o \ P25Trellis.o P25Utils.o POCSAGControl.o POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialController.o SerialPort.o \ diff --git a/Makefile.Pi.OLED b/Makefile.Pi.OLED index 387a0a7..513e3f1 100644 --- a/Makefile.Pi.OLED +++ b/Makefile.Pi.OLED @@ -2,14 +2,21 @@ CC = gcc CXX = g++ + +# Use the following CFLAGS and LIBS if you don't want to use gpsd. CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DOLED -I/usr/local/include LIBS = -lArduiPi_OLED -lwiringPi -lpthread + +# Use the following CFLAGS and LIBS if you do want to use gpsd. +#CFLAGS = -g -O3 -Wall -DUSE_GPS -std=c++0x -pthread -DOLED -I/usr/local/include +#LIBS = -lArduiPi_OLED -lwiringPi -lpthread -lgps + LDFLAGS = -g -L/usr/local/lib OBJECTS = \ AMBEFEC.o BCH.o BPTC19696.o CASTInfo.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedData.o DMRFullLC.o \ DMRLookup.o DMRLC.o DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTA.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o \ - DStarSlowData.o Golay2087.o Golay24128.o Hamming.o I2CController.o OLED.o LCDproc.o Log.o MMDVMHost.o MobileGPS.o Modem.o ModemSerialPort.o Mutex.o \ + DStarSlowData.o Golay2087.o Golay24128.o GPSD.o Hamming.o I2CController.o OLED.o LCDproc.o Log.o MMDVMHost.o Modem.o ModemSerialPort.o Mutex.o \ NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o NXDNIcomNetwork.o NXDNKenwoodNetwork.o \ NXDNLayer3.o NXDNLICH.o NXDNLookup.o NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o P25NID.o \ P25Trellis.o P25Utils.o POCSAGControl.o POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialController.o SerialPort.o \ diff --git a/Makefile.Pi.PCF8574 b/Makefile.Pi.PCF8574 index 5ac5b48..ad46379 100644 --- a/Makefile.Pi.PCF8574 +++ b/Makefile.Pi.PCF8574 @@ -3,14 +3,21 @@ CC = gcc CXX = g++ + +# Use the following CFLAGS and LIBS if you don't want to use gpsd. CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DHD44780 -DPCF8574_DISPLAY -I/usr/local/include LIBS = -lwiringPi -lwiringPiDev -lpthread + +# Use the following CFLAGS and LIBS if you do want to use gpsd. +#CFLAGS = -g -O3 -Wall -DUSE_GPS -std=c++0x -pthread -DHD44780 -DPCF8574_DISPLAY -I/usr/local/include +#LIBS = -lwiringPi -lwiringPiDev -lpthread -lgps + LDFLAGS = -g -L/usr/local/lib OBJECTS = \ AMBEFEC.o BCH.o BPTC19696.o CASTInfo.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedData.o DMRFullLC.o \ DMRLookup.o DMRLC.o DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTA.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o \ - DStarSlowData.o Golay2087.o Golay24128.o Hamming.o HD44780.o I2CController.o LCDproc.o Log.o MMDVMHost.o MobileGPS.o Modem.o ModemSerialPort.o Mutex.o \ + DStarSlowData.o Golay2087.o Golay24128.o GPSD.o Hamming.o HD44780.o I2CController.o LCDproc.o Log.o MMDVMHost.o Modem.o ModemSerialPort.o Mutex.o \ NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o NXDNConvolution.o NXDNCRC.o NXDNFACCH1.o NXDNIcomNetwork.o NXDNKenwoodNetwork.o \ NXDNLayer3.o NXDNLICH.o NXDNLookup.o NXDNNetwork.o NXDNSACCH.o NXDNUDCH.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o P25NID.o \ P25Trellis.o P25Utils.o POCSAGControl.o POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialController.o SerialPort.o \ diff --git a/MobileGPS.cpp b/MobileGPS.cpp deleted file mode 100644 index 27721bd..0000000 --- a/MobileGPS.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2018 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "MobileGPS.h" - -#include -#include -#include -#include - -CMobileGPS::CMobileGPS(const std::string& address, unsigned int port, CDMRNetwork* network) : -m_idTimer(1000U, 60U), -m_address(), -m_port(port), -m_socket(), -m_network(network) -{ - assert(!address.empty()); - assert(port > 0U); - assert(network != NULL); - - m_address = CUDPSocket::lookup(address); -} - -CMobileGPS::~CMobileGPS() -{ -} - -bool CMobileGPS::open() -{ - bool ret = m_socket.open(); - if (!ret) - return false; - - m_idTimer.start(); - - return true; -} - -void CMobileGPS::clock(unsigned int ms) -{ - m_idTimer.clock(ms); - - if (m_idTimer.hasExpired()) { - pollGPS(); - m_idTimer.start(); - } - - sendReport(); -} - -void CMobileGPS::close() -{ - m_socket.close(); -} - -bool CMobileGPS::pollGPS() -{ - return m_socket.write((unsigned char*)"MMDVMHost", 9U, m_address, m_port); -} - -void CMobileGPS::sendReport() -{ - // Grab GPS data if it's available - unsigned char buffer[200U]; - in_addr address; - unsigned int port; - int ret = m_socket.read(buffer, 200U, address, port); - if (ret <= 0) - return; - - buffer[ret] = '\0'; - - // Parse the GPS data - char* pLatitude = ::strtok((char*)buffer, ",\n"); // Latitude - char* pLongitude = ::strtok(NULL, ",\n"); // Longitude - - if (pLatitude == NULL || pLongitude == NULL) - return; - - float latitude = float(::atof(pLatitude)); - float longitude = float(::atof(pLongitude)); - - m_network->writeHomePosition(latitude, longitude); -} - diff --git a/Version.h b/Version.h index 101ca94..68d6440 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200608"; +const char* VERSION = "20200629"; #endif From be8c29da3e62e6fb4a1b49132aa70936f7fc34f2 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 29 Jun 2020 11:50:33 +0100 Subject: [PATCH 04/14] Fix Windows compilation. --- MMDVMHost.vcxproj | 4 ++-- MMDVMHost.vcxproj.filters | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/MMDVMHost.vcxproj b/MMDVMHost.vcxproj index 44b50f2..b17f851 100644 --- a/MMDVMHost.vcxproj +++ b/MMDVMHost.vcxproj @@ -183,13 +183,13 @@ + - @@ -281,12 +281,12 @@ + - diff --git a/MMDVMHost.vcxproj.filters b/MMDVMHost.vcxproj.filters index 01fcd3f..7168194 100644 --- a/MMDVMHost.vcxproj.filters +++ b/MMDVMHost.vcxproj.filters @@ -278,9 +278,6 @@ Header Files - - Header Files - Header Files @@ -305,6 +302,9 @@ Header Files + + Header Files + @@ -547,9 +547,6 @@ Source Files - - Source Files - Source Files @@ -574,5 +571,8 @@ Source Files + + Source Files + \ No newline at end of file From df47466aa2881ff3774f4660727c39227c97bc6c Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Tue, 30 Jun 2020 11:38:25 +0100 Subject: [PATCH 05/14] Use USE_GPSD instead of USE_GPS. --- GPSD.cpp | 3 +-- GPSD.h | 3 +-- MMDVMHost.cpp | 8 ++++---- MMDVMHost.h | 2 +- Makefile | 2 +- Makefile.Pi | 2 +- Makefile.Pi.Adafruit | 2 +- Makefile.Pi.HD44780 | 2 +- Makefile.Pi.OLED | 2 +- Makefile.Pi.PCF8574 | 2 +- Version.h | 2 +- 11 files changed, 14 insertions(+), 16 deletions(-) diff --git a/GPSD.cpp b/GPSD.cpp index aec42f0..c06321a 100644 --- a/GPSD.cpp +++ b/GPSD.cpp @@ -18,7 +18,7 @@ #include "GPSD.h" -#if defined(USE_GPS) +#if defined(USE_GPSD) #include #include @@ -101,4 +101,3 @@ void CGPSD::sendReport() } #endif - diff --git a/GPSD.h b/GPSD.h index d8838db..cef93b5 100644 --- a/GPSD.h +++ b/GPSD.h @@ -19,7 +19,7 @@ #ifndef GPSD_H #define GPSD_H -#if defined(USE_GPS) +#if defined(USE_GPSD) #include "DMRNetwork.h" #include "Timer.h" @@ -52,4 +52,3 @@ private: #endif #endif - diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index b736a42..b5a8aef 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -161,7 +161,7 @@ m_id(0U), m_cwCallsign(), m_lockFileEnabled(false), m_lockFileName(), -#if defined(USE_GPS) +#if defined(USE_GPSD) m_gpsd(NULL), #endif m_remoteControl(NULL), @@ -1006,7 +1006,7 @@ int CMMDVMHost::run() if (m_pocsagNetwork != NULL) m_pocsagNetwork->clock(ms); -#if defined(USE_GPS) +#if defined(USE_GPSD) if (m_gpsd != NULL) m_gpsd->clock(ms); #endif @@ -1086,7 +1086,7 @@ int CMMDVMHost::run() m_display->close(); delete m_display; -#if defined(USE_GPS) +#if defined(USE_GPSD) if (m_gpsd != NULL) { m_gpsd->close(); delete m_gpsd; @@ -1398,7 +1398,7 @@ bool CMMDVMHost::createDMRNetwork() return false; } -#if defined(USE_GPS) +#if defined(USE_GPSD) bool gpsdEnabled = m_conf.getGPSDEnabled(); if (gpsdEnabled) { std::string gpsdAddress = m_conf.getGPSDAddress(); diff --git a/MMDVMHost.h b/MMDVMHost.h index 4e2b039..3d77653 100644 --- a/MMDVMHost.h +++ b/MMDVMHost.h @@ -102,7 +102,7 @@ private: std::string m_cwCallsign; bool m_lockFileEnabled; std::string m_lockFileName; -#if defined(USE_GPS) +#if defined(USE_GPSD) CGPSD* m_gpsd; #endif CRemoteControl* m_remoteControl; diff --git a/Makefile b/Makefile index 029f36e..1ad3c8a 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ CFLAGS = -g -O3 -Wall -std=c++0x -pthread LIBS = -lpthread # Use the following CFLAGS and LIBS if you do want to use gpsd. -#CFLAGS = -g -O3 -Wall -DUSE_GPS -std=c++0x -pthread +#CFLAGS = -g -O3 -Wall -DUSE_GPSD -std=c++0x -pthread #LIBS = -lpthread -lgps LDFLAGS = -g diff --git a/Makefile.Pi b/Makefile.Pi index 24650a3..53e457e 100644 --- a/Makefile.Pi +++ b/Makefile.Pi @@ -7,7 +7,7 @@ CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DRASPBERRY_PI -I/usr/local/include LIBS = -lwiringPi -lwiringPiDev -lpthread # Use the following CFLAGS and LIBS if you do want to use gpsd. -#CFLAGS = -g -O3 -Wall -DUSE_GPS -std=c++0x -pthread -DRASPBERRY_PI -I/usr/local/include +#CFLAGS = -g -O3 -Wall -DUSE_GPSD -std=c++0x -pthread -DRASPBERRY_PI -I/usr/local/include #LIBS = -lwiringPi -lwiringPiDev -lpthread -lgps LDFLAGS = -g -L/usr/local/lib diff --git a/Makefile.Pi.Adafruit b/Makefile.Pi.Adafruit index c273ce5..0a8fa85 100644 --- a/Makefile.Pi.Adafruit +++ b/Makefile.Pi.Adafruit @@ -8,7 +8,7 @@ CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DHD44780 -DADAFRUIT_DISPLAY -I/usr/l LIBS = -lwiringPi -lwiringPiDev -lpthread # Use the following CFLAGS and LIBS if you do want to use gpsd. -#CFLAGS = -g -O3 -Wall -DUSE_GPS -std=c++0x -pthread -DHD44780 -DADAFRUIT_DISPLAY -I/usr/local/include +#CFLAGS = -g -O3 -Wall -DUSE_GPSD -std=c++0x -pthread -DHD44780 -DADAFRUIT_DISPLAY -I/usr/local/include #LIBS = -lwiringPi -lwiringPiDev -lpthread -lgps LDFLAGS = -g -L/usr/local/lib diff --git a/Makefile.Pi.HD44780 b/Makefile.Pi.HD44780 index eccc3cc..5417946 100644 --- a/Makefile.Pi.HD44780 +++ b/Makefile.Pi.HD44780 @@ -8,7 +8,7 @@ CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DHD44780 -I/usr/local/include LIBS = -lwiringPi -lwiringPiDev -lpthread # Use the following CFLAGS and LIBS if you do want to use gpsd. -#CFLAGS = -g -O3 -Wall -DUSE_GPS -std=c++0x -pthread -DHD44780 -I/usr/local/include +#CFLAGS = -g -O3 -Wall -DUSE_GPSD -std=c++0x -pthread -DHD44780 -I/usr/local/include #LIBS = -lwiringPi -lwiringPiDev -lpthread -lgps LDFLAGS = -g -L/usr/local/lib diff --git a/Makefile.Pi.OLED b/Makefile.Pi.OLED index 513e3f1..9949cf2 100644 --- a/Makefile.Pi.OLED +++ b/Makefile.Pi.OLED @@ -8,7 +8,7 @@ CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DOLED -I/usr/local/include LIBS = -lArduiPi_OLED -lwiringPi -lpthread # Use the following CFLAGS and LIBS if you do want to use gpsd. -#CFLAGS = -g -O3 -Wall -DUSE_GPS -std=c++0x -pthread -DOLED -I/usr/local/include +#CFLAGS = -g -O3 -Wall -DUSE_GPSD -std=c++0x -pthread -DOLED -I/usr/local/include #LIBS = -lArduiPi_OLED -lwiringPi -lpthread -lgps LDFLAGS = -g -L/usr/local/lib diff --git a/Makefile.Pi.PCF8574 b/Makefile.Pi.PCF8574 index ad46379..aa84cc8 100644 --- a/Makefile.Pi.PCF8574 +++ b/Makefile.Pi.PCF8574 @@ -9,7 +9,7 @@ CFLAGS = -g -O3 -Wall -std=c++0x -pthread -DHD44780 -DPCF8574_DISPLAY -I/usr/lo LIBS = -lwiringPi -lwiringPiDev -lpthread # Use the following CFLAGS and LIBS if you do want to use gpsd. -#CFLAGS = -g -O3 -Wall -DUSE_GPS -std=c++0x -pthread -DHD44780 -DPCF8574_DISPLAY -I/usr/local/include +#CFLAGS = -g -O3 -Wall -DUSE_GPSD -std=c++0x -pthread -DHD44780 -DPCF8574_DISPLAY -I/usr/local/include #LIBS = -lwiringPi -lwiringPiDev -lpthread -lgps LDFLAGS = -g -L/usr/local/lib diff --git a/Version.h b/Version.h index 68d6440..bb444d2 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200629"; +const char* VERSION = "20200630"; #endif From 236d467c1a4268dee6e79f65dc839a0affd48aa9 Mon Sep 17 00:00:00 2001 From: SASANO Takayoshi Date: Sun, 14 Jun 2020 16:00:20 +0900 Subject: [PATCH 06/14] change ScreenLayout definition for Nextion to add new feature easily, the definition of ScreenLayout in [Nextion] has changed like this. ScreenLayout < 8: compatibile setting for old config file 0: G4KLX @ 9600bps 1: (reserved) 2: ON7LDS @ 9600bps 3: ON7LDS-DIY @ 9600bps 4: ON7LDS-DIY @ 115200bps ScreenLayout >= 8: new world, set the bit to enable each feature bit3 (8) use 115200bps bit4 (16) Display DMR Talker Alias bit5 (32) Colour change when displaying TA bit6 (64) Font size change when displaying long TA text bit7 (128) Display DIY status when MMDVM IDLE old settings are same as: 0 -> 0 2 -> 112 (16+32+64) 3 -> 144 (16+128) 4 -> 152 (8+16+128) --- Display.cpp | 2 +- Nextion.cpp | 106 +++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 76 insertions(+), 32 deletions(-) diff --git a/Display.cpp b/Display.cpp index 0b47b64..d0e6fd0 100644 --- a/Display.cpp +++ b/Display.cpp @@ -566,7 +566,7 @@ CDisplay* CDisplay::createDisplay(const CConf& conf, CUMP* ump, CModem* modem) } } else { SERIAL_SPEED baudrate = SERIAL_9600; - if (screenLayout==4U) + if (screenLayout&0x0cU) baudrate = SERIAL_115200; LogInfo(" Display baudrate: %u ",baudrate); diff --git a/Nextion.cpp b/Nextion.cpp index f15d6cf..adb8e76 100644 --- a/Nextion.cpp +++ b/Nextion.cpp @@ -38,6 +38,16 @@ const unsigned int P25_BER_COUNT = 7U; // 7 * 180ms = 1260ms const unsigned int NXDN_RSSI_COUNT = 28U; // 28 * 40ms = 1120ms const unsigned int NXDN_BER_COUNT = 28U; // 28 * 40ms = 1120ms +#define LAYOUT_COMPAT_MASK (7 << 0) // compatibility for old setting +#define LAYOUT_TA_ENABLE (1 << 4) // enable Talker Alias (TA) display +#define LAYOUT_TA_COLOUR (1 << 5) // TA display with font colour change +#define LAYOUT_TA_FONTSIZE (1 << 6) // TA display with font size change +#define LAYOUT_DIY (1 << 7) // use ON7LDS-DIY layout + +// bit[3:2] is used in Display.cpp to set connection speed for LCD panel. +// 00:low, others:high-speed. bit[2] is overlapped with LAYOUT_COMPAT_MASK. +#define LAYOUT_HIGHSPEED (3 << 2) + CNextion::CNextion(const std::string& callsign, unsigned int dmrid, ISerialPort* serial, unsigned int brightness, bool displayClock, bool utc, unsigned int idleBrightness, unsigned int screenLayout, unsigned int txFrequency, unsigned int rxFrequency, bool displayTempInF, const std::string& location) : CDisplay(), m_callsign(callsign), @@ -49,7 +59,7 @@ m_mode(MODE_IDLE), m_displayClock(displayClock), m_utc(utc), m_idleBrightness(idleBrightness), -m_screenLayout(screenLayout), +m_screenLayout(0), m_clockDisplayTimer(1000U, 0U, 400U), m_rssiAccum1(0U), m_rssiAccum2(0U), @@ -68,6 +78,23 @@ m_location(location) { assert(serial != NULL); assert(brightness >= 0U && brightness <= 100U); + + static const unsigned int feature_set[] = { + 0, // 0: G4KLX + 0, // 1: (reserved, low speed) + // 2: ON7LDS + LAYOUT_TA_ENABLE | LAYOUT_TA_COLOUR | LAYOUT_TA_FONTSIZE, + LAYOUT_TA_ENABLE | LAYOUT_DIY, // 3: ON7LDS-DIY + LAYOUT_TA_ENABLE | LAYOUT_DIY, // 4: ON7LDS-DIY (high speed) + 0, // 5: (reserved, high speed) + 0, // 6: (reserved, high speed) + 0, // 7: (reserved, high speed) + }; + + if (screenLayout & ~LAYOUT_COMPAT_MASK) + m_screenLayout = screenLayout & ~LAYOUT_COMPAT_MASK; + else + m_screenLayout = feature_set[screenLayout]; } CNextion::~CNextion() @@ -118,7 +145,7 @@ void CNextion::setIdleInt() ::sprintf(command, "t0.txt=\"%s/%u\"", m_callsign.c_str(), m_dmrid); sendCommand(command); - if (m_screenLayout > 2U) { + if (m_screenLayout & LAYOUT_DIY) { ::sprintf(command, "t4.txt=\"%s\"", m_callsign.c_str()); sendCommand(command); ::sprintf(command, "t5.txt=\"%u\"", m_dmrid); @@ -350,17 +377,21 @@ void CNextion::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro if (slotNo == 1U) { - if (m_screenLayout == 2U) { - sendCommand("t2.pco=0"); - sendCommand("t2.font=4"); + if (m_screenLayout & LAYOUT_TA_ENABLE) { + if (m_screenLayout & LAYOUT_TA_COLOUR) + sendCommand("t2.pco=0"); + if (m_screenLayout & LAYOUT_TA_FONTSIZE) + sendCommand("t2.font=4"); } sendCommand("t2.txt=\"2 Listening\""); sendCommandAction(69U); } else { - if (m_screenLayout == 2U) { - sendCommand("t0.pco=0"); - sendCommand("t0.font=4"); + if (m_screenLayout & LAYOUT_TA_ENABLE) { + if (m_screenLayout & LAYOUT_TA_COLOUR) + sendCommand("t0.pco=0"); + if (m_screenLayout & LAYOUT_TA_FONTSIZE) + sendCommand("t0.font=4"); } sendCommand("t0.txt=\"1 Listening\""); @@ -377,9 +408,11 @@ void CNextion::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro if (slotNo == 1U) { ::sprintf(text, "t0.txt=\"1 %s %s\"", type, src.c_str()); - if (m_screenLayout == 2U) { - sendCommand("t0.pco=0"); - sendCommand("t0.font=4"); + if (m_screenLayout & LAYOUT_TA_ENABLE) { + if (m_screenLayout & LAYOUT_TA_COLOUR) + sendCommand("t0.pco=0"); + if (m_screenLayout & LAYOUT_TA_FONTSIZE) + sendCommand("t0.font=4"); } sendCommand(text); @@ -391,9 +424,11 @@ void CNextion::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro } else { ::sprintf(text, "t2.txt=\"2 %s %s\"", type, src.c_str()); - if (m_screenLayout == 2U) { - sendCommand("t2.pco=0"); - sendCommand("t2.font=4"); + if (m_screenLayout & LAYOUT_TA_ENABLE) { + if (m_screenLayout & LAYOUT_TA_COLOUR) + sendCommand("t2.pco=0"); + if (m_screenLayout & LAYOUT_TA_FONTSIZE) + sendCommand("t2.font=4"); } sendCommand(text); @@ -448,15 +483,17 @@ void CNextion::writeDMRRSSIInt(unsigned int slotNo, unsigned char rssi) void CNextion::writeDMRTAInt(unsigned int slotNo, unsigned char* talkerAlias, const char* type) { - if (m_screenLayout < 2U) + if (!(m_screenLayout & LAYOUT_TA_ENABLE)) return; if (type[0] == ' ') { if (slotNo == 1U) { - if (m_screenLayout == 2U) sendCommand("t0.pco=33808"); + if (m_screenLayout & LAYOUT_TA_COLOUR) + sendCommand("t0.pco=33808"); sendCommandAction(64U); } else { - if (m_screenLayout == 2U) sendCommand("t2.pco=33808"); + if (m_screenLayout & LAYOUT_TA_COLOUR) + sendCommand("t2.pco=33808"); sendCommandAction(72U); } @@ -467,33 +504,36 @@ void CNextion::writeDMRTAInt(unsigned int slotNo, unsigned char* talkerAlias, co char text[50U]; ::sprintf(text, "t0.txt=\"1 %s %s\"", type, talkerAlias); - if (m_screenLayout == 2U) { + if (m_screenLayout & LAYOUT_TA_FONTSIZE) { if (::strlen((char*)talkerAlias) > (16U-4U)) sendCommand("t0.font=3"); if (::strlen((char*)talkerAlias) > (20U-4U)) sendCommand("t0.font=2"); if (::strlen((char*)talkerAlias) > (24U-4U)) sendCommand("t0.font=1"); - - sendCommand("t0.pco=1024"); } + if (m_screenLayout & LAYOUT_TA_COLOUR) + sendCommand("t0.pco=1024"); + sendCommand(text); sendCommandAction(63U); } else { char text[50U]; ::sprintf(text, "t2.txt=\"2 %s %s\"", type, talkerAlias); - if (m_screenLayout == 2U) { + if (m_screenLayout & LAYOUT_TA_FONTSIZE) { if (::strlen((char*)talkerAlias) > (16U-4U)) sendCommand("t2.font=3"); if (::strlen((char*)talkerAlias) > (20U-4U)) sendCommand("t2.font=2"); if (::strlen((char*)talkerAlias) > (24U-4U)) sendCommand("t2.font=1"); - - sendCommand("t2.pco=1024"); } + + if (m_screenLayout & LAYOUT_TA_COLOUR) + sendCommand("t2.pco=1024"); + sendCommand(text); sendCommandAction(71U); } @@ -535,9 +575,11 @@ void CNextion::clearDMRInt(unsigned int slotNo) sendCommand("t0.txt=\"1 Listening\""); sendCommandAction(61U); - if (m_screenLayout == 2U) { - sendCommand("t0.pco=0"); - sendCommand("t0.font=4"); + if (m_screenLayout & LAYOUT_TA_ENABLE) { + if (m_screenLayout & LAYOUT_TA_COLOUR) + sendCommand("t0.pco=0"); + if (m_screenLayout & LAYOUT_TA_FONTSIZE) + sendCommand("t0.font=4"); } sendCommand("t1.txt=\"\""); @@ -547,9 +589,11 @@ void CNextion::clearDMRInt(unsigned int slotNo) sendCommand("t2.txt=\"2 Listening\""); sendCommandAction(69U); - if (m_screenLayout == 2U) { - sendCommand("t2.pco=0"); - sendCommand("t2.font=4"); + if (m_screenLayout & LAYOUT_TA_ENABLE) { + if (m_screenLayout & LAYOUT_TA_COLOUR) + sendCommand("t2.pco=0"); + if (m_screenLayout & LAYOUT_TA_FONTSIZE) + sendCommand("t2.font=4"); } sendCommand("t3.txt=\"\""); @@ -862,7 +906,7 @@ void CNextion::close() void CNextion::sendCommandAction(unsigned int status) { - if (m_screenLayout<3U) + if (!(m_screenLayout & LAYOUT_DIY)) return; char text[30U]; @@ -881,4 +925,4 @@ void CNextion::sendCommand(const char* command) // we must add a bit of a delay to allow the display to process the commands, else some are getting mangled. // 10 ms is just a guess, but seems to be sufficient. CThread::sleep(10U); - } +} From 79b3eaa57afaa7a6efd765645d415e8712ffbb28 Mon Sep 17 00:00:00 2001 From: SASANO Takayoshi Date: Wed, 1 Jul 2020 19:48:07 +0900 Subject: [PATCH 07/14] replace SSRC source from IPv4 address to random number Previous implementation uses SSRC as IPv4 address that is same behaviour of Kenwood's NXDN repeater. RFC 3350 RTP protocol recommends SSRC uses random number. So I use MT19937 random number generator instead of IP address. And if this is no problem, I will do two changes. - replace rand() in DMRNetwork.cpp and DStarNetwork.cpp to MT19937 - remove getLocalAddress() in UDPSocket.cpp --- NXDNKenwoodNetwork.cpp | 9 +++++++-- NXDNKenwoodNetwork.h | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/NXDNKenwoodNetwork.cpp b/NXDNKenwoodNetwork.cpp index 8531f90..496462f 100644 --- a/NXDNKenwoodNetwork.cpp +++ b/NXDNKenwoodNetwork.cpp @@ -56,7 +56,8 @@ m_rtcpTimer(1000U, 0U, 200U), m_hangTimer(1000U, 5U), m_hangType(0U), m_hangSrc(0U), -m_hangDst(0U) +m_hangDst(0U), +m_random() { assert(localPort > 0U); assert(!gwyAddress.empty()); @@ -65,6 +66,10 @@ m_hangDst(0U) m_sacch = new unsigned char[10U]; m_address = CUDPSocket::lookup(gwyAddress); + + std::random_device rd; + std::mt19937 mt(rd()); + m_random = mt; } CNXDNKenwoodNetwork::~CNXDNKenwoodNetwork() @@ -87,7 +92,7 @@ bool CNXDNKenwoodNetwork::open() return false; } - m_ssrc = m_rtpSocket.getLocalAddress(); + m_ssrc = m_random(); return true; } diff --git a/NXDNKenwoodNetwork.h b/NXDNKenwoodNetwork.h index e0c1099..6645c23 100644 --- a/NXDNKenwoodNetwork.h +++ b/NXDNKenwoodNetwork.h @@ -25,6 +25,7 @@ #include #include +#include class CNXDNKenwoodNetwork : public INXDNNetwork { public: @@ -69,6 +70,7 @@ private: unsigned char m_hangType; unsigned short m_hangSrc; unsigned short m_hangDst; + std::mt19937 m_random; bool processIcomVoiceHeader(const unsigned char* data); bool processIcomVoiceData(const unsigned char* data); From 0892aaaaae746f0a8e103502e4aa573aef8f207f Mon Sep 17 00:00:00 2001 From: SASANO Takayoshi Date: Wed, 1 Jul 2020 20:39:22 +0900 Subject: [PATCH 08/14] eliminate SSRC range 0x00000001 - 0xfffffffe --- NXDNKenwoodNetwork.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NXDNKenwoodNetwork.cpp b/NXDNKenwoodNetwork.cpp index 496462f..e873bd3 100644 --- a/NXDNKenwoodNetwork.cpp +++ b/NXDNKenwoodNetwork.cpp @@ -92,7 +92,8 @@ bool CNXDNKenwoodNetwork::open() return false; } - m_ssrc = m_random(); + std::uniform_int_distribution dist(0x00000001, 0xfffffffe); + m_ssrc = dist(m_random); return true; } From 4dd39696b4ce35fbf26b630746322221b10872c8 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Wed, 1 Jul 2020 13:38:23 +0100 Subject: [PATCH 09/14] Remove unused UDPSocket code. --- UDPSocket.cpp | 30 +----------------------------- UDPSocket.h | 4 +--- 2 files changed, 2 insertions(+), 32 deletions(-) diff --git a/UDPSocket.cpp b/UDPSocket.cpp index 2899faf..ba0e35f 100644 --- a/UDPSocket.cpp +++ b/UDPSocket.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2016,2020 by Jonathan Naylor G4KLX + * Copyright (C) 2006-2016 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 @@ -258,31 +258,3 @@ void CUDPSocket::close() ::close(m_fd); #endif } - -unsigned long CUDPSocket::getLocalAddress() const -{ - unsigned long address = 0UL; - - char hostname[80U]; - int ret = ::gethostname(hostname, 80); - if (ret == -1) - return 0UL; - - struct hostent* phe = ::gethostbyname(hostname); - if (phe == NULL) - return 0UL; - - if (phe->h_addrtype != AF_INET) - return 0UL; - - for (unsigned int i = 0U; phe->h_addr_list[i] != NULL; i++) { - struct in_addr addr; - ::memcpy(&addr, phe->h_addr_list[i], sizeof(struct in_addr)); - if (addr.s_addr != INADDR_LOOPBACK) { - address = addr.s_addr; - break; - } - } - - return address; -} diff --git a/UDPSocket.h b/UDPSocket.h index 4c21a43..3437b53 100644 --- a/UDPSocket.h +++ b/UDPSocket.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2011,2013,2015,2016,2020 by Jonathan Naylor G4KLX + * Copyright (C) 2009-2011,2013,2015,2016 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 @@ -47,8 +47,6 @@ public: void close(); - unsigned long getLocalAddress() const; - static in_addr lookup(const std::string& hostName); private: From dfaedb450b4eb4c8b6165da9383771f801cb8609 Mon Sep 17 00:00:00 2001 From: SASANO Takayoshi Date: Thu, 2 Jul 2020 06:40:26 +0900 Subject: [PATCH 10/14] replace rand() -> MT19937 random number generator sometimes rand() makes problem so replace it to MT19937 in C++11 . --- DMRNetwork.cpp | 18 +++++++++++------- DMRNetwork.h | 2 ++ DStarNetwork.cpp | 11 +++++++---- DStarNetwork.h | 2 ++ 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/DMRNetwork.cpp b/DMRNetwork.cpp index b2aedb5..fece49c 100644 --- a/DMRNetwork.cpp +++ b/DMRNetwork.cpp @@ -66,7 +66,8 @@ m_height(0), m_location(), m_description(), m_url(), -m_beacon(false) +m_beacon(false), +m_random() { assert(!address.empty()); assert(port > 0U); @@ -85,11 +86,13 @@ m_beacon(false) m_id[2U] = id >> 8; m_id[3U] = id >> 0; - CStopWatch stopWatch; - ::srand(stopWatch.start()); + std::random_device rd; + std::mt19937 mt(rd()); + m_random = mt; - m_streamId[0U] = ::rand() + 1U; - m_streamId[1U] = ::rand() + 1U; + std::uniform_int_distribution dist(0x00000001, 0xfffffffe); + m_streamId[0U] = dist(m_random); + m_streamId[1U] = dist(m_random); } CDMRNetwork::~CDMRNetwork() @@ -246,6 +249,7 @@ bool CDMRNetwork::write(const CDMRData& data) unsigned int slotIndex = slotNo - 1U; + std::uniform_int_distribution dist(0x00000001, 0xfffffffe); unsigned char dataType = data.getDataType(); if (dataType == DT_VOICE_SYNC) { buffer[15U] |= 0x10U; @@ -253,10 +257,10 @@ bool CDMRNetwork::write(const CDMRData& data) buffer[15U] |= data.getN(); } else { if (dataType == DT_VOICE_LC_HEADER) - m_streamId[slotIndex] = ::rand() + 1U; + m_streamId[slotIndex] = dist(m_random); if (dataType == DT_CSBK || dataType == DT_DATA_HEADER) - m_streamId[slotIndex] = ::rand() + 1U; + m_streamId[slotIndex] = dist(m_random); buffer[15U] |= (0x20U | dataType); } diff --git a/DMRNetwork.h b/DMRNetwork.h index 9d1c52e..754c970 100644 --- a/DMRNetwork.h +++ b/DMRNetwork.h @@ -27,6 +27,7 @@ #include #include +#include class CDMRNetwork { @@ -106,6 +107,7 @@ private: std::string m_url; bool m_beacon; + std::mt19937 m_random; bool writeLogin(); bool writeAuthorisation(); diff --git a/DStarNetwork.cpp b/DStarNetwork.cpp index de0af69..d13d773 100644 --- a/DStarNetwork.cpp +++ b/DStarNetwork.cpp @@ -44,14 +44,16 @@ m_inId(0U), m_buffer(1000U, "D-Star Network"), m_pollTimer(1000U, 60U), m_linkStatus(LS_NONE), -m_linkReflector(NULL) +m_linkReflector(NULL), +m_random() { m_address = CUDPSocket::lookup(gatewayAddress); m_linkReflector = new unsigned char[DSTAR_LONG_CALLSIGN_LENGTH]; - CStopWatch stopWatch; - ::srand(stopWatch.start()); + std::random_device rd; + std::mt19937 mt(rd()); + m_random = mt; } CDStarNetwork::~CDStarNetwork() @@ -85,7 +87,8 @@ bool CDStarNetwork::writeHeader(const unsigned char* header, unsigned int length buffer[4] = busy ? 0x22U : 0x20U; // Create a random id for this transmission - m_outId = (::rand() % 65535U) + 1U; + std::uniform_int_distribution dist(0x0001, 0xfffe); + m_outId = dist(m_random); buffer[5] = m_outId / 256U; // Unique session id buffer[6] = m_outId % 256U; diff --git a/DStarNetwork.h b/DStarNetwork.h index aeebbbf..991c031 100644 --- a/DStarNetwork.h +++ b/DStarNetwork.h @@ -26,6 +26,7 @@ #include #include +#include class CDStarNetwork { public: @@ -64,6 +65,7 @@ private: CTimer m_pollTimer; LINK_STATUS m_linkStatus; unsigned char* m_linkReflector; + std::mt19937 m_random; bool writePoll(const char* text); }; From 4217ccebc4266f972db50d11e64df356b9ab54f5 Mon Sep 17 00:00:00 2001 From: SASANO Takayoshi Date: Thu, 2 Jul 2020 06:59:51 +0900 Subject: [PATCH 11/14] remove getLocalAddress() It was used for NXDNKenwoodNetwork.cpp to creates SSRC. currently SSRC uses random value, this function is no longer used. --- UDPSocket.cpp | 28 ---------------------------- UDPSocket.h | 2 -- 2 files changed, 30 deletions(-) diff --git a/UDPSocket.cpp b/UDPSocket.cpp index 2899faf..abfa885 100644 --- a/UDPSocket.cpp +++ b/UDPSocket.cpp @@ -258,31 +258,3 @@ void CUDPSocket::close() ::close(m_fd); #endif } - -unsigned long CUDPSocket::getLocalAddress() const -{ - unsigned long address = 0UL; - - char hostname[80U]; - int ret = ::gethostname(hostname, 80); - if (ret == -1) - return 0UL; - - struct hostent* phe = ::gethostbyname(hostname); - if (phe == NULL) - return 0UL; - - if (phe->h_addrtype != AF_INET) - return 0UL; - - for (unsigned int i = 0U; phe->h_addr_list[i] != NULL; i++) { - struct in_addr addr; - ::memcpy(&addr, phe->h_addr_list[i], sizeof(struct in_addr)); - if (addr.s_addr != INADDR_LOOPBACK) { - address = addr.s_addr; - break; - } - } - - return address; -} diff --git a/UDPSocket.h b/UDPSocket.h index 4c21a43..4aa16bd 100644 --- a/UDPSocket.h +++ b/UDPSocket.h @@ -47,8 +47,6 @@ public: void close(); - unsigned long getLocalAddress() const; - static in_addr lookup(const std::string& hostName); private: From 15a8e87c3ecc9c770271de65b1937b5e433e152b Mon Sep 17 00:00:00 2001 From: SASANO Takayoshi Date: Thu, 2 Jul 2020 18:47:33 +0900 Subject: [PATCH 12/14] permit inline comment and ScreenLayout of Nextion two minor improvements - ScreenLayout in Nextion section can use hexadecimal (0xXXXXX), octal (0XXXX) and decimal value - in-line comment enabled example: # conventional comment, the line starts with # [Section] Key=value # this is new style comment Key="quoted value # this is not comment" Key="quoted value" # this is prohibited (not comment) --- Conf.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Conf.cpp b/Conf.cpp index 5bc7dba..6602b3c 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -390,6 +390,9 @@ bool CConf::read() if (len > 1U && *value == '"' && value[len - 1U] == '"') { value[len - 1U] = '\0'; value++; + } else { + // if value is not quoted, remove after # (to make comment) + strtok(value, "#"); } if (section == SECTION_GENERAL) { @@ -916,7 +919,7 @@ bool CConf::read() else if (::strcmp(key, "IdleBrightness") == 0) m_nextionIdleBrightness = (unsigned int)::atoi(value); else if (::strcmp(key, "ScreenLayout") == 0) - m_nextionScreenLayout = (unsigned int)::atoi(value); + m_nextionScreenLayout = (unsigned int)::strtoul(value, NULL, 0); else if (::strcmp(key, "DisplayTempInFahrenheit") == 0) m_nextionTempInFahrenheit = ::atoi(value) == 1; } else if (section == SECTION_OLED) { From 1ded19c5b2c00490c0f4f16c872e5a926d4f5b9f Mon Sep 17 00:00:00 2001 From: SASANO Takayoshi Date: Sat, 4 Jul 2020 17:58:00 +0900 Subject: [PATCH 13/14] 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 14/14] 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