Skip to content

Commit

Permalink
Add the host support for the UMP.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed Nov 3, 2016
1 parent 2ac7e43 commit 015896a
Show file tree
Hide file tree
Showing 16 changed files with 410 additions and 23 deletions.
32 changes: 26 additions & 6 deletions Conf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ enum SECTION {
SECTION_CWID,
SECTION_DMRID_LOOKUP,
SECTION_MODEM,
SECTION_UMP,
SECTION_DSTAR,
SECTION_DMR,
SECTION_FUSION,
Expand Down Expand Up @@ -93,6 +94,8 @@ m_modemOscOffset(0),
m_modemRSSIMultiplier(0),
m_modemRSSIOffset(0),
m_modemDebug(false),
m_umpEnabled(false),
m_umpPort(),
m_dstarEnabled(false),
m_dstarModule("C"),
m_dstarSelfOnly(false),
Expand Down Expand Up @@ -207,7 +210,9 @@ bool CConf::read()
else if (::strncmp(buffer, "[DMR Id Lookup]", 15U) == 0)
section = SECTION_DMRID_LOOKUP;
else if (::strncmp(buffer, "[Modem]", 7U) == 0)
section = SECTION_MODEM;
section = SECTION_MODEM;
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)
Expand All @@ -217,15 +222,15 @@ bool CConf::read()
else if (::strncmp(buffer, "[P25]", 5U) == 0)
section = SECTION_P25;
else if (::strncmp(buffer, "[D-Star Network]", 16U) == 0)
section = SECTION_DSTAR_NETWORK;
section = SECTION_DSTAR_NETWORK;
else if (::strncmp(buffer, "[DMR Network]", 13U) == 0)
section = SECTION_DMR_NETWORK;
section = SECTION_DMR_NETWORK;
else if (::strncmp(buffer, "[System Fusion Network]", 23U) == 0)
section = SECTION_FUSION_NETWORK;
section = SECTION_FUSION_NETWORK;
else if (::strncmp(buffer, "[P25 Network]", 13U) == 0)
section = SECTION_P25_NETWORK;
else if (::strncmp(buffer, "[TFT Serial]", 12U) == 0)
section = SECTION_TFTSERIAL;
section = SECTION_TFTSERIAL;
else if (::strncmp(buffer, "[HD44780]", 9U) == 0)
section = SECTION_HD44780;
else if (::strncmp(buffer, "[Nextion]", 9U) == 0)
Expand All @@ -235,7 +240,7 @@ bool CConf::read()
else if (::strncmp(buffer, "[LCDproc]", 9U) == 0)
section = SECTION_LCDPROC;
else
section = SECTION_NONE;
section = SECTION_NONE;

continue;
}
Expand Down Expand Up @@ -338,6 +343,11 @@ bool CConf::read()
m_modemRSSIOffset = ::atoi(value);
else if (::strcmp(key, "Debug") == 0)
m_modemDebug = ::atoi(value) == 1;
} 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;
Expand Down Expand Up @@ -802,6 +812,16 @@ bool CConf::getModemDebug() const
return m_modemDebug;
}

bool CConf::getUMPEnabled() const
{
return m_umpEnabled;
}

std::string CConf::getUMPPort() const
{
return m_umpPort;
}

bool CConf::getDStarEnabled() const
{
return m_dstarEnabled;
Expand Down
7 changes: 7 additions & 0 deletions Conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ class CConf
int getModemRSSIOffset() const;
bool getModemDebug() const;

// The UMP section
bool getUMPEnabled() const;
std::string getUMPPort() const;

// The D-Star section
bool getDStarEnabled() const;
std::string getDStarModule() const;
Expand Down Expand Up @@ -237,6 +241,9 @@ class CConf
int m_modemRSSIOffset;
bool m_modemDebug;

bool m_umpEnabled;
std::string m_umpPort;

bool m_dstarEnabled;
std::string m_dstarModule;
bool m_dstarSelfOnly;
Expand Down
5 changes: 5 additions & 0 deletions MMDVM.ini
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ RSSIMultiplier=1
RSSIOffset=10
Debug=0

[UMP]
Enable=0
# Port=\\.\COM4
Port=/dev/ttyACM1

[D-Star]
Enable=1
Module=C
Expand Down
68 changes: 58 additions & 10 deletions MMDVMHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ m_dmrNetwork(NULL),
m_ysfNetwork(NULL),
m_p25Network(NULL),
m_display(NULL),
m_ump(NULL),
m_mode(MODE_IDLE),
m_rfModeHang(10U),
m_netModeHang(3U),
Expand Down Expand Up @@ -240,6 +241,20 @@ 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;
}
}

