Skip to content

Commit

Permalink
Add the optional RX DC Offset parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed Oct 28, 2017
1 parent 5049802 commit 066e5f0
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 7 deletions.
8 changes: 8 additions & 0 deletions Conf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ m_modemTXDelay(100U),
m_modemDMRDelay(0U),
m_modemTXOffset(0),
m_modemRXOffset(0),
m_modemRXDCOffset(0),
m_modemTXDCOffset(0),
m_modemRXLevel(50.0F),
m_modemCWIdTXLevel(50.0F),
Expand Down Expand Up @@ -351,6 +352,8 @@ bool CConf::read()
m_modemRXOffset = ::atoi(value);
else if (::strcmp(key, "TXOffset") == 0)
m_modemTXOffset = ::atoi(value);
else if (::strcmp(key, "RXDCOffset") == 0)
m_modemRXDCOffset = ::atoi(value);
else if (::strcmp(key, "TXDCOffset") == 0)
m_modemTXDCOffset = ::atoi(value);
else if (::strcmp(key, "RXLevel") == 0)
Expand Down Expand Up @@ -793,6 +796,11 @@ int CConf::getModemTXOffset() const
return m_modemTXOffset;
}

int CConf::getModemRXDCOffset() const
{
return m_modemRXDCOffset;
}

int CConf::getModemTXDCOffset() const
{
return m_modemTXDCOffset;
Expand Down
2 changes: 2 additions & 0 deletions Conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class CConf
unsigned int getModemDMRDelay() const;
int getModemTXOffset() const;
int getModemRXOffset() const;
int getModemRXDCOffset() const;
int getModemTXDCOffset() const;
float getModemRXLevel() const;
float getModemCWIdTXLevel() const;
Expand Down Expand Up @@ -246,6 +247,7 @@ class CConf
unsigned int m_modemDMRDelay;
int m_modemTXOffset;
int m_modemRXOffset;
int m_modemRXDCOffset;
int m_modemTXDCOffset;
float m_modemRXLevel;
float m_modemCWIdTXLevel;
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
RXDCOffset=0
TXDCOffset=0
# CWIdTXLevel=50
# D-StarTXLevel=50
Expand Down
4 changes: 3 additions & 1 deletion MMDVMHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,7 @@ bool CMMDVMHost::createModem()
unsigned int txFrequency = m_conf.getTXFrequency();
int rxOffset = m_conf.getModemRXOffset();
int txOffset = m_conf.getModemTXOffset();
int rxDCOffset = m_conf.getModemRXDCOffset();
int txDCOffset = m_conf.getModemTXDCOffset();

LogInfo("Modem Parameters");
Expand All @@ -858,6 +859,7 @@ bool CMMDVMHost::createModem()
LogInfo(" TX Delay: %ums", txDelay);
LogInfo(" RX Offset: %dHz", rxOffset);
LogInfo(" TX Offset: %dHz", txOffset);
LogInfo(" RX DC Offset: %d", rxDCOffset);
LogInfo(" TX DC Offset: %d", txDCOffset);
LogInfo(" DMR Delay: %u (%.1fms)", dmrDelay, float(dmrDelay) * 0.0416666F);
LogInfo(" RX Level: %.1f%%", rxLevel);
Expand All @@ -872,7 +874,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, txDCOffset);
m_modem->setRFParams(rxFrequency, rxOffset, txFrequency, txOffset, txDCOffset, rxDCOffset);
m_modem->setDMRParams(colorCode);
m_modem->setYSFParams(lowDeviation);

Expand Down
13 changes: 8 additions & 5 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_rxDCOffset(0),
m_txDCOffset(0),
m_serial(port, SERIAL_115200, true),
m_buffer(NULL),
Expand Down Expand Up @@ -146,11 +147,12 @@ CModem::~CModem()
delete[] m_buffer;
}

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

void CModem::setModeParams(bool dstarEnabled, bool dmrEnabled, bool ysfEnabled, bool p25Enabled)
Expand Down Expand Up @@ -945,7 +947,7 @@ bool CModem::setConfig()

buffer[0U] = MMDVM_FRAME_START;

buffer[1U] = 17U;
buffer[1U] = 18U;

buffer[2U] = MMDVM_SET_CONFIG;

Expand Down Expand Up @@ -993,11 +995,12 @@ bool CModem::setConfig()
buffer[15U] = (unsigned char)(m_p25TXLevel * 2.55F + 0.5F);

buffer[16U] = (unsigned char)(m_txDCOffset + 128);
buffer[17U] = (unsigned char)(m_rxDCOffset + 128);

// CUtils::dump(1U, "Written", buffer, 17U);
// CUtils::dump(1U, "Written", buffer, 18U);

int ret = m_serial.write(buffer, 17U);
if (ret != 17)
int ret = m_serial.write(buffer, 18U);
if (ret != 18)
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, int txDCOffset);
void setRFParams(unsigned int rxFrequency, int rxOffset, unsigned int txFrequency, int txOffset, int txDCOffset, int rxDCOffset);
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_rxDCOffset;
int m_txDCOffset;
CSerialController m_serial;
unsigned char* m_buffer;
Expand Down

0 comments on commit 066e5f0

Please sign in to comment.