Change the EOT handling on TX.

This commit is contained in:
Jonathan Naylor 2021-09-19 14:25:12 +01:00
parent 6a4dad4c44
commit d063a1da1e
4 changed files with 6 additions and 35 deletions

View File

@ -114,7 +114,7 @@ void CM17TX::process()
} }
} }
uint8_t CM17TX::writeLinkSetup(const uint8_t* data, uint8_t length) uint8_t CM17TX::writeData(const uint8_t* data, uint8_t length)
{ {
if (length != (M17_FRAME_LENGTH_BYTES + 1U)) if (length != (M17_FRAME_LENGTH_BYTES + 1U))
return 4U; return 4U;
@ -129,33 +129,6 @@ uint8_t CM17TX::writeLinkSetup(const uint8_t* data, uint8_t length)
return 0U; return 0U;
} }
uint8_t CM17TX::writeStream(const uint8_t* data, uint8_t length)
{
if (length != (M17_FRAME_LENGTH_BYTES + 1U))
return 4U;
uint16_t space = m_buffer.getSpace();
if (space < M17_FRAME_LENGTH_BYTES)
return 5U;
for (uint8_t i = 0U; i < M17_FRAME_LENGTH_BYTES; i++)
m_buffer.put(data[i + 1U]);
return 0U;
}
uint8_t CM17TX::writeEOT()
{
uint16_t space = m_buffer.getSpace();
if (space < M17_SYNC_LENGTH_BYTES)
return 5U;
for (uint8_t i = 0U; i < M17_SYNC_LENGTH_BYTES; i++)
m_buffer.put(M17_EOF_SYNC_BYTES[i]);
return 0U;
}
void CM17TX::writeByte(uint8_t c) void CM17TX::writeByte(uint8_t c)
{ {
q15_t inBuffer[4U]; q15_t inBuffer[4U];

View File

@ -29,9 +29,7 @@ class CM17TX {
public: public:
CM17TX(); CM17TX();
uint8_t writeLinkSetup(const uint8_t* data, uint8_t length); uint8_t writeData(const uint8_t* data, uint8_t length);
uint8_t writeStream(const uint8_t* data, uint8_t length);
uint8_t writeEOT();
void process(); void process();

View File

@ -1307,7 +1307,7 @@ void CSerialPort::processMessage(uint8_t type, const uint8_t* buffer, uint16_t l
case MMDVM_M17_LINK_SETUP: case MMDVM_M17_LINK_SETUP:
if (m_m17Enable) { if (m_m17Enable) {
if (m_modemState == STATE_IDLE || m_modemState == STATE_M17) if (m_modemState == STATE_IDLE || m_modemState == STATE_M17)
err = m17TX.writeLinkSetup(buffer, length); err = m17TX.writeData(buffer, length);
} }
if (err == 0U) { if (err == 0U) {
if (m_modemState == STATE_IDLE) if (m_modemState == STATE_IDLE)
@ -1321,7 +1321,7 @@ void CSerialPort::processMessage(uint8_t type, const uint8_t* buffer, uint16_t l
case MMDVM_M17_STREAM: case MMDVM_M17_STREAM:
if (m_m17Enable) { if (m_m17Enable) {
if (m_modemState == STATE_IDLE || m_modemState == STATE_M17) if (m_modemState == STATE_IDLE || m_modemState == STATE_M17)
err = m17TX.writeStream(buffer, length); err = m17TX.writeData(buffer, length);
} }
if (err == 0U) { if (err == 0U) {
if (m_modemState == STATE_IDLE) if (m_modemState == STATE_IDLE)
@ -1335,7 +1335,7 @@ void CSerialPort::processMessage(uint8_t type, const uint8_t* buffer, uint16_t l
case MMDVM_M17_EOT: case MMDVM_M17_EOT:
if (m_m17Enable) { if (m_m17Enable) {
if (m_modemState == STATE_IDLE || m_modemState == STATE_M17) if (m_modemState == STATE_IDLE || m_modemState == STATE_M17)
err = m17TX.writeEOT(); err = m17TX.writeData(buffer, length);
} }
if (err == 0U) { if (err == 0U) {
if (m_modemState == STATE_IDLE) if (m_modemState == STATE_IDLE)

View File

@ -19,7 +19,7 @@
#if !defined(VERSION_H) #if !defined(VERSION_H)
#define VERSION_H #define VERSION_H
#define VERSION "20210906" #define VERSION "20210919"
#endif #endif