createDisplay();

if (m_dstarEnabled && m_conf.getDStarNetworkEnabled()) {
Expand Down Expand Up @@ -420,10 +435,13 @@ int CMMDVMHost::run()
LogMessage("MMDVMHost-%s is running", VERSION);

while (!m_killed) {
bool lockout = m_modem->hasLockout();
if (lockout && m_mode != MODE_LOCKOUT)
bool lockout1 = m_modem->hasLockout();
bool lockout2 = false;
if (m_ump != NULL)
lockout2 = m_ump->getLockout();
if ((lockout1 || lockout2) && m_mode != MODE_LOCKOUT)
setMode(MODE_LOCKOUT);
else if (!lockout && m_mode == MODE_LOCKOUT)
else if ((!lockout1 && !lockout2) && m_mode == MODE_LOCKOUT)
setMode(MODE_IDLE);

bool error = m_modem->hasError();
Expand All @@ -432,6 +450,11 @@ 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);
}

unsigned char data[200U];
unsigned int len;
bool ret;
Expand Down Expand Up @@ -719,6 +742,9 @@ int CMMDVMHost::run()
m_dmrTXTimer.stop();
}

if (m_ump != NULL)
m_ump->clock(ms);

if (ms < 5U)
CThread::sleep(5U);
}
Expand All @@ -733,6 +759,11 @@ int CMMDVMHost::run()
m_display->close();
delete m_display;

if (m_ump != NULL) {
m_ump->close();
delete m_ump;
}

if (m_lookup != NULL)
m_lookup->stop();

Expand Down Expand Up @@ -1024,13 +1055,16 @@ void CMMDVMHost::createDisplay()
LogInfo(" Display UTC: %s", utc ? "yes" : "no");
LogInfo(" Idle Brightness: %u", idleBrightness);

ISerialPort* serial = NULL;
if (port == "modem")
serial = new CModemSerialPort(m_modem);
else
serial = new CSerialController(port, SERIAL_9600);

