Change to the new method of M17 EOT transmission.

This commit is contained in:
Jonathan Naylor 2021-09-19 15:15:37 +01:00
parent cb89b34a39
commit 50a3afd66f
7 changed files with 33 additions and 47 deletions

View File

@ -329,8 +329,18 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len)
#if defined(DUMP_M17)
writeFile(data + 2U);
#endif
if (m_duplex)
writeQueueEOTRF();
if (m_duplex) {
unsigned char rfData[M17_FRAME_LENGTH_BYTES + 2U];
rfData[0U] = TAG_EOT;
rfData[1U] = 0x00U;
// Generate the sync
for (unsigned int i = 0U; i < M17_FRAME_LENGTH_BYTES; i += M17_SYNC_LENGTH_BYTES)
CSync::addM17EOTSync(rfData + 2U + i);
writeQueueRF(rfData);
}
if (m_network != NULL && m_rfTimeoutTimer.isRunning() && !m_rfTimeoutTimer.hasExpired()) {
unsigned char netData[M17_LSF_LENGTH_BYTES + M17_FN_LENGTH_BYTES + M17_PAYLOAD_LENGTH_BYTES + M17_CRC_LENGTH_BYTES];
@ -560,7 +570,16 @@ void CM17Control::writeNetwork()
LogMessage("M17, received network end of transmission from %s to %s, %.1f seconds", source.c_str(), dest.c_str(), float(m_netFrames) / 25.0F);
writeQueueEOTNet();
unsigned char data[M17_FRAME_LENGTH_BYTES + 2U];
data[0U] = TAG_EOT;
data[1U] = 0x00U;
// Generate the sync
for (unsigned int i = 0U; i < M17_FRAME_LENGTH_BYTES; i += M17_SYNC_LENGTH_BYTES)
CSync::addM17EOTSync(data + 2U + i);
writeQueueNet(data);
writeEndNet();
}
@ -686,28 +705,6 @@ void CM17Control::writeQueueRF(const unsigned char *data)
m_queue.addData(data, len);
}
void CM17Control::writeQueueEOTRF()
{
if (m_netState != RS_NET_IDLE)
return;
if (m_rfTimeoutTimer.isRunning() && m_rfTimeoutTimer.hasExpired())
return;
const unsigned char len = 1U;
unsigned int space = m_queue.freeSpace();
if (space < (len + 1U)) {
LogError("M17, overflow in the M17 RF queue");
return;
}
m_queue.addData(&len, 1U);
const unsigned char data = TAG_EOT;
m_queue.addData(&data, len);
}
void CM17Control::writeQueueNet(const unsigned char *data)
{
assert(data != NULL);
@ -728,25 +725,6 @@ void CM17Control::writeQueueNet(const unsigned char *data)
m_queue.addData(data, len);
}
void CM17Control::writeQueueEOTNet()
{
if (m_netTimeoutTimer.isRunning() && m_netTimeoutTimer.hasExpired())
return;
const unsigned char len = 1U;
unsigned int space = m_queue.freeSpace();
if (space < (len + 1U)) {
LogError("M17, overflow in the M17 RF queue");
return;
}
m_queue.addData(&len, 1U);
const unsigned char data = TAG_EOT;
m_queue.addData(&data, len);
}
void CM17Control::interleaver(const unsigned char* in, unsigned char* out) const
{
assert(in != NULL);

View File

@ -82,10 +82,8 @@ private:
bool processRFHeader(bool lateEntry);
void writeQueueRF(const unsigned char* data);
void writeQueueEOTRF();
void writeQueueNet(const unsigned char* data);
void writeQueueEOTNet();
void writeNetwork();

View File

@ -26,6 +26,7 @@ const unsigned int M17_FRAME_LENGTH_BYTES = M17_FRAME_LENGTH_BITS / 8U;
const unsigned char M17_LINK_SETUP_SYNC_BYTES[] = {0x55U, 0xF7U};
const unsigned char M17_STREAM_SYNC_BYTES[] = {0xFFU, 0x5DU};
const unsigned char M17_EOT_SYNC_BYTES[] = {0x55U, 0x5DU};
const unsigned int M17_SYNC_LENGTH_BITS = 16U;
const unsigned int M17_SYNC_LENGTH_BYTES = M17_SYNC_LENGTH_BITS / 8U;

View File

@ -1534,6 +1534,7 @@ bool CModem::writeM17Data(const unsigned char* data, unsigned int length)
break;
case TAG_EOT:
buffer[2U] = MMDVM_M17_EOT;
::memcpy(buffer + 3U, data + 1U, length - 1U);
break;
default:
return false;

View File

@ -99,3 +99,10 @@ void CSync::addM17StreamSync(unsigned char* data)
::memcpy(data, M17_STREAM_SYNC_BYTES, M17_SYNC_LENGTH_BYTES);
}
void CSync::addM17EOTSync(unsigned char* data)
{
assert(data != NULL);
::memcpy(data, M17_EOT_SYNC_BYTES, M17_SYNC_LENGTH_BYTES);
}

1
Sync.h
View File

@ -35,6 +35,7 @@ public:
static void addM17LinkSetupSync(unsigned char* data);
static void addM17StreamSync(unsigned char* data);
static void addM17EOTSync(unsigned char* data);
private:
};

View File

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