Add CD LED functionality to MMDVMHost

This commit is contained in:
phl0 2016-11-17 11:48:42 +01:00
parent cb35888d0e
commit 8373dc0b8a
No known key found for this signature in database
GPG Key ID: 48EA1E640798CA9A
5 changed files with 38 additions and 2 deletions

View File

@ -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];

View File

@ -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)
@ -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;
@ -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;

View File

@ -59,6 +59,7 @@ public:
bool hasP25Space() const;
bool hasTX() const;
bool hasCD() const;
bool hasLockout() const;
bool hasError() const;
@ -131,6 +132,7 @@ private:
unsigned int m_ysfSpace;
unsigned int m_p25Space;
bool m_tx;
bool m_cd;
bool m_lockout;
bool m_error;
HW_TYPE m_hwType;

23
UMP.cpp
View File

@ -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;
@ -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];
}
@ -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;

3
UMP.h
View File

@ -36,6 +36,8 @@ public:
bool setTX(bool on);
bool setCD(bool on);
bool getLockout() const;
virtual int read(unsigned char* buffer, unsigned int length);
@ -55,6 +57,7 @@ private:
bool m_lockout;
unsigned char m_mode;
bool m_tx;
bool m_cd;
};
#endif