m_display = new CNextion(m_callsign, dmrid, serial, brightness, displayClock, utc, idleBrightness);
if (port == "modem") {
ISerialPort* serial = new CModemSerialPort(m_modem);
m_display = new CNextion(m_callsign, dmrid, serial, brightness, displayClock, utc, idleBrightness);
} else if (port == "ump") {
if (m_ump != NULL)
m_display = new CNextion(m_callsign, dmrid, m_ump, brightness, displayClock, utc, idleBrightness);
} else {
ISerialPort* serial = new CSerialController(port, SERIAL_9600);
m_display = new CNextion(m_callsign, dmrid, serial, brightness, displayClock, utc, idleBrightness);
}
} else if (type == "LCDproc") {
std::string address = m_conf.getLCDprocAddress();
unsigned int port = m_conf.getLCDprocPort();
Expand Down Expand Up @@ -1124,6 +1158,8 @@ void CMMDVMHost::setMode(unsigned char mode)
if (m_p25Network != NULL)
m_p25Network->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();
Expand All @@ -1137,6 +1173,8 @@ void CMMDVMHost::setMode(unsigned char mode)
if (m_p25Network != NULL)
m_p25Network->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();
Expand All @@ -1154,6 +1192,8 @@ void CMMDVMHost::setMode(unsigned char mode)
if (m_p25Network != NULL)
m_p25Network->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();
Expand All @@ -1167,6 +1207,8 @@ void CMMDVMHost::setMode(unsigned char mode)
if (m_ysfNetwork != NULL)
m_ysfNetwork->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();
Expand All @@ -1187,6 +1229,8 @@ 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();
Expand All @@ -1207,6 +1251,8 @@ 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();
Expand All @@ -1227,6 +1273,8 @@ 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_mode == MODE_LOCKOUT) {
m_modem->sendCWId(m_callsign);
m_cwIdTimer.setTimeout(m_cwIdTime);
Expand Down
2 changes: 2 additions & 0 deletions MMDVMHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "Timer.h"
#include "Modem.h"
#include "Conf.h"
#include "UMP.h"

#include <string>

Expand All @@ -47,6 +48,7 @@ class CMMDVMHost
CYSFNetwork* m_ysfNetwork;
CP25Network* m_p25Network;
CDisplay* m_display;
CUMP* m_ump;
unsigned char m_mode;
unsigned int m_rfModeHang;
unsigned int m_netModeHang;
Expand Down
2 changes: 2 additions & 0 deletions MMDVMHost.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@
<ClInclude Include="Thread.h" />
<ClInclude Include="Timer.h" />
<ClInclude Include="UDPSocket.h" />
<ClInclude Include="UMP.h" />
<ClInclude Include="Utils.h" />
<ClInclude Include="Version.h" />
<ClInclude Include="YSFControl.h" />
Expand Down Expand Up @@ -271,6 +272,7 @@
<ClCompile Include="Thread.cpp" />
<ClCompile Include="Timer.cpp" />
<ClCompile Include="UDPSocket.cpp" />
<ClCompile Include="UMP.cpp" />
<ClCompile Include="Utils.cpp" />
<ClCompile Include="YSFNetwork.cpp" />
<ClCompile Include="YSFPayload.cpp" />
Expand Down
6 changes: 6 additions & 0 deletions MMDVMHost.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@
<ClInclude Include="LCDproc.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="UMP.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="BPTC19696.cpp">
Expand Down Expand Up @@ -400,5 +403,8 @@
<ClCompile Include="LCDproc.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="UMP.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ OBJECTS = \
DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o Golay2087.o \
Golay24128.o Hamming.o LCDproc.o Log.o MMDVMHost.o Modem.o ModemSerialPort.o Mutex.o Nextion.o NullDisplay.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o \
P25Network.o P25NID.o P25Utils.o QR1676.o RS129.o RS241213.o SerialController.o SerialPort.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o Timer.o UDPSocket.o \
Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
UMP.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o

all: MMDVMHost

Expand Down
2 changes: 1 addition & 1 deletion Makefile.Pi
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ OBJECTS = \
DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o Golay2087.o \
Golay24128.o Hamming.o LCDproc.o Log.o MMDVMHost.o Modem.o ModemSerialPort.o Mutex.o Nextion.o NullDisplay.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o \
P25Network.o P25NID.o P25Utils.o QR1676.o RS129.o RS241213.o SerialController.o SerialPort.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o Timer.o UDPSocket.o \
Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
UMP.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o

all: MMDVMHost

Expand Down
2 changes: 1 addition & 1 deletion Makefile.Pi.Adafruit
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ OBJECTS = \
DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o Golay2087.o \
Golay24128.o Hamming.o HD44780.o LCDproc.o Log.o MMDVMHost.o Modem.o ModemSerialPort.o Mutex.o Nextion.o NullDisplay.o P25Audio.o P25Control.o P25Data.o \
P25LowSpeedData.o P25Network.o P25NID.o P25Utils.o QR1676.o RS129.o RS241213.o SerialController.o SerialPort.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o \
Timer.o UDPSocket.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
Timer.o UDPSocket.o UMP.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o

all: MMDVMHost

Expand Down
2 changes: 1 addition & 1 deletion Makefile.Pi.HD44780
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ OBJECTS = \
DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o Golay2087.o \
Golay24128.o Hamming.o HD44780.o LCDproc.o Log.o MMDVMHost.o Modem.o ModemSerialPort.o Mutex.o Nextion.o NullDisplay.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o \
P25Network.o P25NID.o P25Utils.o QR1676.o RS129.o RS241213.o SerialController.o SerialPort.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o Timer.o UDPSocket.o \
Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
UMP.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o

all: MMDVMHost

Expand Down
2 changes: 1 addition & 1 deletion Makefile.Pi.OLED
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ OBJECTS = \
DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o Golay2087.o \
Golay24128.o Hamming.o OLED.o LCDproc.o Log.o MMDVMHost.o Modem.o ModemSerialPort.o Mutex.o Nextion.o NullDisplay.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o \
P25Network.o P25NID.o P25Utils.o QR1676.o RS129.o RS241213.o SerialController.o SerialPort.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o Timer.o UDPSocket.o \
Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
UMP.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o

all: MMDVMHost

Expand Down
2 changes: 1 addition & 1 deletion Makefile.Pi.PCF8574
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ OBJECTS = \
DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o Golay2087.o \
Golay24128.o Hamming.o HD44780.o LCDproc.o Log.o MMDVMHost.o Modem.o ModemSerialPort.o Mutex.o Nextion.o NullDisplay.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o \
P25Network.o P25NID.o P25Utils.o QR1676.o RS129.o RS241213.o SerialController.o SerialPort.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o Timer.o UDPSocket.o \
Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o
UMP.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o

all: MMDVMHost

Expand Down
Loading

0 comments on commit 015896a

Please sign in to comment.