Skip to content

Commit

Permalink
Add an optional transmi DC offset value.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed Aug 20, 2017
1 parent 7b93ed1 commit 9a78285
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 28 deletions.
28 changes: 18 additions & 10 deletions Conf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ m_modemTXInvert(false),
m_modemPTTInvert(false),
m_modemTXDelay(100U),
m_modemDMRDelay(0U),
m_modemTxOffset(0),
m_modemRxOffset(0),
m_modemTXOffset(0),
m_modemRXOffset(0),
m_modemTXDCOffset(0),
m_modemRXLevel(50.0F),
m_modemCWIdTXLevel(50.0F),
m_modemDStarTXLevel(50.0F),
Expand Down Expand Up @@ -340,9 +341,11 @@ bool CConf::read()
else if (::strcmp(key, "DMRDelay") == 0)
m_modemDMRDelay = (unsigned int)::atoi(value);
else if (::strcmp(key, "RXOffset") == 0)
m_modemRxOffset = ::atoi(value);
m_modemRXOffset = ::atoi(value);
else if (::strcmp(key, "TXOffset") == 0)
m_modemTxOffset = ::atoi(value);
m_modemTXOffset = ::atoi(value);
else if (::strcmp(key, "TXDCOffset") == 0)
m_modemTXDCOffset = ::atoi(value);
else if (::strcmp(key, "RXLevel") == 0)
m_modemRXLevel = float(::atof(value));
else if (::strcmp(key, "TXLevel") == 0)
Expand Down Expand Up @@ -647,12 +650,12 @@ bool CConf::getDaemon() const
return m_daemon;
}

unsigned int CConf::getRxFrequency() const
unsigned int CConf::getRXFrequency() const
{
return m_rxFrequency;
}

unsigned int CConf::getTxFrequency() const
unsigned int CConf::getTXFrequency() const
{
return m_txFrequency;
}
Expand Down Expand Up @@ -767,14 +770,19 @@ unsigned int CConf::getModemDMRDelay() const
return m_modemDMRDelay;
}

int CConf::getModemRxOffset() const
int CConf::getModemRXOffset() const
{
return m_modemRxOffset;
return m_modemRXOffset;
}

int CConf::getModemTxOffset() const
int CConf::getModemTXOffset() const
{
return m_modemTxOffset;
return m_modemTXOffset;
}

int CConf::getModemTXDCOffset() const
{
return m_modemTXDCOffset;
}

float CConf::getModemRXLevel() const
Expand Down
14 changes: 8 additions & 6 deletions Conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class CConf
bool getDaemon() const;

// The Info section
unsigned int getRxFrequency() const;
unsigned int getTxFrequency() const;
unsigned int getRXFrequency() const;
unsigned int getTXFrequency() const;
unsigned int getPower() const;
float getLatitude() const;
float getLongitude() const;
Expand Down Expand Up @@ -73,8 +73,9 @@ class CConf
bool getModemPTTInvert() const;
unsigned int getModemTXDelay() const;
unsigned int getModemDMRDelay() const;
int getModemTxOffset() const;
int getModemRxOffset() const;
int getModemTXOffset() const;
int getModemRXOffset() const;
int getModemTXDCOffset() const;
float getModemRXLevel() const;
float getModemCWIdTXLevel() const;
float getModemDStarTXLevel() const;
Expand Down Expand Up @@ -239,8 +240,9 @@ class CConf
bool m_modemPTTInvert;
unsigned int m_modemTXDelay;
unsigned int m_modemDMRDelay;
int m_modemTxOffset;
int m_modemRxOffset;
int m_modemTXOffset;
int m_modemRXOffset;
int m_modemTXDCOffset;
float m_modemRXLevel;
float m_modemCWIdTXLevel;
float m_modemDStarTXLevel;
Expand Down
1 change: 1 addition & 0 deletions MMDVM.ini
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ TXOffset=0
DMRDelay=0
RXLevel=50
TXLevel=50
TXDCOffset=0
# CWIdTXLevel=50
# D-StarTXLevel=50
# DMRTXLevel=50
Expand Down
16 changes: 9 additions & 7 deletions MMDVMHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -828,10 +828,11 @@ bool CMMDVMHost::createModem()
bool debug = m_conf.getModemDebug();
unsigned int colorCode = m_conf.getDMRColorCode();
bool lowDeviation = m_conf.getFusionLowDeviation();
unsigned int rxFrequency = m_conf.getRxFrequency();
unsigned int txFrequency = m_conf.getTxFrequency();
int rxOffset = m_conf.getModemRxOffset();
int txOffset = m_conf.getModemTxOffset();
unsigned int rxFrequency = m_conf.getRXFrequency();
unsigned int txFrequency = m_conf.getTXFrequency();
int rxOffset = m_conf.getModemRXOffset();
int txOffset = m_conf.getModemTXOffset();
int txDCOffset = m_conf.getModemTXDCOffset();

