Remove support for the UMP (sob).

This commit is contained in:
Jonathan Naylor 2020-11-10 09:58:10 +00:00
parent f1dda251c3
commit f89145b772
19 changed files with 20 additions and 675 deletions

View file

@ -37,7 +37,6 @@ enum SECTION {
SECTION_NXDNID_LOOKUP,
SECTION_MODEM,
SECTION_TRANSPARENT,
SECTION_UMP,
SECTION_DSTAR,
SECTION_DMR,
SECTION_FUSION,
@ -122,8 +121,6 @@ m_transparentRemoteAddress(),
m_transparentRemotePort(0U),
m_transparentLocalPort(0U),
m_transparentSendFrameType(0U),
m_umpEnabled(false),
m_umpPort(),
m_dstarEnabled(false),
m_dstarModule("C"),
m_dstarSelfOnly(false),
@ -360,8 +357,6 @@ bool CConf::read()
section = SECTION_MODEM;
else if (::strncmp(buffer, "[Transparent Data]", 18U) == 0)
section = SECTION_TRANSPARENT;
else if (::strncmp(buffer, "[UMP]", 5U) == 0)
section = SECTION_UMP;
else if (::strncmp(buffer, "[D-Star]", 8U) == 0)
section = SECTION_DSTAR;
else if (::strncmp(buffer, "[DMR]", 5U) == 0)
@ -568,11 +563,6 @@ bool CConf::read()
m_transparentLocalPort = (unsigned int)::atoi(value);
else if (::strcmp(key, "SendFrameType") == 0)
m_transparentSendFrameType = (unsigned int)::atoi(value);
} else if (section == SECTION_UMP) {
if (::strcmp(key, "Enable") == 0)
m_umpEnabled = ::atoi(value) == 1;
else if (::strcmp(key, "Port") == 0)
m_umpPort = value;
} else if (section == SECTION_DSTAR) {
if (::strcmp(key, "Enable") == 0)
m_dstarEnabled = ::atoi(value) == 1;
@ -1358,16 +1348,6 @@ unsigned int CConf::getTransparentSendFrameType() const
return m_transparentSendFrameType;
}
bool CConf::getUMPEnabled() const
{
return m_umpEnabled;
}
std::string CConf::getUMPPort() const
{
return m_umpPort;
}
bool CConf::getDStarEnabled() const
{
return m_dstarEnabled;

7
Conf.h
View file

@ -101,10 +101,6 @@ public:
unsigned int getTransparentLocalPort() const;
unsigned int getTransparentSendFrameType() const;
// The UMP section
bool getUMPEnabled() const;
std::string getUMPPort() const;
// The D-Star section
bool getDStarEnabled() const;
std::string getDStarModule() const;
@ -417,9 +413,6 @@ private:
unsigned int m_transparentLocalPort;
unsigned int m_transparentSendFrameType;
bool m_umpEnabled;
std::string m_umpPort;
bool m_dstarEnabled;
std::string m_dstarModule;
bool m_dstarSelfOnly;

View file

@ -28,7 +28,6 @@
#include "CASTInfo.h"
#include "Conf.h"
#include "Modem.h"
#include "UMP.h"
#include "Log.h"
#if defined(HD44780)
@ -537,11 +536,11 @@ int CDisplay::writeNXDNIntEx(const class CUserDBentry& source, bool group, unsig
/* Factory method extracted from MMDVMHost.cpp - BG5HHP */
CDisplay* CDisplay::createDisplay(const CConf& conf, CUMP* ump, IModem* modem)
CDisplay* CDisplay::createDisplay(const CConf& conf, IModem* modem)
{
CDisplay *display = NULL;
CDisplay *display = NULL;
std::string type = conf.getDisplay();
std::string type = conf.getDisplay();
unsigned int dmrid = conf.getDMRId();
LogInfo("Display Parameters");
@ -604,13 +603,6 @@ CDisplay* CDisplay::createDisplay(const CConf& conf, CUMP* ump, IModem* modem)
if (port == "modem") {
ISerialPort* serial = new IModemSerialPort(modem);
display = new CNextion(conf.getCallsign(), dmrid, serial, brightness, displayClock, utc, idleBrightness, screenLayout, txFrequency, rxFrequency, displayTempInF);
} else if (port == "ump") {
if (ump != NULL) {
display = new CNextion(conf.getCallsign(), dmrid, ump, brightness, displayClock, utc, idleBrightness, screenLayout, txFrequency, rxFrequency, displayTempInF);
} else {
LogInfo(" NullDisplay loaded");
display = new CNullDisplay;
}
} else {
unsigned int baudrate = 9600U;
if (screenLayout == 4U)

View file

@ -29,7 +29,6 @@
class CConf;
class IModem;
class CUMP;
class CDisplay
{
@ -87,7 +86,7 @@ public:
void clock(unsigned int ms);
static CDisplay* createDisplay(const CConf& conf, CUMP* ump, IModem* modem);
static CDisplay* createDisplay(const CConf& conf, IModem* modem);
protected:
virtual void setIdleInt() = 0;

View file

@ -76,11 +76,6 @@ RemotePort=40094
LocalPort=40095
# SendFrameType=0
[UMP]
Enable=0
# Port=\\.\COM4
Port=/dev/ttyACM1
[D-Star]
Enable=1
Module=C

View file

@ -136,7 +136,6 @@ m_pocsagNetwork(NULL),
m_fmNetwork(NULL),
m_ax25Network(NULL),
m_display(NULL),
m_ump(NULL),
m_mode(MODE_IDLE),
m_dstarRFModeHang(10U),
m_dmrRFModeHang(10U),
@ -285,21 +284,7 @@ int CMMDVMHost::run()
if (!ret)
return 1;
if (m_conf.getUMPEnabled()) {
std::string port = m_conf.getUMPPort();
LogInfo("Universal MMDVM Peripheral");
LogInfo(" Port: %s", port.c_str());
m_ump = new CUMP(port);
bool ret = m_ump->open();
if (!ret) {
delete m_ump;
m_ump = NULL;
}
}
m_display = CDisplay::createDisplay(m_conf,m_ump,m_modem);
m_display = CDisplay::createDisplay(m_conf, m_modem);
if (m_dstarEnabled && m_conf.getDStarNetworkEnabled()) {
ret = createDStarNetwork();
@ -708,14 +693,11 @@ int CMMDVMHost::run()
LogMessage("MMDVMHost-%s is running", VERSION);
while (!m_killed) {
bool lockout1 = m_modem->hasLockout();
bool lockout2 = false;
bool lockout = m_modem->hasLockout();
if (m_ump != NULL)
lockout2 = m_ump->getLockout();
if ((lockout1 || lockout2) && m_mode != MODE_LOCKOUT)
if (lockout && m_mode != MODE_LOCKOUT)
setMode(MODE_LOCKOUT);
else if ((!lockout1 && !lockout2) && m_mode == MODE_LOCKOUT)
else if (!lockout && m_mode == MODE_LOCKOUT)
setMode(MODE_IDLE);
bool error = m_modem->hasError();
@ -724,13 +706,6 @@ int CMMDVMHost::run()
else if (!error && m_mode == MODE_ERROR)
setMode(MODE_IDLE);
if (m_ump != NULL) {
bool tx = m_modem->hasTX();
m_ump->setTX(tx);
bool cd = m_modem->hasCD();
m_ump->setCD(cd);
}
unsigned char data[500U];
unsigned int len;
bool ret;
@ -1231,9 +1206,6 @@ int CMMDVMHost::run()
pocsagTimer.start();
}
if (m_ump != NULL)
m_ump->clock(ms);
if (ms < 5U)
CThread::sleep(5U);
}
@ -1246,11 +1218,6 @@ int CMMDVMHost::run()
m_display->close();
delete m_display;
if (m_ump != NULL) {
m_ump->close();
delete m_ump;
}
if (m_dmrLookup != NULL)
m_dmrLookup->stop();
@ -1877,8 +1844,6 @@ void CMMDVMHost::setMode(unsigned char mode)
if (m_ax25 != NULL)
m_ax25->enable(false);
m_modem->setMode(MODE_DSTAR);
if (m_ump != NULL)
m_ump->setMode(MODE_DSTAR);
m_mode = MODE_DSTAR;
m_modeTimer.start();
m_cwIdTimer.stop();
@ -1923,8 +1888,6 @@ void CMMDVMHost::setMode(unsigned char mode)
if (m_ax25 != NULL)
m_ax25->enable(false);
m_modem->setMode(MODE_DMR);
if (m_ump != NULL)
m_ump->setMode(MODE_DMR);
if (m_duplex) {
m_modem->writeDMRStart(true);
m_dmrTXTimer.start();
@ -1973,8 +1936,6 @@ void CMMDVMHost::setMode(unsigned char mode)
if (m_ax25 != NULL)
m_ax25->enable(false);
m_modem->setMode(MODE_YSF);
if (m_ump != NULL)
m_ump->setMode(MODE_YSF);
m_mode = MODE_YSF;
m_modeTimer.start();
m_cwIdTimer.stop();
@ -2019,8 +1980,6 @@ void CMMDVMHost::setMode(unsigned char mode)
if (m_ax25 != NULL)
m_ax25->enable(false);
m_modem->setMode(MODE_P25);
if (m_ump != NULL)
m_ump->setMode(MODE_P25);
m_mode = MODE_P25;
m_modeTimer.start();
m_cwIdTimer.stop();
@ -2065,8 +2024,6 @@ void CMMDVMHost::setMode(unsigned char mode)
if (m_ax25 != NULL)
m_ax25->enable(false);
m_modem->setMode(MODE_NXDN);
if (m_ump != NULL)
m_ump->setMode(MODE_NXDN);
m_mode = MODE_NXDN;
m_modeTimer.start();
m_cwIdTimer.stop();
@ -2103,8 +2060,6 @@ void CMMDVMHost::setMode(unsigned char mode)
if (m_pocsag != NULL)
m_pocsag->enable(false);
m_modem->setMode(MODE_M17);
if (m_ump != NULL)
m_ump->setMode(MODE_M17);
m_mode = MODE_M17;
m_modeTimer.start();
m_cwIdTimer.stop();
@ -2149,8 +2104,6 @@ void CMMDVMHost::setMode(unsigned char mode)
if (m_ax25 != NULL)
m_ax25->enable(false);
m_modem->setMode(MODE_POCSAG);
if (m_ump != NULL)
m_ump->setMode(MODE_POCSAG);
m_mode = MODE_POCSAG;
m_modeTimer.start();
m_cwIdTimer.stop();
@ -2199,8 +2152,6 @@ void CMMDVMHost::setMode(unsigned char mode)
m_dmrTXTimer.stop();
}
m_modem->setMode(MODE_FM);
if (m_ump != NULL)
m_ump->setMode(MODE_FM);
m_display->setFM();
m_mode = MODE_FM;
m_modeTimer.start();
@ -2250,8 +2201,6 @@ void CMMDVMHost::setMode(unsigned char mode)
m_dmrTXTimer.stop();
}
m_modem->setMode(MODE_IDLE);
if (m_ump != NULL)
m_ump->setMode(MODE_IDLE);
m_display->setLockout();
m_mode = MODE_LOCKOUT;
m_modeTimer.stop();
@ -2301,8 +2250,6 @@ void CMMDVMHost::setMode(unsigned char mode)
m_modem->writeDMRStart(false);
m_dmrTXTimer.stop();
}
if (m_ump != NULL)
m_ump->setMode(MODE_IDLE);
m_display->setError("MODEM");
m_mode = MODE_ERROR;
m_modeTimer.stop();
@ -2352,8 +2299,6 @@ void CMMDVMHost::setMode(unsigned char mode)
m_dmrTXTimer.stop();
}
m_modem->setMode(MODE_IDLE);
if (m_ump != NULL)
m_ump->setMode(MODE_IDLE);
if (m_mode == MODE_ERROR) {
m_modem->sendCWId(m_callsign);
m_cwIdTimer.setTimeout(m_cwIdTime);

View file

@ -44,7 +44,6 @@
#include "Timer.h"
#include "Modem.h"
#include "Conf.h"
#include "UMP.h"
#include <string>
@ -79,7 +78,6 @@ private:
CFMNetwork* m_fmNetwork;
CAX25Network* m_ax25Network;
CDisplay* m_display;
CUMP* m_ump;
unsigned char m_mode;
unsigned int m_dstarRFModeHang;
unsigned int m_dmrRFModeHang;

View file

@ -251,7 +251,6 @@
<ClInclude Include="Thread.h" />
<ClInclude Include="Timer.h" />
<ClInclude Include="UDPSocket.h" />
<ClInclude Include="UMP.h" />
<ClInclude Include="UserDB.h" />
<ClInclude Include="UserDBentry.h" />
<ClInclude Include="Utils.h" />
@ -354,7 +353,6 @@
<ClCompile Include="Thread.cpp" />
<ClCompile Include="Timer.cpp" />
<ClCompile Include="UDPSocket.cpp" />
<ClCompile Include="UMP.cpp" />
<ClCompile Include="UserDB.cpp" />
<ClCompile Include="UserDBentry.cpp" />
<ClCompile Include="Utils.cpp" />

View file

@ -215,9 +215,6 @@
<ClInclude Include="LCDproc.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="UMP.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="RSSIInterpolator.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -526,9 +523,6 @@
<ClCompile Include="LCDproc.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="UMP.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="RSSIInterpolator.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -641,4 +635,4 @@
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
</Project>

View file

@ -14,7 +14,7 @@ OBJECTS = \
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 SerialController.o SerialModem.o SerialPort.o StopWatch.o Sync.o TFTSerial.o TFTSurenoo.o Thread.o Timer.o UDPSocket.o UMP.o \
RSSIInterpolator.o SerialController.o SerialModem.o SerialPort.o StopWatch.o Sync.o TFTSerial.o TFTSurenoo.o Thread.o Timer.o UDPSocket.o \
UserDB.o UserDBentry.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
all: MMDVMHost RemoteCommand

View file

@ -14,7 +14,7 @@ OBJECTS = \
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 SerialController.o SerialModem.o SerialPort.o StopWatch.o Sync.o TFTSerial.o TFTSurenoo.o Thread.o Timer.o UDPSocket.o UMP.o \
RSSIInterpolator.o SerialController.o SerialModem.o SerialPort.o StopWatch.o Sync.o TFTSerial.o TFTSurenoo.o Thread.o Timer.o UDPSocket.o \
UserDB.o UserDBentry.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
all: MMDVMHost RemoteCommand

View file

@ -15,7 +15,7 @@ OBJECTS = \
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 SerialController.o SerialModem.o SerialPort.o StopWatch.o Sync.o TFTSerial.o TFTSurenoo.o Thread.o Timer.o UDPSocket.o UMP.o \
RSSIInterpolator.o SerialController.o SerialModem.o SerialPort.o StopWatch.o Sync.o TFTSerial.o TFTSurenoo.o Thread.o Timer.o UDPSocket.o \
UserDB.o UserDBentry.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
all: MMDVMHost RemoteCommand

View file

@ -14,7 +14,7 @@ OBJECTS = \
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 SerialController.o SerialModem.o SerialPort.o StopWatch.o Sync.o TFTSerial.o TFTSurenoo.o Thread.o Timer.o UDPSocket.o UMP.o \
RSSIInterpolator.o SerialController.o SerialModem.o SerialPort.o StopWatch.o Sync.o TFTSerial.o TFTSurenoo.o Thread.o Timer.o UDPSocket.o \
UserDB.o UserDBentry.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
all: MMDVMHost RemoteCommand

View file

@ -19,7 +19,7 @@ OBJECTS = \
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 SerialController.o SerialModem.o SerialPort.o StopWatch.o Sync.o TFTSerial.o TFTSurenoo.o Thread.o Timer.o \
UDPSocket.o UMP.o UserDB.o UserDBentry.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
UDPSocket.o UserDB.o UserDBentry.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
all: MMDVMHost RemoteCommand

View file

@ -15,7 +15,7 @@ OBJECTS = \
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 SerialController.o SerialModem.o SerialPort.o StopWatch.o Sync.o TFTSerial.o TFTSurenoo.o Thread.o Timer.o UDPSocket.o UMP.o \
RSSIInterpolator.o SerialController.o SerialModem.o SerialPort.o StopWatch.o Sync.o TFTSerial.o TFTSurenoo.o Thread.o Timer.o UDPSocket.o \
UserDB.o UserDBentry.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
all: MMDVMHost RemoteCommand

View file

@ -1,7 +1,7 @@
These are the source files for building the MMDVMHost, the program that
interfaces to the MMDVM or DVMega on the one side, and a suitable network on
the other. It supports D-Star, DMR, P25 Phase 1, NXDN, System Fusion,
POCSAG, and FM on the MMDVM, and D-Star, DMR, and System Fusion on the DVMega.
the other. It supports D-Star, DMR, P25 Phase 1, NXDN, System Fusion, M17,
POCSAG, FM, and AX.25 on the MMDVM, and D-Star, DMR, and System Fusion on the DVMega.
On the D-Star side the MMDVMHost interfaces with the ircDDB Gateway, on DMR it
can connect to BrandMeister, DMR+, TGIF, HB Link, XLX or
@ -9,7 +9,8 @@ can connect to BrandMeister, DMR+, TGIF, HB Link, XLX or
networks at once) 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. It uses the DAPNET Gateway to access DAPNET to receive
NXCore talk groups. On M17 it uses the M17 Gateway to access the M17 reflector system.
It uses the DAPNET Gateway to access DAPNET to receive
paging messages. Finally it uses the FM Gateway to interface to existing FM
networks.
@ -28,8 +29,7 @@ these are:
The Nextion displays can connect to the UART on the Raspberry Pi, or via a USB
to TTL serial converter like the FT-232RL. It may also be connected to the UART
output of the MMDVM modem (Arduino Due, STM32, Teensy), or to the UART output
on the UMP.
output of the MMDVM modem (Arduino Due, STM32, Teensy).
The HD44780 displays are integrated with wiringPi for Raspberry Pi based
platforms.

283
UMP.cpp
View file

@ -1,283 +0,0 @@
/*
* Copyright (C) 2016,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 "Defines.h"
#include "Utils.h"
#include "Log.h"
#include "UMP.h"
#include <cstdio>
#include <cassert>
#include <cstring>
const unsigned char UMP_FRAME_START = 0xF0U;
const unsigned char UMP_HELLO = 0x00U;
const unsigned char UMP_SET_MODE = 0x01U;
const unsigned char UMP_SET_TX = 0x02U;
const unsigned char UMP_SET_CD = 0x03U;
const unsigned char UMP_WRITE_SERIAL = 0x10U;
const unsigned char UMP_READ_SERIAL = 0x11U;
const unsigned char UMP_STATUS = 0x50U;
const unsigned int BUFFER_LENGTH = 255U;
CUMP::CUMP(const std::string& port) :
m_serial(port, 115200U),
m_open(false),
m_buffer(NULL),
m_length(0U),
m_offset(0U),
m_lockout(false),
m_mode(MODE_IDLE),
m_tx(false),
m_cd(false)
{
m_buffer = new unsigned char[BUFFER_LENGTH];
}
CUMP::~CUMP()
{
delete[] m_buffer;
}
bool CUMP::open()
{
if (m_open)
return true;
LogMessage("Opening the UMP");
bool ret = m_serial.open();
if (!ret)
return false;
unsigned char buffer[3U];
buffer[0U] = UMP_FRAME_START;
buffer[1U] = 3U;
buffer[2U] = UMP_HELLO;
// CUtils::dump(1U, "Transmitted", buffer, 3U);
int n = m_serial.write(buffer, 3U);
if (n != 3) {
m_serial.close();
return false;
}
m_open = true;
return true;
}
bool CUMP::setMode(unsigned char mode)
{
if (mode == m_mode)
return true;
m_mode = mode;
unsigned char buffer[4U];
buffer[0U] = UMP_FRAME_START;
buffer[1U] = 4U;
buffer[2U] = UMP_SET_MODE;
buffer[3U] = mode;
// CUtils::dump(1U, "Transmitted", buffer, 4U);
return m_serial.write(buffer, 4U) == 4;
}
bool CUMP::setTX(bool on)
{
if (on == m_tx)
return true;
m_tx = on;
unsigned char buffer[4U];
buffer[0U] = UMP_FRAME_START;
buffer[1U] = 4U;
buffer[2U] = UMP_SET_TX;
buffer[3U] = on ? 0x01U : 0x00U;
// CUtils::dump(1U, "Transmitted", buffer, 4U);
return m_serial.write(buffer, 4U) == 4;
}
bool CUMP::setCD(bool on)
{
if (on == m_cd)
return true;
m_cd = on;
unsigned char buffer[4U];
buffer[0U] = UMP_FRAME_START;
buffer[1U] = 4U;
buffer[2U] = UMP_SET_CD;
buffer[3U] = on ? 0x01U : 0x00U;
// CUtils::dump(1U, "Transmitted", buffer, 4U);
return m_serial.write(buffer, 4U) == 4;
}
bool CUMP::getLockout() const
{
return m_lockout;
}
int CUMP::write(const unsigned char* data, unsigned int length)
{
assert(data != NULL);
assert(length > 0U);
unsigned char buffer[250U];
buffer[0U] = UMP_FRAME_START;
buffer[1U] = length + 3U;
buffer[2U] = UMP_WRITE_SERIAL;
::memcpy(buffer + 3U, data, length);
// CUtils::dump(1U, "Transmitted", buffer, length + 3U);
return m_serial.write(buffer, length + 3U);
}
// To be implemented later if needed
int CUMP::read(unsigned char* data, unsigned int length)
{
assert(data != NULL);
assert(length > 0U);
return 0;
}
void CUMP::clock(unsigned int ms)
{
if (m_offset == 0U) {
// Get the start of the frame or nothing at all
int ret = m_serial.read(m_buffer + 0U, 1U);
if (ret < 0) {
LogError("Error when reading from the UMP");
return;
}
if (ret == 0)
return;
if (m_buffer[0U] != UMP_FRAME_START)
return;
m_offset = 1U;
}
if (m_offset == 1U) {
// Get the length of the frame
int ret = m_serial.read(m_buffer + 1U, 1U);
if (ret < 0) {
LogError("Error when reading from the UMP");
m_offset = 0U;
return;
}
if (ret == 0)
return;
if (m_buffer[1U] >= 250U) {
LogError("Invalid length received from the UMP - %u", m_buffer[1U]);
m_offset = 0U;
return;
}
m_length = m_buffer[1U];
m_offset = 2U;
}
if (m_offset == 2U) {
// Get the frame type
int ret = m_serial.read(m_buffer + 2U, 1U);
if (ret < 0) {
LogError("Error when reading from the UMP");
m_offset = 0U;
return;
}
if (ret == 0)
return;
switch (m_buffer[2U]) {
case UMP_STATUS:
case UMP_READ_SERIAL:
break;
default:
LogError("Unknown message, type: %02X", m_buffer[2U]);
m_offset = 0U;
return;
}
m_offset = 3U;
}
if (m_offset >= 3U) {
while (m_offset < m_length) {
int ret = m_serial.read(m_buffer + m_offset, m_length - m_offset);
if (ret < 0) {
LogError("Error when reading from the UMP");
m_offset = 0U;
return;
}
if (ret == 0)
return;
if (ret > 0)
m_offset += ret;
}
}
m_offset = 0U;
// CUtils::dump(1U, "Received", m_buffer, m_length);
if (m_buffer[2U] == UMP_STATUS)
m_lockout = (m_buffer[3U] & 0x01U) == 0x01U;
}
void CUMP::close()
{
if (!m_open)
return;
LogMessage("Closing the UMP");
m_serial.close();
m_open = false;
}

63
UMP.h
View file

@ -1,63 +0,0 @@
/*
* Copyright (C) 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
* 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.
*/
#if !defined(UMP_H)
#define UMP_H
#include "SerialController.h"
#include "SerialPort.h"
#include <string>
class CUMP : public ISerialPort
{
public:
CUMP(const std::string& port);
virtual ~CUMP();
virtual bool open();
bool setMode(unsigned char mode);
bool setTX(bool on);
bool setCD(bool on);
bool getLockout() const;
virtual int read(unsigned char* buffer, unsigned int length);
virtual int write(const unsigned char* buffer, unsigned int length);
void clock(unsigned int ms);
virtual void close();
private:
CSerialController m_serial;
bool m_open;
unsigned char* m_buffer;
unsigned int m_length;
unsigned int m_offset;
bool m_lockout;
unsigned char m_mode;
bool m_tx;
bool m_cd;
};
#endif

View file

@ -1,203 +0,0 @@
/*
* Copyright (C) 2016,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.
*/
#if !defined(__AVR_ATmega1280__) && !defined(__AVR_ATmega2560__) && !defined(__AVR_ATmega32U4__) && !defined(__SAM3X8E__) && !defined(__MK20DX256__)
#include <AltSoftSerial.h>
#endif
#if !defined(PIN_LED)
#define PIN_LED 13
#endif
#define PIN_DSTAR 3
#define PIN_DMR 4
#define PIN_YSF 5
#define PIN_P25 6
#define PIN_NXDN 7
#define PIN_POCSAG 8
#define PIN_TX 10
#define PIN_CD 11
#define PIN_LOCKOUT 12
#if defined(__MK20DX256__)
#define FLASH_DELAY 200000U
#else
#define FLASH_DELAY 3200U
#endif
#if !defined(__AVR_ATmega1280__) && !defined(__AVR_ATmega2560__) && !defined(__AVR_ATmega32U4__) && !defined(__SAM3X8E__) && !defined(__MK20DX256__)
AltSoftSerial mySerial;
#endif
// Use the LOCKOUT function on the UMP
// #define USE_LOCKOUT
void setup()
{
Serial.begin(115200);
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega32U4__) || defined(__SAM3X8E__) || defined(__MK20DX256__)
Serial1.begin(9600);
#else
mySerial.begin(9600);
#endif
pinMode(PIN_LED, OUTPUT);
pinMode(PIN_DSTAR, OUTPUT);
pinMode(PIN_DMR, OUTPUT);
pinMode(PIN_YSF, OUTPUT);
pinMode(PIN_P25, OUTPUT);
pinMode(PIN_NXDN, OUTPUT);
pinMode(PIN_POCSAG, OUTPUT);
pinMode(PIN_TX, OUTPUT);
pinMode(PIN_CD, OUTPUT);
pinMode(PIN_LOCKOUT, INPUT);
digitalWrite(PIN_DSTAR, LOW);
digitalWrite(PIN_DMR, LOW);
digitalWrite(PIN_YSF, LOW);
digitalWrite(PIN_P25, LOW);
digitalWrite(PIN_NXDN, LOW);
digitalWrite(PIN_POCSAG, LOW);
digitalWrite(PIN_TX, LOW);
digitalWrite(PIN_CD, LOW);
}
#define UMP_FRAME_START 0xF0U
#define UMP_HELLO 0x00U
#define UMP_SET_MODE 0x01U
#define UMP_SET_TX 0x02U
#define UMP_SET_CD 0x03U
#define UMP_WRITE_SERIAL 0x10U
#define UMP_STATUS 0x50U
#define MODE_IDLE 0U
#define MODE_DSTAR 1U
#define MODE_DMR 2U
#define MODE_YSF 3U
#define MODE_P25 4U
#define MODE_NXDN 5U
#define MODE_POCSAG 6U
bool m_started = false;
uint32_t m_count = 0U;
bool m_led = false;
uint8_t m_buffer[256U];
uint8_t m_offset = 0U;
uint8_t m_length = 0U;
bool m_lockout = false;
void loop()
{
while (Serial.available()) {
uint8_t c = Serial.read();
if (m_offset == 0U) {
if (c == UMP_FRAME_START) {
m_buffer[m_offset] = c;
m_offset = 1U;
}
} else if (m_offset == 1U) {
m_length = m_buffer[m_offset] = c;
m_offset = 2U;
} else {
m_buffer[m_offset] = c;
m_offset++;
if (m_length == m_offset) {
switch (m_buffer[2U]) {
case UMP_HELLO:
m_started = true;
break;
case UMP_SET_MODE:
digitalWrite(PIN_DSTAR, m_buffer[3U] == MODE_DSTAR ? HIGH : LOW);
digitalWrite(PIN_DMR, m_buffer[3U] == MODE_DMR ? HIGH : LOW);
digitalWrite(PIN_YSF, m_buffer[3U] == MODE_YSF ? HIGH : LOW);
digitalWrite(PIN_P25, m_buffer[3U] == MODE_P25 ? HIGH : LOW);
digitalWrite(PIN_NXDN, m_buffer[3U] == MODE_NXDN ? HIGH : LOW);
digitalWrite(PIN_POCSAG, m_buffer[3U] == MODE_POCSAG ? HIGH : LOW);
break;
case UMP_SET_TX:
digitalWrite(PIN_TX, m_buffer[3U] == 0x01U ? HIGH : LOW);
break;
case UMP_SET_CD:
digitalWrite(PIN_CD, m_buffer[3U] == 0x01U ? HIGH : LOW);
break;
case UMP_WRITE_SERIAL:
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega32U4__) || defined(__SAM3X8E__) || defined(__MK20DX256__)
Serial1.write(m_buffer + 3U, m_length - 3U);
#else
mySerial.write(m_buffer + 3U, m_length - 3U);
#endif
break;
default:
break;
}
m_length = 0U;
m_offset = 0U;
}
}
}
bool lockout = false;
#if defined(USE_LOCKOUT)
lockout = digitalRead(PIN_LOCKOUT) == HIGH;
#endif
if (lockout != m_lockout) {
uint8_t data[4U];
data[0U] = UMP_FRAME_START;
data[1U] = 4U;
data[2U] = UMP_STATUS;
data[3U] = lockout ? 0x01U : 0x00U;
Serial.write(data, 4U);
m_lockout = lockout;
}
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega32U4__) || defined(__SAM3X8E__) || defined(__MK20DX256__)
while (Serial1.available())
Serial1.read();
#else
while (mySerial.available())
mySerial.read();
#endif
m_count++;
if (m_started) {
if (m_count > FLASH_DELAY) {
digitalWrite(PIN_LED, m_led ? LOW : HIGH);
m_led = !m_led;
m_count = 0U;
}
} else {
if (m_count > (FLASH_DELAY * 3U)) {
digitalWrite(PIN_LED, m_led ? LOW : HIGH);
m_led = !m_led;
m_count = 0U;
}
}
}