Skip to content

Commit

Permalink
fix buffer overflow causing modem crash during calibration; fix file …
Browse files Browse the repository at this point in the history
…formatting; add support for force DMO configuration flag (used for calibration);
  • Loading branch information
gatekeep committed Jan 5, 2024
1 parent 8008f96 commit 74225c4
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 28 deletions.
2 changes: 1 addition & 1 deletion ADF7021.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ void IO::rf2Conf(DVM_STATE modemState)
AD7021_CONTROL = ADF7021_REG2;
AD7021_2_IOCTL();

DEBUG3("IO::rf2Conf(): ADF2 REG2 =", (ADF7021_REG2 >> 16 & 0xFFFFU), (ADF7021_REG3 & 0xFFFFU));
DEBUG3("IO::rf2Conf() ADF2 REG2 =", (ADF7021_REG2 >> 16 & 0xFFFFU), (ADF7021_REG3 & 0xFFFFU));

/*
** Test DAC (Register 14)
Expand Down
1 change: 1 addition & 0 deletions FirmwareMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ bool m_p25Enable = true;
bool m_nxdnEnable = true;

bool m_duplex = false;
bool m_forceDMO = false;

bool m_tx = false;
bool m_dcd = false;
Expand Down
1 change: 1 addition & 0 deletions Globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ extern bool m_p25Enable;
extern bool m_nxdnEnable;

extern bool m_duplex;
extern bool m_forceDMO;

extern bool m_tx;
extern bool m_dcd;
Expand Down
2 changes: 1 addition & 1 deletion IO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void IO::process()
if (m_modemState == STATE_DMR) {
/** Digital Mobile Radio */
#if defined(DUPLEX)
if (m_duplex) {
if (m_duplex && !m_forceDMO) {
if (m_tx)
dmrRX.databit(bit, control);
else
Expand Down
1 change: 1 addition & 0 deletions SerialPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,7 @@ uint8_t SerialPort::setConfig(const uint8_t* data, uint8_t length)

bool simplex = (data[0U] & 0x80U) == 0x80U;

m_forceDMO = (data[0U] & 0x40U) == 0x40U;
m_debug = (data[0U] & 0x10U) == 0x10U;

bool dmrEnable = (data[1U] & 0x02U) == 0x02U;
Expand Down
42 changes: 21 additions & 21 deletions dmr/CalDMR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,42 +40,42 @@ using namespace dmr;

// Voice LC Header, CC: 1, srcID: 1, dstID: TG9
const uint8_t VH_1K[] = { 0x00U,
0x00U, 0x20U, 0x08U, 0x08U, 0x02U, 0x38U, 0x15U, 0x00U, 0x2CU, 0xA0U, 0x14U,
0x60U, 0x84U, 0x6DU, 0xFFU, 0x57U, 0xD7U, 0x5DU, 0xF5U, 0xDEU, 0x30U, 0x30U,
0x01U, 0x10U, 0x01U, 0x40U, 0x03U, 0xC0U, 0x13U, 0xC1U, 0x1EU, 0x80U, 0x6FU };
0x00U, 0x20U, 0x08U, 0x08U, 0x02U, 0x38U, 0x15U, 0x00U, 0x2CU, 0xA0U, 0x14U,
0x60U, 0x84U, 0x6DU, 0xFFU, 0x57U, 0xD7U, 0x5DU, 0xF5U, 0xDEU, 0x30U, 0x30U,
0x01U, 0x10U, 0x01U, 0x40U, 0x03U, 0xC0U, 0x13U, 0xC1U, 0x1EU, 0x80U, 0x6FU };

// Voice Term with LC, CC: 1, srcID: 1, dstID: TG9
const uint8_t VT_1K[] = { 0x00U,
0x00U, 0x4FU, 0x08U, 0xDCU, 0x02U, 0x88U, 0x15U, 0x78U, 0x2CU, 0xD0U, 0x14U,
0xC0U, 0x84U, 0xADU, 0xFFU, 0x57U, 0xD7U, 0x5DU, 0xF5U, 0xD9U, 0x65U, 0x24U,
0x02U, 0x28U, 0x06U, 0x20U, 0x0FU, 0x80U, 0x1BU, 0xC1U, 0x07U, 0x80U, 0x5CU };
0x00U, 0x4FU, 0x08U, 0xDCU, 0x02U, 0x88U, 0x15U, 0x78U, 0x2CU, 0xD0U, 0x14U,
0xC0U, 0x84U, 0xADU, 0xFFU, 0x57U, 0xD7U, 0x5DU, 0xF5U, 0xD9U, 0x65U, 0x24U,
0x02U, 0x28U, 0x06U, 0x20U, 0x0FU, 0x80U, 0x1BU, 0xC1U, 0x07U, 0x80U, 0x5CU };

