add support for a CMD_SET_BUFFERS, this will allow the host to control the size of the transmit FIFO buffers; reduce the size of FIFO buffers;

pull/4/head 2023-06-16
Bryan Biedenkapp 3 years ago
parent 4701bb4d6b
commit 42f4ea03a1

@ -175,6 +175,17 @@ void SerialPort::process()
}
break;
case CMD_SET_BUFFERS:
err = setBuffers(m_buffer + 3U, m_len - 3U);
if (err == RSN_OK) {
sendACK();
}
else {
DEBUG2("SerialPort: process(): received invalid data to set buffers", err);
sendNAK(err);
}
break;
/** CW */
case CMD_SEND_CWID:
err = RSN_RINGBUFF_FULL;
@ -1301,3 +1312,33 @@ uint8_t SerialPort::setRFParams(const uint8_t* data, uint8_t length)
return io.setRFParams(rxFreq, txFreq, rfPower, gainMode);
}
/// <summary>
/// Sets the protocol ring buffer sizes.
/// </summary>
/// <param name="data"></param>
/// <param name="length"></param>
/// <returns></returns>
uint8_t SerialPort::setBuffers(const uint8_t* data, uint8_t length)
{
if (length < 1U)
return RSN_ILLEGAL_LENGTH;
if (m_modemState != STATE_IDLE)
return RSN_INVALID_MODE;
uint16_t dmrBufSize = dmr::DMR_TX_BUFFER_LEN;
uint16_t p25BufSize = p25::P25_TX_BUFFER_LEN;
uint16_t nxdnBufSize = nxdn::NXDN_TX_BUFFER_LEN;
dmrBufSize = (data[0U] << 8) + (data[1U]);
p25BufSize = (data[2U] << 8) + (data[3U]);
nxdnBufSize = (data[4U] << 8) + (data[5U]);
p25TX.resizeBuffer(p25BufSize);
nxdnTX.resizeBuffer(nxdnBufSize);
dmrTX.resizeBuffer(dmrBufSize);
dmrDMOTX.resizeBuffer(dmrBufSize);
return RSN_OK;
}

@ -82,6 +82,8 @@ enum DVM_COMMANDS {
CMD_RSSI_DATA = 0x09U,
CMD_SEND_CWID = 0x0AU,
CMD_SET_BUFFERS = 0x0FU,
CMD_DMR_DATA1 = 0x18U,
CMD_DMR_LOST1 = 0x19U,
@ -227,6 +229,8 @@ private:
void setMode(DVM_STATE modemState);
/// <summary>Sets the RF parameters.</summary>
uint8_t setRFParams(const uint8_t* data, uint8_t length);
/// <summary>Sets the protocol ring buffer sizes.</summary>
uint8_t setBuffers(const uint8_t* data, uint8_t length);
/// <summary></summary>
void flashRead();

@ -144,6 +144,16 @@ void DMRDMOTX::setPreambleCount(uint8_t preambleCnt)
m_preambleCnt = 1200U;
}
/// <summary>
/// Helper to resize the FIFO buffer.
/// </summary>
/// <param name="size"></param>
void DMRDMOTX::resizeBuffer(uint16_t size)
{
m_fifo.reset();
m_fifo.reinitialize(size);
}
/// <summary>
/// Helper to get how much space the ring buffer has for samples.
/// </summary>

@ -65,6 +65,9 @@ namespace dmr
/// <summary>Sets the FDMA preamble count.</summary>
void setPreambleCount(uint8_t preambleCnt);
/// <summary>Helper to resize the FIFO buffer.</summary>
void resizeBuffer(uint16_t size);
/// <summary>Helper to get how much space the ring buffer has for samples.</summary>
uint16_t getSpace() const;

@ -126,7 +126,8 @@ namespace dmr
const int8_t DMR_MS_VOICE_SYNC_SYMBOLS_VALUES[] = { +3, -3, -3, -3, +3, -3, -3, +3, +3, +3, -3, +3, -3, +3, +3, +3, +3, -3, -3, +3, -3, -3, -3, +3 };
const uint32_t DMR_TX_BUFFER_LEN = 538U; // 538 = DMR_FRAME_LENGTH_BYTES * 16 + 10 (BUFFER_LEN = DMR_FRAME_LENGTH_BYTES * NO_OF_FRAMES + 10)
// 505 = DMR_FRAME_LENGTH_BYTES * 15 + 10 (BUFFER_LEN = DMR_FRAME_LENGTH_BYTES * NO_OF_FRAMES + 10)
const uint32_t DMR_TX_BUFFER_LEN = 505U; // 15 frames + pad
// Data Type(s)
const uint8_t DT_VOICE_PI_HEADER = 0U;

