Convert to the new EOF marker.

This commit is contained in:
Jonathan Naylor
2021-08-25 19:27:53 +01:00
parent 37c889c2d9
commit b779ea5ae6
5 changed files with 82 additions and 64 deletions

View File

@@ -78,6 +78,7 @@ const unsigned char MMDVM_M17_LINK_SETUP = 0x45U;
const unsigned char MMDVM_M17_STREAM = 0x46U;
const unsigned char MMDVM_M17_PACKET = 0x47U;
const unsigned char MMDVM_M17_LOST = 0x48U;
const unsigned char MMDVM_M17_EOT = 0x49U;
const unsigned char MMDVM_POCSAG_DATA = 0x50U;
@@ -690,6 +691,18 @@ void CModem::clock(unsigned int ms)
}
break;
case MMDVM_M17_EOT: {
if (m_trace)
CUtils::dump(1U, "RX M17 EOT", m_buffer, m_length);
unsigned char data = 1U;
m_rxM17Data.addData(&data, 1U);
data = TAG_EOT;
m_rxM17Data.addData(&data, 1U);
}
break;
case MMDVM_M17_LOST: {
if (m_trace)
CUtils::dump(1U, "RX M17 Lost", m_buffer, m_length);
@@ -1041,8 +1054,8 @@ void CModem::clock(unsigned int ms)
case MMDVM_M17_STREAM:
CUtils::dump(1U, "TX M17 Stream Data", m_buffer, len);
break;
case MMDVM_M17_PACKET:
CUtils::dump(1U, "TX M17 Packet Data", m_buffer, len);
case MMDVM_M17_EOT:
CUtils::dump(1U, "TX M17 EOT", m_buffer, len);
break;
}
}
@@ -1504,20 +1517,26 @@ bool CModem::writeM17Data(const unsigned char* data, unsigned int length)
assert(data != NULL);
assert(length > 0U);
if (data[0U] != TAG_HEADER && data[0U] != TAG_DATA && data[0U] != TAG_EOT)
return false;
unsigned char buffer[130U];
buffer[0U] = MMDVM_FRAME_START;
buffer[1U] = length + 2U;
if (data[0U] == TAG_HEADER)
buffer[2U] = MMDVM_M17_LINK_SETUP;
else
buffer[2U] = MMDVM_M17_STREAM;
::memcpy(buffer + 3U, data + 1U, length - 1U);
switch (data[0U]) {
case TAG_HEADER:
buffer[2U] = MMDVM_M17_LINK_SETUP;
::memcpy(buffer + 3U, data + 1U, length - 1U);
break;
case TAG_DATA:
buffer[2U] = MMDVM_M17_STREAM;
::memcpy(buffer + 3U, data + 1U, length - 1U);
break;
case TAG_EOT:
buffer[2U] = MMDVM_M17_EOT;
break;
default:
return false;
}
unsigned char len = length + 2U;
m_txM17Data.addData(&len, 1U);