TinyModem
Header-only software audio modem library
Loading...
Searching...
No Matches
tinymodem::BasicModemStreamRTOS< Base > Class Template Reference

BasicModemStream which receives in a separate task (FreeRTOS on ESP32 and RP2040, a std::thread on the desktop): the task reads the audio input and decodes it, so the decoding does not block your loop() and no audio is lost while loop() is busy. available(), read() and peek() only access the received data and can be called from any task. More...

#include <ModemStreamRTOS.h>

Inheritance diagram for tinymodem::BasicModemStreamRTOS< Base >:
Collaboration diagram for tinymodem::BasicModemStreamRTOS< Base >:

Classes

struct  LockedQueue
 Print which writes the decoded data into the queue with a lock. More...

Public Types

using Config = typename Base::ConfigType

Public Member Functions

 ~BasicModemStreamRTOS ()
void setTaskConfig (int stack_size, int priority=1, int core=-1)
bool begin (Config cfg, int rx_buffer_size=256)
void end ()
 Stops the receive task and the modem.
int available () override
int read () override
int peek () override
size_t update ()
 Not needed: the receive task processes the input.
bool isRunning ()
 true while the receive task is running

Protected Types

using Queue = typename Base::ReceiveQueue

Protected Member Functions

void receive ()
 One iteration of the receive task.
size_t readInputLocked ()
 Reads the available audio input and feeds it to the decoder.

Protected Attributes

audio_tools::Task task
audio_tools::Mutex mutex
LockedQueue locked_queue
int task_stack_size = DEFAULT_STACK_SIZE
int task_priority = 1
int task_core = -1
bool task_created = false
bool is_task_active = false
std::atomic< bool > is_running {false}
std::atomic< bool > is_idle {false}

Static Protected Attributes

static constexpr int DEFAULT_STACK_SIZE = 2 * 1024

Detailed Description

template<class Base>
class tinymodem::BasicModemStreamRTOS< Base >

BasicModemStream which receives in a separate task (FreeRTOS on ESP32 and RP2040, a std::thread on the desktop): the task reads the audio input and decodes it, so the decoding does not block your loop() and no audio is lost while loop() is busy. available(), read() and peek() only access the received data and can be called from any task.

Transmitting (write(), print(), flush()) happens in the calling task like in the BasicModemStream. The status output (setStatusOutput()) is written by the receive task.

Template Parameters
Basethe BasicModemStream (e.g. ModemStream or MFSKStream)

Member Typedef Documentation

◆ Config

template<class Base>
using tinymodem::BasicModemStreamRTOS< Base >::Config = typename Base::ConfigType

◆ Queue

template<class Base>
using tinymodem::BasicModemStreamRTOS< Base >::Queue = typename Base::ReceiveQueue
protected

Constructor & Destructor Documentation

◆ ~BasicModemStreamRTOS()

template<class Base>
tinymodem::BasicModemStreamRTOS< Base >::~BasicModemStreamRTOS ( )
inline

Member Function Documentation

◆ available()

template<class Base>
int tinymodem::BasicModemStreamRTOS< Base >::available ( )
inlineoverride

◆ begin()

template<class Base>
bool tinymodem::BasicModemStreamRTOS< Base >::begin ( Config cfg,
int rx_buffer_size = 256 )
inline

Starts the modem and the receive task: the input is only read while less than rx_buffer_size decoded bytes are waiting to be read

◆ end()

template<class Base>
void tinymodem::BasicModemStreamRTOS< Base >::end ( )
inline

Stops the receive task and the modem.

◆ isRunning()

template<class Base>
bool tinymodem::BasicModemStreamRTOS< Base >::isRunning ( )
inline

true while the receive task is running

◆ peek()

template<class Base>
int tinymodem::BasicModemStreamRTOS< Base >::peek ( )
inlineoverride

◆ read()

template<class Base>
int tinymodem::BasicModemStreamRTOS< Base >::read ( )
inlineoverride

◆ readInputLocked()

template<class Base>
size_t tinymodem::BasicModemStreamRTOS< Base >::readInputLocked ( )
inlineprotected

Reads the available audio input and feeds it to the decoder.

◆ receive()

template<class Base>
void tinymodem::BasicModemStreamRTOS< Base >::receive ( )
inlineprotected

One iteration of the receive task.

◆ setTaskConfig()

template<class Base>
void tinymodem::BasicModemStreamRTOS< Base >::setTaskConfig ( int stack_size,
int priority = 1,
int core = -1 )
inline

Defines the receive task parameters: call before begin(). The stack size is in bytes on ESP32 and in words on other FreeRTOS platforms.

◆ update()

template<class Base>
size_t tinymodem::BasicModemStreamRTOS< Base >::update ( )
inline

Not needed: the receive task processes the input.

Member Data Documentation

◆ DEFAULT_STACK_SIZE

template<class Base>
int tinymodem::BasicModemStreamRTOS< Base >::DEFAULT_STACK_SIZE = 2 * 1024
staticconstexprprotected

◆ is_idle

template<class Base>
std::atomic<bool> tinymodem::BasicModemStreamRTOS< Base >::is_idle {false}
protected

◆ is_running

template<class Base>
std::atomic<bool> tinymodem::BasicModemStreamRTOS< Base >::is_running {false}
protected

◆ is_task_active

template<class Base>
bool tinymodem::BasicModemStreamRTOS< Base >::is_task_active = false
protected

◆ locked_queue

template<class Base>
LockedQueue tinymodem::BasicModemStreamRTOS< Base >::locked_queue
protected

◆ mutex

template<class Base>
audio_tools::Mutex tinymodem::BasicModemStreamRTOS< Base >::mutex
protected

◆ task

template<class Base>
audio_tools::Task tinymodem::BasicModemStreamRTOS< Base >::task
protected

◆ task_core

template<class Base>
int tinymodem::BasicModemStreamRTOS< Base >::task_core = -1
protected

◆ task_created

template<class Base>
bool tinymodem::BasicModemStreamRTOS< Base >::task_created = false
protected

◆ task_priority

template<class Base>
int tinymodem::BasicModemStreamRTOS< Base >::task_priority = 1
protected

◆ task_stack_size

template<class Base>
int tinymodem::BasicModemStreamRTOS< Base >::task_stack_size = DEFAULT_STACK_SIZE
protected

The documentation for this class was generated from the following file: