diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 6903505..b4cf5e0 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -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); - m_modem->writeSerialData(message, length); + 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) diff --git a/MMDVMHost.h b/MMDVMHost.h index 11e006f..a917b95 100644 --- a/MMDVMHost.h +++ b/MMDVMHost.h @@ -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) diff --git a/Version.h b/Version.h index 19548a7..12931c4 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20230927"; +const char* VERSION = "20231005"; #endif