Play out large modem serial payloads gradually.

This commit is contained in:
Jonathan Naylor
2023-10-05 19:12:13 +01:00
parent c0c00fdb5b
commit 37c25598d4
3 changed files with 45 additions and 3 deletions

View File

@@ -275,14 +275,22 @@ m_cwCallsign(),
m_lockFileEnabled(false),
m_lockFileName(),
m_remoteControl(NULL),
m_fixedMode(false)
m_fixedMode(false),
m_serialTimer(1000U, 0U, 210U), // 252 bytes at 9600 bps
m_serialBuffer(NULL),
m_serialStart(0U),
m_serialLength(0U)
{
CUDPSocket::startup();
m_serialBuffer = new unsigned char[5000U];
}
CMMDVMHost::~CMMDVMHost()
{
CUDPSocket::shutdown();
delete[] m_serialBuffer;
}
int CMMDVMHost::run()
@@ -1361,6 +1369,24 @@ int CMMDVMHost::run()
m_modem->clock(ms);
m_serialTimer.clock(ms);
if (m_serialTimer.isRunning() && m_serialTimer.hasExpired()) {
unsigned int length = m_serialLength - m_serialStart;
if (length > 252U) {
m_modem->writeSerialData(m_serialBuffer + m_serialStart, 252U);
m_serialStart += 252U;
m_serialTimer.start();
} else {
if (length > 0U)
m_modem->writeSerialData(m_serialBuffer + m_serialStart, length);
m_serialLength = 0U;
m_serialStart = 0U;
m_serialTimer.stop();
}
}
if (!m_fixedMode)
m_modeTimer.clock(ms);
@@ -3635,7 +3661,18 @@ void CMMDVMHost::writeSerial(const unsigned char* message, unsigned int length)
assert(m_modem != NULL);
assert(message != NULL);
if (length <= 252U) {
// Simple case of a short message, send it immediately to the modem
m_modem->writeSerialData(message, length);
} else {
::memcpy(m_serialBuffer, message, length);
m_serialLength = length;
m_modem->writeSerialData(m_serialBuffer, 252U);
m_serialStart = 252U;
m_serialTimer.start();
}
}
#if defined(USE_AX25)

View File

@@ -192,6 +192,11 @@ private:
CRemoteControl* m_remoteControl;
bool m_fixedMode;
CTimer m_serialTimer;
unsigned char* m_serialBuffer;
unsigned int m_serialStart;
unsigned int m_serialLength;
void readParams();
bool createModem();
#if defined(USE_DSTAR)

View File

@@ -19,6 +19,6 @@
#if !defined(VERSION_H)
#define VERSION_H
const char* VERSION = "20230927";
const char* VERSION = "20231005";
#endif