// Voice LC MS Header, CC: 1, srcID: 1, dstID: TG9
const uint8_t VH_DMO1K[] = { 0x00U,
0x00U, 0x20U, 0x08U, 0x08U, 0x02U, 0x38U, 0x15U, 0x00U, 0x2CU, 0xA0U, 0x14U,
0x60U, 0x84U, 0x6DU, 0x5DU, 0x7FU, 0x77U, 0xFDU, 0x75U, 0x7EU, 0x30U, 0x30U,
0x01U, 0x10U, 0x01U, 0x40U, 0x03U, 0xC0U, 0x13U, 0xC1U, 0x1EU, 0x80U, 0x6FU };
0x00U, 0x20U, 0x08U, 0x08U, 0x02U, 0x38U, 0x15U, 0x00U, 0x2CU, 0xA0U, 0x14U,
0x60U, 0x84U, 0x6DU, 0x5DU, 0x7FU, 0x77U, 0xFDU, 0x75U, 0x7EU, 0x30U, 0x30U,
0x01U, 0x10U, 0x01U, 0x40U, 0x03U, 0xC0U, 0x13U, 0xC1U, 0x1EU, 0x80U, 0x6FU };

// Voice Term MS with LC, CC: 1, srcID: 1, dstID: TG9
const uint8_t VT_DMO1K[] = { 0x00U,
0x00U, 0x4FU, 0x08U, 0xDCU, 0x02U, 0x88U, 0x15U, 0x78U, 0x2CU, 0xD0U, 0x14U,
0xC0U, 0x84U, 0xADU, 0x5DU, 0x7FU, 0x77U, 0xFDU, 0x75U, 0x79U, 0x65U, 0x24U,
0x02U, 0x28U, 0x06U, 0x20U, 0x0FU, 0x80U, 0x1BU, 0xC1U, 0x07U, 0x80U, 0x5CU };
0x00U, 0x4FU, 0x08U, 0xDCU, 0x02U, 0x88U, 0x15U, 0x78U, 0x2CU, 0xD0U, 0x14U,
0xC0U, 0x84U, 0xADU, 0x5DU, 0x7FU, 0x77U, 0xFDU, 0x75U, 0x79U, 0x65U, 0x24U,
0x02U, 0x28U, 0x06U, 0x20U, 0x0FU, 0x80U, 0x1BU, 0xC1U, 0x07U, 0x80U, 0x5CU };

// Voice coding data + FEC, 1031 Hz Test Pattern
const uint8_t VOICE_1K[] = { 0x00U,
0xCEU, 0xA8U, 0xFEU, 0x83U, 0xACU, 0xC4U, 0x58U, 0x20U, 0x0AU, 0xCEU, 0xA8U,
0xFEU, 0x83U, 0xA0U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x0CU, 0xC4U, 0x58U,
0x20U, 0x0AU, 0xCEU, 0xA8U, 0xFEU, 0x83U, 0xACU, 0xC4U, 0x58U, 0x20U, 0x0AU };
0xCEU, 0xA8U, 0xFEU, 0x83U, 0xACU, 0xC4U, 0x58U, 0x20U, 0x0AU, 0xCEU, 0xA8U,
0xFEU, 0x83U, 0xA0U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x0CU, 0xC4U, 0x58U,
0x20U, 0x0AU, 0xCEU, 0xA8U, 0xFEU, 0x83U, 0xACU, 0xC4U, 0x58U, 0x20U, 0x0AU };