LogInfo("Modem Parameters");
LogInfo(" Port: %s", port.c_str());
Expand All @@ -841,6 +842,7 @@ bool CMMDVMHost::createModem()
LogInfo(" TX Delay: %ums", txDelay);
LogInfo(" RX Offset: %dHz", rxOffset);
LogInfo(" TX Offset: %dHz", txOffset);
LogInfo(" TX DC Offset: %d", txDCOffset);
LogInfo(" DMR Delay: %u (%.1fms)", dmrDelay, float(dmrDelay) * 0.0416666F);
LogInfo(" RX Level: %.1f%%", rxLevel);
LogInfo(" CW Id TX Level: %.1f%%", cwIdTXLevel);
Expand All @@ -854,7 +856,7 @@ bool CMMDVMHost::createModem()
m_modem = new CModem(port, m_duplex, rxInvert, txInvert, pttInvert, txDelay, dmrDelay, trace, debug);
m_modem->setModeParams(m_dstarEnabled, m_dmrEnabled, m_ysfEnabled, m_p25Enabled);
m_modem->setLevels(rxLevel, cwIdTXLevel, dstarTXLevel, dmrTXLevel, ysfTXLevel, p25TXLevel);
m_modem->setRFParams(rxFrequency, rxOffset, txFrequency, txOffset);
m_modem->setRFParams(rxFrequency, rxOffset, txFrequency, txOffset, txDCOffset);
m_modem->setDMRParams(colorCode);
m_modem->setYSFParams(lowDeviation);

Expand Down Expand Up @@ -926,8 +928,8 @@ bool CMMDVMHost::createDMRNetwork()
m_dmrNetwork->setOptions(options);
}

unsigned int rxFrequency = m_conf.getRxFrequency();
unsigned int txFrequency = m_conf.getTxFrequency();
unsigned int rxFrequency = m_conf.getRXFrequency();
unsigned int txFrequency = m_conf.getTXFrequency();
unsigned int power = m_conf.getPower();
unsigned int colorCode = m_conf.getDMRColorCode();
float latitude = m_conf.getLatitude();
Expand Down
12 changes: 8 additions & 4 deletions Modem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ m_dstarEnabled(false),
m_dmrEnabled(false),
m_ysfEnabled(false),
m_p25Enabled(false),
m_txDCOffset(0),
m_serial(port, SERIAL_115200, true),
m_buffer(NULL),
m_length(0U),
Expand Down Expand Up @@ -145,10 +146,11 @@ CModem::~CModem()
delete[] m_buffer;
}

void CModem::setRFParams(unsigned int rxFrequency, int rxOffset, unsigned int txFrequency, int txOffset)
void CModem::setRFParams(unsigned int rxFrequency, int rxOffset, unsigned int txFrequency, int txOffset, int txDCOffset)
{
m_rxFrequency = rxFrequency + rxOffset;
m_txFrequency = txFrequency + txOffset;
m_txDCOffset = txDCOffset;
}

void CModem::setModeParams(bool dstarEnabled, bool dmrEnabled, bool ysfEnabled, bool p25Enabled)
Expand Down Expand Up @@ -990,10 +992,12 @@ bool CModem::setConfig()
buffer[14U] = (unsigned char)(m_ysfTXLevel * 2.55F + 0.5F);
buffer[15U] = (unsigned char)(m_p25TXLevel * 2.55F + 0.5F);

// CUtils::dump(1U, "Written", buffer, 16U);
buffer[16U] = (unsigned char)(m_txDCOffset + 128);

int ret = m_serial.write(buffer, 16U);
if (ret != 16)
// CUtils::dump(1U, "Written", buffer, 17U);

int ret = m_serial.write(buffer, 17U);
if (ret != 17)
return false;

unsigned int count = 0U;
Expand Down
3 changes: 2 additions & 1 deletion Modem.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class 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();

void setRFParams(unsigned int rxFrequency, int rxOffset, unsigned int txFrequency, int txOffset);
void setRFParams(unsigned int rxFrequency, int rxOffset, unsigned int txFrequency, int txOffset, int txDCOffset);
void setModeParams(bool dstarEnabled, bool dmrEnabled, bool ysfEnabled, bool p25Enabled);
void setLevels(float rxLevel, float cwIdTXLevel, float dstarTXLevel, float dmrTXLevel, float ysfTXLevel, float p25Enabled);
void setDMRParams(unsigned int colorCode);
Expand Down Expand Up @@ -111,6 +111,7 @@ class CModem {
bool m_dmrEnabled;
bool m_ysfEnabled;
bool m_p25Enabled;
int m_txDCOffset;
CSerialController m_serial;
unsigned char* m_buffer;
unsigned int m_length;
Expand Down

0 comments on commit 9a78285

Please sign in to comment.