From 05e08a232fb42fa79414347d860d3858775fba5f Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Wed, 22 Jun 2016 20:42:14 +0100 Subject: [PATCH] Keep the SET_CONFIG command unchanged for DVMegas. --- MMDVMHost.cpp | 2 +- Modem.cpp | 13 ++++++++----- Modem.h | 3 ++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 8e9918f..a2854f1 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -686,7 +686,7 @@ bool CMMDVMHost::createModem() LogInfo(" Osc. Offset: %dppm", oscOffset); - m_modem = new CModem(port, rxInvert, txInvert, pttInvert, txDelay, rxLevel, txLevel, dmrDelay, oscOffset, debug); + m_modem = new CModem(port, m_duplex, rxInvert, txInvert, pttInvert, txDelay, rxLevel, txLevel, dmrDelay, oscOffset, debug); m_modem->setModeParams(m_dstarEnabled, m_dmrEnabled, m_ysfEnabled); m_modem->setModeLevels(dstarLevel, dmrLevel1, dmrLevel3, ysfLevel1, ysfLevel3, dmrThreshold, ysfThreshold); m_modem->setRFParams(rxFrequency, txFrequency); diff --git a/Modem.cpp b/Modem.cpp index a317987..0b9971e 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -76,9 +76,10 @@ const unsigned int MAX_RESPONSES = 30U; const unsigned int BUFFER_LENGTH = 500U; -CModem::CModem(const std::string& port, bool rxInvert, bool txInvert, bool pttInvert, unsigned int txDelay, unsigned int rxLevel, unsigned int txLevel, unsigned int dmrDelay, int oscOffset, bool debug) : +CModem::CModem(const std::string& port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, unsigned int txDelay, unsigned int rxLevel, unsigned int txLevel, unsigned int dmrDelay, int oscOffset, bool debug) : m_port(port), m_colorCode(0U), +m_duplex(duplex), m_rxInvert(rxInvert), m_txInvert(txInvert), m_pttInvert(pttInvert), @@ -760,11 +761,13 @@ bool CModem::readStatus() bool CModem::setConfig() { + unsigned int length = m_duplex ? 19U : 12U; + unsigned char buffer[20U]; buffer[0U] = MMDVM_FRAME_START; - buffer[1U] = 19U; + buffer[1U] = length; buffer[2U] = MMDVM_SET_CONFIG; @@ -805,10 +808,10 @@ bool CModem::setConfig() buffer[17U] = (unsigned char)(m_dmrThreshold + 128); buffer[18U] = (unsigned char)(m_ysfThreshold + 128); - // CUtils::dump(1U, "Written", buffer, 19U); + // CUtils::dump(1U, "Written", buffer, length); - int ret = m_serial.write(buffer, 19U); - if (ret != 19) + int ret = m_serial.write(buffer, length); + if (ret != int(length)) return false; unsigned int count = 0U; diff --git a/Modem.h b/Modem.h index 6664832..07300a8 100644 --- a/Modem.h +++ b/Modem.h @@ -33,7 +33,7 @@ enum RESP_TYPE_MMDVM { class CModem { public: - CModem(const std::string& port, bool rxInvert, bool txInvert, bool pttInvert, unsigned int txDelay, unsigned int rxLevel, unsigned int txLevel, unsigned int dmrDelay, int oscOffset, bool debug = false); + CModem(const std::string& port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, unsigned int txDelay, unsigned int rxLevel, unsigned int txLevel, unsigned int dmrDelay, int oscOffset, bool debug = false); ~CModem(); void setRFParams(unsigned int rxFrequency, unsigned int txFrequency); @@ -78,6 +78,7 @@ public: private: std::string m_port; unsigned int m_colorCode; + bool m_duplex; bool m_rxInvert; bool m_txInvert; bool m_pttInvert;