// Embedded LC: CC: 1, srcID: 1, dstID: TG9
const uint8_t SYNCEMB_1K[6][7] = {
{ 0x07U, 0x55U, 0xFDU, 0x7DU, 0xF7U, 0x5FU, 0x70U }, // BS VOICE SYNC (audio seq 0)
{ 0x01U, 0x30U, 0x00U, 0x00U, 0x90U, 0x09U, 0x10U }, // EMB + Embedded LC1 (audio seq 1)
{ 0x01U, 0x70U, 0x00U, 0x90U, 0x00U, 0x07U, 0x40U }, // EMB + Embedded LC2 (audio seq 2)
{ 0x01U, 0x70U, 0x00U, 0x31U, 0x40U, 0x07U, 0x40U }, // EMB + Embedded LC3 (audio seq 3)
{ 0x01U, 0x50U, 0xA1U, 0x71U, 0xD1U, 0x70U, 0x70U }, // EMB + Embedded LC4 (audio seq 4)
{ 0x01U, 0x10U, 0x00U, 0x00U, 0x00U, 0x0EU, 0x20U } }; // EMB (audio seq 5)
{ 0x07U, 0x55U, 0xFDU, 0x7DU, 0xF7U, 0x5FU, 0x70U }, // BS VOICE SYNC (audio seq 0)
{ 0x01U, 0x30U, 0x00U, 0x00U, 0x90U, 0x09U, 0x10U }, // EMB + Embedded LC1 (audio seq 1)
{ 0x01U, 0x70U, 0x00U, 0x90U, 0x00U, 0x07U, 0x40U }, // EMB + Embedded LC2 (audio seq 2)
{ 0x01U, 0x70U, 0x00U, 0x31U, 0x40U, 0x07U, 0x40U }, // EMB + Embedded LC3 (audio seq 3)
{ 0x01U, 0x50U, 0xA1U, 0x71U, 0xD1U, 0x70U, 0x70U }, // EMB + Embedded LC4 (audio seq 4)
{ 0x01U, 0x10U, 0x00U, 0x00U, 0x00U, 0x0EU, 0x20U } }; // EMB (audio seq 5)

// Embedded LC MS: CC: 1, srcID: 1, dstID: TG9
const uint8_t SYNCEMB_DMO1K[6][7] = {
Expand Down
6 changes: 3 additions & 3 deletions dmr/DMRDMOTX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ void DMRDMOTX::setPreambleCount(uint8_t preambleCnt)
uint32_t preambles = (uint32_t)((float)preambleCnt / 0.2083F);
m_preambleCnt = DMRDMO_FIXED_DELAY + preambles;

// clamp preamble count to 250ms maximum
if (m_preambleCnt > 1200U)
m_preambleCnt = 1200U;
// clamp preamble count to 16ms maximum
if (m_preambleCnt > 80U)
m_preambleCnt = 80U;
}

/// <summary>
Expand Down
5 changes: 3 additions & 2 deletions nxdn/NXDNTX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ void NXDNTX::setPreambleCount(uint8_t preambleCnt)
{
m_preambleCnt = 300U + uint16_t(preambleCnt) * 6U; // 500ms + tx delay

if (m_preambleCnt > 1200U)
m_preambleCnt = 1200U;
// clamp preamble count
if (m_preambleCnt > 60U)
m_preambleCnt = 60U;
}

/// <summary>
Expand Down

0 comments on commit 74225c4

Please sign in to comment.