diff --git a/MMDVM.ini b/MMDVM.ini index 638118f..a75af4b 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -43,7 +43,7 @@ File=NXDN.csv Time=24 [Modem] -# Valid values are "uart", "udp", and (on Linux) "i2c" +# Valid values are "null", "uart", "udp", and (on Linux) "i2c" Protocol=uart # The port and speed used for a UART connection # UARTPort=\\.\COM4 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index a03fa70..f662289 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -22,10 +22,13 @@ #include "NXDNKenwoodNetwork.h" #include "NXDNIcomNetwork.h" #include "RSSIInterpolator.h" +#include "NullController.h" #include "UARTController.h" +#if defined(__linux__) +#include "I2CController.h" +#endif #include "UDPController.h" #include "MMDVMModem.h" -#include "NullModem.h" #include "Version.h" #include "StopWatch.h" #include "Defines.h" @@ -1404,10 +1407,7 @@ bool CMMDVMHost::createModem() LogInfo(" TX Frequency: %uHz (%uHz)", txFrequency, txFrequency + txOffset); LogInfo(" Use COS as Lockout: %s", useCOSAsLockout ? "yes" : "no"); - if (protocol == "null") - m_modem = new CNullModem; - else - m_modem = new CMMDVMModem(m_duplex, rxInvert, txInvert, pttInvert, txDelay, dmrDelay, useCOSAsLockout, trace, debug); + m_modem = new CMMDVMModem(m_duplex, rxInvert, txInvert, pttInvert, txDelay, dmrDelay, useCOSAsLockout, trace, debug); IMMDVMModemPort* modem = NULL; if (protocol == "uart") @@ -1418,6 +1418,8 @@ bool CMMDVMHost::createModem() else if (protocol == "i2c") modem = new CI2CController(i2cPort, i2cAddress); #endif + else if (protocol == "null") + modem = new CNullController; else return false; diff --git a/MMDVMHost.vcxproj b/MMDVMHost.vcxproj index 1067b2b..f6a0920 100644 --- a/MMDVMHost.vcxproj +++ b/MMDVMHost.vcxproj @@ -209,8 +209,8 @@ + - @@ -319,8 +319,8 @@ + - diff --git a/MMDVMHost.vcxproj.filters b/MMDVMHost.vcxproj.filters index 0a1e4bf..b6efac7 100644 --- a/MMDVMHost.vcxproj.filters +++ b/MMDVMHost.vcxproj.filters @@ -263,9 +263,6 @@ Header Files - - Header Files - Header Files @@ -350,6 +347,9 @@ Header Files + + Header Files + @@ -577,9 +577,6 @@ Source Files - - Source Files - Source Files @@ -658,5 +655,8 @@ Source Files + + Source Files + \ No newline at end of file diff --git a/MMDVMModem.cpp b/MMDVMModem.cpp index bb14094..c6c98c8 100644 --- a/MMDVMModem.cpp +++ b/MMDVMModem.cpp @@ -16,10 +16,6 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "UARTController.h" -#if defined(__linux__) -#include "I2CController.h" -#endif #include "DStarDefines.h" #include "DMRDefines.h" #include "YSFDefines.h" @@ -30,7 +26,6 @@ #include "M17Defines.h" #include "Thread.h" #include "MMDVMModem.h" -#include "NullModem.h" #include "Utils.h" #include "Log.h" diff --git a/Makefile b/Makefile index d26be33..6ff0e76 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ OBJECTS = \ DMRDirectNetwork.o DMREMB.o DMREmbeddedData.o DMRFullLC.o DMRGatewayNetwork.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 FMControl.o FMNetwork.o Golay2087.o Golay24128.o \ Hamming.o I2CController.o IIRDirectForm1Filter.o LCDproc.o Log.o M17Control.o M17Convolution.o M17CRC.o M17LICH.o M17Network.o M17Utils.o MMDVMHost.o \ - MMDVMModem.o MMDVMModemPort.o Modem.o ModemSerialPort.o Mutex.o NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o \ + MMDVMModem.o MMDVMModemPort.o Modem.o ModemSerialPort.o Mutex.o NetworkInfo.o Nextion.o NullController.o NullDisplay.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 PseudoTTYController.o POCSAGControl.o \ POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialPort.o StopWatch.o Sync.o SHA256.o TFTSurenoo.o Thread.o Timer.o \ diff --git a/Makefile.Pi b/Makefile.Pi index 0662f57..ee7be86 100644 --- a/Makefile.Pi +++ b/Makefile.Pi @@ -11,7 +11,7 @@ OBJECTS = \ DMRDirectNetwork.o DMREMB.o DMREmbeddedData.o DMRFullLC.o DMRGatewayNetwork.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 FMControl.o FMNetwork.o Golay2087.o Golay24128.o \ Hamming.o I2CController.o IIRDirectForm1Filter.o LCDproc.o Log.o M17Control.o M17Convolution.o M17CRC.o M17LICH.o M17Network.o M17Utils.o MMDVMHost.o \ - MMDVMModem.o MMDVMModemPort.o Modem.o ModemSerialPort.o Mutex.o NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o \ + MMDVMModem.o MMDVMModemPort.o Modem.o ModemSerialPort.o Mutex.o NetworkInfo.o Nextion.o NullController.o NullDisplay.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 PseudoTTYController.o POCSAGControl.o \ POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialPort.o StopWatch.o Sync.o SHA256.o TFTSurenoo.o Thread.o Timer.o \ diff --git a/Makefile.Pi.Adafruit b/Makefile.Pi.Adafruit index eeb192a..53cef93 100644 --- a/Makefile.Pi.Adafruit +++ b/Makefile.Pi.Adafruit @@ -12,11 +12,12 @@ OBJECTS = \ DMRDirectNetwork.o DMREMB.o DMREmbeddedData.o DMRFullLC.o DMRGatewayNetwork.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 FMControl.o FMNetwork.o Golay2087.o Golay24128.o \ Hamming.o HD44780.o I2CController.o IIRDirectForm1Filter.o LCDproc.o Log.o M17Control.o M17Convolution.o M17CRC.o M17LICH.o M17Network.o M17Utils.o \ - MMDVMHost.o MMDVMModem.o MMDVMModemPort.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 PseudoTTYController.o POCSAGControl.o \ - POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialPort.o StopWatch.o Sync.o SHA256.o TFTSurenoo.o Thread.o Timer.o \ - UARTController.o UDPController.o UDPSocket.o UserDB.o UserDBentry.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o + MMDVMHost.o MMDVMModem.o MMDVMModemPort.o Modem.o ModemSerialPort.o Mutex.o NetworkInfo.o Nextion.o NullController.o NullDisplay.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 PseudoTTYController.o \ + POCSAGControl.o POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialPort.o StopWatch.o Sync.o SHA256.o TFTSurenoo.o \ + Thread.o Timer.o UARTController.o UDPController.o UDPSocket.o UserDB.o UserDBentry.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o \ + YSFPayload.o all: MMDVMHost RemoteCommand diff --git a/Makefile.Pi.HD44780 b/Makefile.Pi.HD44780 index 92a7b58..cf4f3cb 100644 --- a/Makefile.Pi.HD44780 +++ b/Makefile.Pi.HD44780 @@ -11,11 +11,12 @@ OBJECTS = \ DMRDirectNetwork.o DMREMB.o DMREmbeddedData.o DMRFullLC.o DMRGatewayNetwork.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 FMControl.o FMNetwork.o Golay2087.o Golay24128.o \ Hamming.o HD44780.o I2CController.o IIRDirectForm1Filter.o LCDproc.o Log.o M17Control.o M17Convolution.o M17CRC.o M17LICH.o M17Network.o M17Utils.o \ - MMDVMHost.o MMDVMModem.o MMDVMModemPort.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 PseudoTTYController.o POCSAGControl.o \ - POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialPort.o StopWatch.o Sync.o SHA256.o TFTSurenoo.o Thread.o Timer.o \ - UARTController.o UDPController.o UDPSocket.o UserDB.o UserDBentry.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o + MMDVMHost.o MMDVMModem.o MMDVMModemPort.o Modem.o ModemSerialPort.o Mutex.o NetworkInfo.o Nextion.o NullController.o NullDisplay.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 PseudoTTYController.o \ + POCSAGControl.o POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialPort.o StopWatch.o Sync.o SHA256.o TFTSurenoo.o \ + Thread.o Timer.o UARTController.o UDPController.o UDPSocket.o UserDB.o UserDBentry.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o \ + YSFPayload.o all: MMDVMHost RemoteCommand diff --git a/Makefile.Pi.OLED b/Makefile.Pi.OLED index 42c584d..63a1d52 100644 --- a/Makefile.Pi.OLED +++ b/Makefile.Pi.OLED @@ -15,7 +15,7 @@ OBJECTS = \ DMRDirectNetwork.o DMREMB.o DMREmbeddedData.o DMRFullLC.o DMRGatewayNetwork.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 FMControl.o FMNetwork.o Golay2087.o Golay24128.o \ Hamming.o I2CController.o IIRDirectForm1Filter.o LCDproc.o Log.o M17Control.o M17Convolution.o M17CRC.o M17LICH.o M17Network.o M17Utils.o MMDVMHost.o \ - MMDVMModem.o MMDVMModemPort.o Modem.o ModemSerialPort.o Mutex.o NetworkInfo.o Nextion.o NullDisplay.o NullModem.o NXDNAudio.o NXDNControl.o \ + MMDVMModem.o MMDVMModemPort.o Modem.o ModemSerialPort.o Mutex.o NetworkInfo.o Nextion.o NullController.o NullDisplay.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 OLED.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o P25Network.o P25NID.o P25Trellis.o P25Utils.o PseudoTTYController.o \ POCSAGControl.o POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialPort.o StopWatch.o Sync.o SHA256.o TFTSurenoo.o \ diff --git a/Makefile.Pi.PCF8574 b/Makefile.Pi.PCF8574 index 0c54640..cce0546 100644 --- a/Makefile.Pi.PCF8574 +++ b/Makefile.Pi.PCF8574 @@ -12,11 +12,12 @@ OBJECTS = \ DMRDirectNetwork.o DMREMB.o DMREmbeddedData.o DMRFullLC.o DMRGatewayNetwork.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 FMControl.o FMNetwork.o Golay2087.o Golay24128.o \ Hamming.o HD44780.o I2CController.o IIRDirectForm1Filter.o LCDproc.o Log.o M17Control.o M17Convolution.o M17CRC.o M17LICH.o M17Network.o M17Utils.o \ - MMDVMHost.o MMDVMModem.o MMDVMModemPort.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 PseudoTTYController.o POCSAGControl.o \ - POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialPort.o StopWatch.o Sync.o SHA256.o TFTSurenoo.o Thread.o Timer.o \ - UARTController.o UDPController.o UDPSocket.o UserDB.o UserDBentry.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o + MMDVMHost.o MMDVMModem.o MMDVMModemPort.o Modem.o ModemSerialPort.o Mutex.o NetworkInfo.o Nextion.o NullController.o NullDisplay.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 PseudoTTYController.o \ + POCSAGControl.o POCSAGNetwork.o QR1676.o RemoteControl.o RS129.o RS241213.o RSSIInterpolator.o SerialPort.o StopWatch.o Sync.o SHA256.o TFTSurenoo.o \ + Thread.o Timer.o UARTController.o UDPController.o UDPSocket.o UserDB.o UserDBentry.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o \ + YSFPayload.o all: MMDVMHost RemoteCommand diff --git a/NullController.cpp b/NullController.cpp new file mode 100644 index 0000000..fb48a04 --- /dev/null +++ b/NullController.cpp @@ -0,0 +1,47 @@ +/* +* Copyright (C) 2021 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 "NullController.h" + +CNullController::CNullController() +{ +} + +CNullController::~CNullController() +{ +} + +bool CNullController::open() +{ + return true; +} + +int CNullController::read(unsigned char* buffer, unsigned int length) +{ + return 0; +} + +int CNullController::write(const unsigned char* buffer, unsigned int length) +{ + return length; +} + + +void CNullController::close() +{ +} diff --git a/NullController.h b/NullController.h new file mode 100644 index 0000000..5cb39c8 --- /dev/null +++ b/NullController.h @@ -0,0 +1,40 @@ +/* +* Copyright (C) 2021 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. +*/ + +#ifndef NullController_H +#define NullController_H + +#include "MMDVMModemPort.h" + +class CNullController : public IMMDVMModemPort { +public: + CNullController(); + virtual ~CNullController(); + + virtual bool open(); + + virtual int read(unsigned char* buffer, unsigned int length); + + virtual int write(const unsigned char* buffer, unsigned int length); + + virtual void close(); + +private: +}; + +#endif diff --git a/NullModem.cpp b/NullModem.cpp deleted file mode 100644 index 40e3fdd..0000000 --- a/NullModem.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 - * 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 "NullModem.h" -#include "Log.h" - -CNullModem::CNullModem() -{ -} - -CNullModem::~CNullModem() -{ -} - -bool CNullModem::open() -{ - ::LogMessage("Opening the MMDVM Null Modem"); - - return true; -} diff --git a/NullModem.h b/NullModem.h deleted file mode 100644 index 442b13e..0000000 --- a/NullModem.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2011-2018,2020,2021 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. - */ - -#ifndef NULLMODEM_H -#define NULLMODEM_H - -#include "Modem.h" -#include "Defines.h" - -#include - -class CNullModem : public IModem { -public: - CNullModem(); - virtual ~CNullModem(); - - virtual void setModem(IMMDVMModemPort* port) {}; - virtual void setRFParams(unsigned int rxFrequency, int rxOffset, unsigned int txFrequency, int txOffset, int txDCOffset, int rxDCOffset, float rfLevel, unsigned int pocsagFrequency) {}; - virtual void setModeParams(bool dstarEnabled, bool dmrEnabled, bool ysfEnabled, bool p25Enabled, bool nxdnEnabled, bool m17Enabled, bool pocsagEnabled, bool fmEnabled, bool ax25Enabled) {}; - virtual void setLevels(float rxLevel, float cwIdTXLevel, float dstarTXLevel, float dmrTXLevel, float ysfTXLevel, float p25TXLevel, float nxdnTXLevel, float m17TXLevel, float pocsagLevel, float fmTXLevel, float ax25TXLevel) {}; - virtual void setDMRParams(unsigned int colorCode) {}; - virtual void setYSFParams(bool loDev, unsigned int txHang) {}; - virtual void setP25Params(unsigned int txHang) {}; - virtual void setNXDNParams(unsigned int txHang) {}; - virtual void setM17Params(unsigned int txHang) {}; - virtual void setAX25Params(int rxTwist, unsigned int txDelay, unsigned int slotTime, unsigned int pPersist) {}; - virtual void setTransparentDataParams(unsigned int sendFrameType) {}; - - virtual void setFMCallsignParams(const std::string& callsign, unsigned int callsignSpeed, unsigned int callsignFrequency, unsigned int callsignTime, unsigned int callsignHoldoff, float callsignHighLevel, float callsignLowLevel, bool callsignAtStart, bool callsignAtEnd, 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, unsigned int accessMode, bool cosInvert, bool noiseSquelch, unsigned int squelchHighThreshold, unsigned int squelchLowThreshold, unsigned int rfAudioBoost, float maxDevLevel) {}; - virtual void setFMExtParams(const std::string& ack, unsigned int audioBoost) {}; - - virtual bool open(); - - virtual unsigned int readDStarData(unsigned char* data) { return 0U; }; - virtual unsigned int readDMRData1(unsigned char* data) { return 0U; }; - virtual unsigned int readDMRData2(unsigned char* data) { return 0U; }; - virtual unsigned int readYSFData(unsigned char* data) { return 0U; }; - virtual unsigned int readP25Data(unsigned char* data) { return 0U; }; - virtual unsigned int readNXDNData(unsigned char* data) { return 0U; }; - virtual unsigned int readM17Data(unsigned char* data) { return 0U; }; - virtual unsigned int readFMData(unsigned char* data) { return 0U; }; - virtual unsigned int readAX25Data(unsigned char* data) { return 0U; }; - - virtual bool hasDStarSpace()const { return true; }; - virtual bool hasDMRSpace1() const { return true; }; - virtual bool hasDMRSpace2() const { return true; }; - virtual bool hasYSFSpace() const { return true; }; - virtual bool hasP25Space() const { return true; }; - virtual bool hasNXDNSpace() const { return true; }; - virtual bool hasM17Space() const { return true; }; - virtual bool hasPOCSAGSpace() const { return true; }; - virtual unsigned int getFMSpace() const { return true; }; - virtual bool hasAX25Space() const { return true; }; - - virtual bool hasTX() const { return false; }; - virtual bool hasCD() const { return false; }; - - virtual bool hasLockout() const { return false; }; - virtual bool hasError() const { return false; }; - - virtual bool writeDStarData(const unsigned char* data, unsigned int length) { return true; }; - virtual bool writeDMRData1(const unsigned char* data, unsigned int length) { return true; }; - virtual bool writeDMRData2(const unsigned char* data, unsigned int length) { return true; }; - virtual bool writeYSFData(const unsigned char* data, unsigned int length) { return true; }; - virtual bool writeP25Data(const unsigned char* data, unsigned int length) { return true; }; - virtual bool writeNXDNData(const unsigned char* data, unsigned int length) { return true; }; - virtual bool writeM17Data(const unsigned char* data, unsigned int length) { return true; }; - virtual bool writePOCSAGData(const unsigned char* data, unsigned int length) { return true; }; - virtual bool writeFMData(const unsigned char* data, unsigned int length) { return true; }; - virtual bool writeAX25Data(const unsigned char* data, unsigned int length) { return true; }; - - virtual bool writeConfig() { return true; }; - virtual bool writeDStarInfo(const char* my1, const char* my2, const char* your, const char* type, const char* reflector) { return true; }; - virtual bool writeDMRInfo(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type) { return true; }; - virtual bool writeYSFInfo(const char* source, const char* dest, unsigned char dgid, const char* type, const char* origin) { return true; }; - virtual bool writeP25Info(const char* source, bool group, unsigned int dest, const char* type) { return true; }; - virtual bool writeNXDNInfo(const char* source, bool group, unsigned int dest, const char* type) { return true; }; - virtual bool writeM17Info(const char* source, const char* dest, const char* type) { return true; }; - virtual bool writePOCSAGInfo(unsigned int ric, const std::string& message) { return true; }; - virtual bool writeIPInfo(const std::string& address) { return true; }; - - virtual bool writeDMRStart(bool tx) { return true; }; - virtual bool writeDMRShortLC(const unsigned char* lc) { return true; }; - virtual bool writeDMRAbort(unsigned int slotNo) { return true; }; - - virtual bool writeTransparentData(const unsigned char* data, unsigned int length) { return true; }; - virtual unsigned int readTransparentData(unsigned char* data) { return 0U; }; - - virtual bool writeSerial(const unsigned char* data, unsigned int length) { return true; }; - virtual unsigned int readSerial(unsigned char* data, unsigned int length) { return 0U; }; - - virtual unsigned char getMode() const { return MODE_IDLE; }; - virtual bool setMode(unsigned char mode) { return true; }; - - virtual bool sendCWId(const std::string& callsign) { return true; }; - - virtual HW_TYPE getHWType() const { return HWT_MMDVM; }; - - virtual void clock(unsigned int ms) {}; - - virtual void close() {}; - -private: -}; - -#endif diff --git a/README.md b/README.md index 0b6fe0b..5fe08f0 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ POCSAG, FM, and AX.25 on the MMDVM, and D-Star, DMR, and System Fusion on the DV On the D-Star side the MMDVMHost interfaces with the ircDDB Gateway, on DMR it connects to the DMR Gateway to allow for connection to multiple DMR networks, -on System Fusion it connects to the YSF Gateway to allow +or a single network directly. on System Fusion it connects to the YSF Gateway to allow access to the FCS and YSF networks. On P25 it connects to the P25 Gateway. On NXDN it connects to the NXDN Gateway which provides access to the NXDN and NXCore talk groups. On M17 it uses the M17 Gateway to access the M17 reflector system. diff --git a/UDPController.cpp b/UDPController.cpp index 7e38d7c..c8f4b6f 100644 --- a/UDPController.cpp +++ b/UDPController.cpp @@ -28,9 +28,7 @@ CUDPController::CUDPController(const std::string& modemAddress, unsigned int mod m_socket(localPort), m_addr(), m_addrLen(0U), -m_buffer(NULL), -m_length(0U), -m_offset(0U) +m_buffer(2000U, "UDP Controller Ring Buffer") { assert(!modemAddress.empty()); assert(modemPort > 0U); @@ -38,13 +36,10 @@ m_offset(0U) if (CUDPSocket::lookup(modemAddress, modemPort, m_addr, m_addrLen) != 0) m_addrLen = 0U; - - m_buffer = new unsigned char[BUFFER_LENGTH]; } CUDPController::~CUDPController() { - delete[] m_buffer; } bool CUDPController::open() @@ -59,10 +54,32 @@ bool CUDPController::open() int CUDPController::read(unsigned char* buffer, unsigned int length) { - assert(buffer != NULL); - assert(length > 0U); + assert(buffer != NULL); + assert(length > 0U); - return 0; + unsigned char data[BUFFER_LENGTH]; + sockaddr_storage addr; + unsigned int addrLen; + int ret = m_socket.read(data, BUFFER_LENGTH, addr, addrLen); + + // An error occurred on the socket + if (ret < 0) + return ret; + + // Add new data to the ring buffer + if (ret > 0) { + if (CUDPSocket::match(addr, m_addr)) + m_buffer.addData(data, ret); + } + + // Get required data from the ring buffer + unsigned int avail = m_buffer.dataSize(); + if (avail < length) + length = avail; + + m_buffer.getData(buffer, length); + + return int(length); } int CUDPController::write(const unsigned char* buffer, unsigned int length) diff --git a/UDPController.h b/UDPController.h index 6e24eca..acb19e4 100644 --- a/UDPController.h +++ b/UDPController.h @@ -20,6 +20,7 @@ #define UDPController_H #include "MMDVMModemPort.h" +#include "RingBuffer.h" #include "UDPSocket.h" #include @@ -41,9 +42,7 @@ protected: CUDPSocket m_socket; sockaddr_storage m_addr; unsigned int m_addrLen; - unsigned char* m_buffer; - unsigned int m_length; - unsigned int m_offset; + CRingBuffer m_buffer; }; #endif diff --git a/Version.h b/Version.h index 50453e8..f707967 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20210216"; +const char* VERSION = "20210217"; #endif