@ -350,6 +350,18 @@ void DMRTX::resetFifo2()
m_fifo[1U].reset();
}
/// <summary>
/// Helper to resize the FIFO buffer.
/// </summary>
/// <param name="size"></param>
void DMRTX::resizeBuffer(uint16_t size)
{
m_fifo[0U].reset();
m_fifo[1U].reset();
m_fifo[0U].reinitialize(size);
m_fifo[1U].reinitialize(size);
}
/// <summary>
///
/// </summary>

@ -94,6 +94,10 @@ namespace dmr
void resetFifo1();
/// <summary>Helper to reset data values to defaults for slot 2 FIFO.</summary>
void resetFifo2();
/// <summary>Helper to resize the FIFO buffer.</summary>
void resizeBuffer(uint16_t size);
/// <summary></summary>
uint32_t getFrameCount();

@ -68,7 +68,8 @@ namespace nxdn
const uint16_t NXDN_FSW_SYMBOLS = 0x014DU;
const uint16_t NXDN_FSW_SYMBOLS_MASK = 0x03FFU;
const uint32_t NXDN_TX_BUFFER_LEN = 1018U; // 2026 = NXDN_FRAME_LENGTH_BYTES * 21 + 10 (BUFFER_LEN = NXDN_FRAME_LENGTH_BYTES * NO_OF_FRAMES)
// 538 = NXDN_FRAME_LENGTH_BYTES * 11 + 10 (BUFFER_LEN = NXDN_FRAME_LENGTH_BYTES * NO_OF_FRAMES)
const uint32_t NXDN_TX_BUFFER_LEN = 538U; // 11 frames + pad
} // namespace nxdn
#endif // __NXDN_DEFINES_H__

@ -175,6 +175,16 @@ void NXDNTX::setCal(bool start)
m_state = start ? NXDNTXSTATE_CAL : NXDNTXSTATE_NORMAL;
}
/// <summary>
/// Helper to resize the FIFO buffer.
/// </summary>
/// <param name="size"></param>
void NXDNTX::resizeBuffer(uint16_t size)
{
m_fifo.reset();
m_fifo.reinitialize(size);
}
/// <summary>
/// Helper to get how much space the ring buffer has for samples.
/// </summary>

@ -74,6 +74,9 @@ namespace nxdn
/// <summary>Helper to set the calibration state for Tx.</summary>
void setCal(bool start);
/// <summary>Helper to resize the FIFO buffer.</summary>
void resizeBuffer(uint16_t size);
/// <summary>Helper to get how much space the ring buffer has for samples.</summary>
uint8_t getSpace() const;

@ -120,7 +120,8 @@ namespace p25
const uint32_t P25_SYNC_SYMBOLS = 0x00FB30A0U;
const uint32_t P25_SYNC_SYMBOLS_MASK = 0x00FFFFFFU;
const uint32_t P25_TX_BUFFER_LEN = 1738U; // 2592 = P25_LDU_FRAME_LENGTH_BYTES * 8 + 10 (BUFFER_LEN = P25_LDU_FRAME_LENGTH_BYTES * NO_OF_FRAMES + 10)
// 442 = P25_LDU_FRAME_LENGTH_BYTES * 2 + 10 (BUFFER_LEN = P25_LDU_FRAME_LENGTH_BYTES * NO_OF_FRAMES + 10)
const uint32_t P25_TX_BUFFER_LEN = 442U; // 2 frames + pad
// Data Unit ID(s)
const uint8_t P25_DUID_HDU = 0x00U; // Header Data Unit

@ -189,6 +189,16 @@ void P25TX::setCal(bool start)
m_state = start ? P25TXSTATE_CAL : P25TXSTATE_NORMAL;
}
/// <summary>
/// Helper to resize the FIFO buffer.
/// </summary>
/// <param name="size"></param>
void P25TX::resizeBuffer(uint16_t size)
{
m_fifo.reset();
m_fifo.reinitialize(size);
}
/// <summary>
/// Helper to get how much space the ring buffer has for samples.
/// </summary>

@ -75,6 +75,9 @@ namespace p25
/// <summary>Helper to set the calibration state for Tx.</summary>
void setCal(bool start);
/// <summary>Helper to resize the FIFO buffer.</summary>
void resizeBuffer(uint16_t size);
/// <summary>Helper to get how much space the ring buffer has for samples.</summary>
uint8_t getSpace() const;

Loading…
Cancel
Save

Powered by TurnKey Linux.