Implemented M17 EOT marker
This commit is contained in:
parent
a22aceb576
commit
fa33f15417
|
|
@ -41,6 +41,7 @@ static constexpr syncw_t LSF_SYNC_WORD = {0x55, 0xF7}; // LSF sync word
|
||||||
static constexpr syncw_t BERT_SYNC_WORD = {0xDF, 0x55}; // BERT data sync word
|
static constexpr syncw_t BERT_SYNC_WORD = {0xDF, 0x55}; // BERT data sync word
|
||||||
static constexpr syncw_t STREAM_SYNC_WORD = {0xFF, 0x5D}; // Stream data sync word
|
static constexpr syncw_t STREAM_SYNC_WORD = {0xFF, 0x5D}; // Stream data sync word
|
||||||
static constexpr syncw_t PACKET_SYNC_WORD = {0x75, 0xFF}; // Packet data sync word
|
static constexpr syncw_t PACKET_SYNC_WORD = {0x75, 0xFF}; // Packet data sync word
|
||||||
|
static constexpr syncw_t EOT_SYNC_WORD = {0x55, 0x5D}; // End of transmission sync word
|
||||||
|
|
||||||
} // namespace M17
|
} // namespace M17
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ public:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shutdown modulator and deallocate data buffers.
|
* Forcefully shutdown modulator and deallocate data buffers.
|
||||||
*/
|
*/
|
||||||
void terminate();
|
void terminate();
|
||||||
|
|
||||||
|
|
@ -89,6 +89,9 @@ private:
|
||||||
*/
|
*/
|
||||||
void sendBaseband();
|
void sendBaseband();
|
||||||
|
|
||||||
|
/** Gracefully end the transmission **/
|
||||||
|
void stop();
|
||||||
|
|
||||||
static constexpr size_t M17_TX_SAMPLE_RATE = 48000;
|
static constexpr size_t M17_TX_SAMPLE_RATE = 48000;
|
||||||
static constexpr size_t M17_SAMPLES_PER_SYMBOL = M17_TX_SAMPLE_RATE / M17_SYMBOL_RATE;
|
static constexpr size_t M17_SAMPLES_PER_SYMBOL = M17_TX_SAMPLE_RATE / M17_SYMBOL_RATE;
|
||||||
static constexpr size_t M17_FRAME_SAMPLES = M17_FRAME_SYMBOLS * M17_SAMPLES_PER_SYMBOL;
|
static constexpr size_t M17_FRAME_SAMPLES = M17_FRAME_SYMBOLS * M17_SAMPLES_PER_SYMBOL;
|
||||||
|
|
@ -106,7 +109,6 @@ private:
|
||||||
stream_sample_t *idleBuffer; ///< Half baseband buffer, free for processing.
|
stream_sample_t *idleBuffer; ///< Half baseband buffer, free for processing.
|
||||||
streamId outStream; ///< Baseband output stream ID.
|
streamId outStream; ///< Baseband output stream ID.
|
||||||
bool txRunning; ///< Transmission running.
|
bool txRunning; ///< Transmission running.
|
||||||
bool stopTx; ///< Stop transmission request.
|
|
||||||
|
|
||||||
#if defined(PLATFORM_MD3x0) || defined(PLATFORM_MDUV3x0)
|
#if defined(PLATFORM_MD3x0) || defined(PLATFORM_MDUV3x0)
|
||||||
filter_state_t pwmFilterState;
|
filter_state_t pwmFilterState;
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,6 @@ void M17::M17Modulator::start()
|
||||||
if(txRunning) return;
|
if(txRunning) return;
|
||||||
|
|
||||||
txRunning = true;
|
txRunning = true;
|
||||||
stopTx = false;
|
|
||||||
|
|
||||||
// Fill symbol buffer with preamble, made of alternated +3 and -3 symbols
|
// Fill symbol buffer with preamble, made of alternated +3 and -3 symbols
|
||||||
for(size_t i = 0; i < symbols.size(); i += 2)
|
for(size_t i = 0; i < symbols.size(); i += 2)
|
||||||
|
|
@ -112,11 +111,45 @@ void M17Modulator::send(const frame_t& frame, const bool isLast)
|
||||||
it = std::copy(sym.begin(), sym.end(), it);
|
it = std::copy(sym.begin(), sym.end(), it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
symbolsToBaseband();
|
||||||
|
sendBaseband();
|
||||||
|
|
||||||
// If last frame, signal stop of transmission
|
// If last frame, signal stop of transmission
|
||||||
if(isLast) stopTx = true;
|
if(isLast) stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
void M17Modulator::stop()
|
||||||
|
{
|
||||||
|
if(txRunning == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
frame_t eotFrame;
|
||||||
|
// Fill EOT frame with 0x55, 0x5D as per M17 spec.
|
||||||
|
for(size_t i = 0; i < eotFrame.size(); i += 2)
|
||||||
|
{
|
||||||
|
eotFrame[i] = 0x55;
|
||||||
|
eotFrame[i + 1] = 0x5D;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert to symbols
|
||||||
|
auto it = symbols.begin();
|
||||||
|
for(size_t i = 0; i < eotFrame.size(); i++)
|
||||||
|
{
|
||||||
|
auto sym = byteToSymbols(eotFrame[i]);
|
||||||
|
it = std::copy(sym.begin(), sym.end(), it);
|
||||||
|
}
|
||||||
|
|
||||||
symbolsToBaseband();
|
symbolsToBaseband();
|
||||||
sendBaseband();
|
sendBaseband();
|
||||||
|
|
||||||
|
outputStream_stop(outStream);
|
||||||
|
outputStream_sync(outStream, false);
|
||||||
|
txRunning = false;
|
||||||
|
idleBuffer = baseband_buffer.get();
|
||||||
|
|
||||||
|
#if defined(PLATFORM_MD3x0) || defined(PLATFORM_MDUV3x0)
|
||||||
|
dsp_resetFilterState(&pwmFilterState);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void M17Modulator::symbolsToBaseband()
|
void M17Modulator::symbolsToBaseband()
|
||||||
|
|
@ -148,24 +181,7 @@ void M17Modulator::sendBaseband()
|
||||||
|
|
||||||
// Transmission is ongoing, syncronise with stream end before proceeding
|
// Transmission is ongoing, syncronise with stream end before proceeding
|
||||||
outputStream_sync(outStream, true);
|
outputStream_sync(outStream, true);
|
||||||
|
idleBuffer = outputStream_getIdleBuffer(outStream);
|
||||||
// Check if transmission stop is requested, if so stop the output stream
|
|
||||||
// and wait until its effective termination.
|
|
||||||
if(stopTx == true)
|
|
||||||
{
|
|
||||||
outputStream_stop(outStream);
|
|
||||||
outputStream_sync(outStream, false);
|
|
||||||
stopTx = false;
|
|
||||||
txRunning = false;
|
|
||||||
idleBuffer = baseband_buffer.get();
|
|
||||||
#if defined(PLATFORM_MD3x0) || defined(PLATFORM_MDUV3x0)
|
|
||||||
dsp_resetFilterState(&pwmFilterState);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
idleBuffer = outputStream_getIdleBuffer(outStream);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void M17Modulator::sendBaseband()
|
void M17Modulator::sendBaseband()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue