Skip to content

Commit

Permalink
Add CD LED functionality to MMDVMHost
Browse files Browse the repository at this point in the history
  • Loading branch information
phl0 committed Nov 17, 2016
1 parent cb35888 commit 8373dc0
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 2 deletions.
2 changes: 2 additions & 0 deletions MMDVMHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,8 @@ int CMMDVMHost::run()
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[200U];
Expand Down
10 changes: 9 additions & 1 deletion Modem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ m_dmrSpace2(0U),
m_ysfSpace(0U),
m_p25Space(0U),
m_tx(false),
m_cd(false),
m_lockout(false),
m_error(false),
m_hwType(HWT_UNKNOWN)
Expand Down Expand Up @@ -446,8 +447,10 @@ void CModem::clock(unsigned int ms)
m_ysfSpace = m_buffer[9U];
m_p25Space = m_buffer[10U];

m_cd = (m_buffer[11U] & 0x01U) == 0x01U;

m_inactivityTimer.start();
// LogMessage("status=%02X, tx=%d, space=%u,%u,%u,%u,%u lockout=%d", m_buffer[5U], int(m_tx), m_dstarSpace, m_dmrSpace1, m_dmrSpace2, m_ysfSpace, m_p25Space, int(m_lockout));
// LogMessage("status=%02X, tx=%d, space=%u,%u,%u,%u,%u lockout=%d, cd=%d", m_buffer[5U], int(m_tx), m_dstarSpace, m_dmrSpace1, m_dmrSpace2, m_ysfSpace, m_p25Space, int(m_lockout), int(m_cd));
}
break;

Expand Down Expand Up @@ -852,6 +855,11 @@ bool CModem::hasTX() const
return m_tx;
}

bool CModem::hasCD() const
{
return m_cd;
}

bool CModem::hasLockout() const
{
return m_lockout;
Expand Down
2 changes: 2 additions & 0 deletions Modem.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class CModem {
bool hasP25Space() const;

bool hasTX() const;
bool hasCD() const;

bool hasLockout() const;
bool hasError() const;
Expand Down Expand Up @@ -131,6 +132,7 @@ class CModem {
unsigned int m_ysfSpace;
unsigned int m_p25Space;
bool m_tx;
bool m_cd;
bool m_lockout;
bool m_error;
HW_TYPE m_hwType;
Expand Down
23 changes: 22 additions & 1 deletion UMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ 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;
Expand All @@ -47,7 +48,8 @@ m_length(0U),
m_offset(0U),
m_lockout(false),
m_mode(MODE_IDLE),
m_tx(false)
m_tx(false),
m_cd(false)
{
m_buffer = new unsigned char[BUFFER_LENGTH];
}
Expand Down Expand Up @@ -125,6 +127,25 @@ bool CUMP::setTX(bool on)
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;
Expand Down
3 changes: 3 additions & 0 deletions UMP.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class CUMP : public ISerialPort

bool setTX(bool on);

bool setCD(bool on);

bool getLockout() const;

virtual int read(unsigned char* buffer, unsigned int length);
Expand All @@ -55,6 +57,7 @@ class CUMP : public ISerialPort
bool m_lockout;
unsigned char m_mode;
bool m_tx;
bool m_cd;
};

#endif

0 comments on commit 8373dc0

Please sign in to comment.