Skip to content

Commit

Permalink
Fix setFrequency() length for DVMega
Browse files Browse the repository at this point in the history
  • Loading branch information
juribeparada committed Jan 2, 2018
1 parent 1805a98 commit 1c77275
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Modem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1044,10 +1044,18 @@ bool CModem::setConfig()
bool CModem::setFrequency()
{
unsigned char buffer[16U];
unsigned char len;

if (m_hwType == HWT_DVMEGA)
len = 12U;
else {
buffer[12U] = (unsigned char)(m_rfLevel * 2.55F + 0.5F);
len = 13U;
}

buffer[0U] = MMDVM_FRAME_START;

buffer[1U] = 13U;
buffer[1U] = len;

buffer[2U] = MMDVM_SET_FREQ;

Expand All @@ -1062,13 +1070,11 @@ bool CModem::setFrequency()
buffer[9U] = (m_txFrequency >> 8) & 0xFFU;
buffer[10U] = (m_txFrequency >> 16) & 0xFFU;
buffer[11U] = (m_txFrequency >> 24) & 0xFFU;

buffer[12U] = (unsigned char)(m_rfLevel * 2.55F + 0.5F);

// CUtils::dump(1U, "Written", buffer, 13U);
// CUtils::dump(1U, "Written", buffer, len);

int ret = m_serial.write(buffer, 13U);
if (ret != 13)
int ret = m_serial.write(buffer, len);
if (ret != len)
return false;

unsigned int count = 0U;
Expand Down

0 comments on commit 1c77275

Please sign in to comment.