Skip to content

Commit

Permalink
Detect DAC overflows.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed Jun 9, 2016
1 parent ee93e4c commit 89fa0a0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
26 changes: 9 additions & 17 deletions Modem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,18 +197,10 @@ void CModem::clock(unsigned int ms)
LogError("No reply from the modem for some time, resetting it");
m_error = true;
close();
#if defined(_WIN32) || defined(_WIN64)
::Sleep(2000UL); // 2s
#else
::sleep(2UL); // 2s
#endif
while (!open()) {
#if defined(_WIN32) || defined(_WIN64)
::Sleep(5000UL); // 5s
#else
::sleep(5UL); // 5s
#endif
}

CThread::sleep(2000U); // 2s
while (!open())
CThread::sleep(5000U); // 5s
}

RESP_TYPE_MMDVM type = getResponse();
Expand Down Expand Up @@ -376,6 +368,10 @@ void CModem::clock(unsigned int ms)

m_lockout = (m_buffer[5U] & 0x10U) == 0x10U;

bool dacOverflow = (m_buffer[5U] & 0x20U) == 0x20U;
if (dacOverflow)
LogError("MMDVM DAC levels have overflowed");

m_dstarSpace = m_buffer[6U];
m_dmrSpace1 = m_buffer[7U];
m_dmrSpace2 = m_buffer[8U];
Expand Down Expand Up @@ -698,11 +694,7 @@ bool CModem::writeYSFData(const unsigned char* data, unsigned int length)

bool CModem::readVersion()
{
#if defined(_WIN32) || defined(_WIN64)
::Sleep(2000UL); // 2s
#else
::sleep(2); // 2s
#endif
CThread::sleep(2000U); // 2s

for (unsigned int i = 0U; i < 6U; i++) {
unsigned char buffer[3U];
Expand Down
4 changes: 3 additions & 1 deletion YSFControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,8 @@ void CYSFControl::writeNetwork()

m_networkWatchdog.start();

bool gateway = ::memcmp(data + 4U, "GATEWAY ", YSF_CALLSIGN_LENGTH) == 0;

if (!m_netTimeoutTimer.isRunning()) {
if (::memcmp(data + 14U, " ", YSF_CALLSIGN_LENGTH) != 0)
::memcpy(m_netSource, data + 14U, YSF_CALLSIGN_LENGTH);
Expand Down Expand Up @@ -403,7 +405,7 @@ void CYSFControl::writeNetwork()

m_netFrames++;

bool end = data[34U] == 0x01U;
bool end = (data[34U] & 0x01U) == 0x01U;

data[33U] = end ? TAG_EOT : TAG_DATA;
data[34U] = 0x00U;
Expand Down
2 changes: 1 addition & 1 deletion YSFNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void CYSFNetwork::clock(unsigned int ms)
return;
}

bool end = buffer[34U] == 0x01U;
bool end = (buffer[34U] & 0x01U) == 0x01U;
if (end)
::memset(m_tag, ' ', YSF_CALLSIGN_LENGTH);

Expand Down

0 comments on commit 89fa0a0

Please sign in to comment.