TinyModem
Header-only software audio modem library
Loading...
Searching...
No Matches
tinymodem::AX25Decoder Class Reference

AX.25 packet radio demodulator (APRS, 1200 baud AFSK). The PCM audio data is written to the decoder and the received frames with a correct frame check sequence are written to the output: as monitor text lines (SRC>DEST,DIGI:info) or as KISS frames (see AX25Config::format). More...

#include <AX25Decoder.h>

Inheritance diagram for tinymodem::AX25Decoder:
Collaboration diagram for tinymodem::AX25Decoder:

Classes

struct  Phasor
 Rotating phasor of a tone: avoids sin() and cos() per sample. More...

Public Member Functions

 AX25Decoder ()=default
 AX25Decoder (Print &out)
AX25Config defaultConfig ()
 Provides a default configuration: APRS (1200 baud AFSK).
void setAudioInfo (audio_tools::AudioInfo info) override
 Defines the format of the input audio data.
audio_tools::AudioInfo audioInfo () override
bool begin (AX25Config config)
 Starts the processing with the indicated configuration.
bool begin () override
void end () override
 Reports the statistics.
void flush () override
 Provides a frame which is held back during an FX.25 block.
size_t write (const uint8_t *data, size_t len) override
 Provide PCM data to the decoder.
bool isCarrier () override
 true while a frame is received
bool isFinished () override
 The decoder never stops.
size_t frameCount ()
 Number of received frames with a correct frame check sequence.
size_t errorCount ()
 Number of frames with a wrong frame check sequence.
size_t fx25Count ()
 Number of received FX.25 frames.
size_t il2pCount ()
 Number of received IL2P frames.
size_t correctedCount ()
 Number of bytes which were corrected by FX.25 and IL2P.
AX25Config & config ()
 The configuration which was provided in begin().
 operator bool () override
Public Member Functions inherited from tinymodem::ModemDecoder
void setStatusOutput (Print &out)
 Defines the output for the ### CARRIER / ### NOCARRIER messages.
void setQuiet (bool quiet)
 Suppresses the status messages.
const char * mime () override

Protected Member Functions

void resetState ()
float noise ()
 uniform random value in the range -0.5 to 0.5
void addSample (float x)
void recalculate ()
 Avoids the accumulation of rounding errors.
void hdlc (int bit)
void processFrame ()
void deliverPending ()
void fx25 (int bit)
 FX.25: correlation tag and Reed-Solomon block.
void il2p (int raw)
 IL2P: sync word, header and payload.
void deliver (const uint8_t *frame, int len)
 Writes a received frame (without FCS) to the output.
Protected Member Functions inherited from tinymodem::ModemDecoder
void status (const char *fmt,...)

Static Protected Member Functions

static int popcount (uint32_t v)

Protected Attributes

AX25Config cfg
bool is_active = false
PcmInput input
uint32_t noise_seed = 1
size_t frames = 0
size_t errors = 0
size_t fx25_frames = 0
size_t il2p_frames = 0
size_t corrected_bytes = 0
int window = 40
audio_tools::Vector< float > products
int pos = 0
float sums [4] = {0, 0, 0, 0}
Phasor mark
Phasor space
uint32_t sample_count = 0
float pll_step = 0.025f
float pll = 0
bool last_tone = false
bool bit_tone = false
uint8_t history = 0
int ones = 0
bool in_frame = false
uint8_t frame [AX25Frame::MAX_FRAME+2]
int frame_len = 0
uint8_t current = 0
int current_bits = 0
char text [AX25Frame::MAX_FRAME *2]
uint8_t pending [AX25Frame::MAX_FRAME]
int pending_len = 0
int fx_tag = 0
uint64_t fx_accum = 0
uint8_t fx_block [FX25::BLOCK_SIZE]
int fx_len = 0
int fx_bits = 0
int fx_total = 0
int il_state = 0
uint32_t il_accum = 0
bool il_inverted = false
int il_len = 0
int il_bits = 0
int il_need = 0
uint8_t il_raw_header [IL2P::HEADER_SIZE+IL2P::HEADER_PARITY]
uint8_t il_header [IL2P::HEADER_SIZE]
uint8_t il_payload [IL2P_MAX_ENCODED]
int il_corrected = 0
Protected Attributes inherited from tinymodem::ModemDecoder
Print * p_status = nullptr
bool is_quiet = false

Static Protected Attributes

static constexpr int IL2P_MAX_ENCODED = AX25Frame::MAX_FRAME + 2 * 16
static constexpr float PLL_GAIN = 0.15f

Detailed Description

AX.25 packet radio demodulator (APRS, 1200 baud AFSK). The PCM audio data is written to the decoder and the received frames with a correct frame check sequence are written to the output: as monitor text lines (SRC>DEST,DIGI:info) or as KISS frames (see AX25Config::format).

The mark and space energy is measured with sliding correlators over one bit, a digital PLL recovers the bit clock, and the bits are NRZI and HDLC decoded. The input can be 8, 16 or 32 bit signed samples with any number of channels (only AX25Config::channel is evaluated).

FX.25 and IL2P frames are decoded in parallel (independent of AX25Config::layer2) and corrected with their Reed-Solomon codes. An FX.25 frame which is also received as standard AX.25 frame is provided only once.

Constructor & Destructor Documentation

◆ AX25Decoder() [1/2]

tinymodem::AX25Decoder::AX25Decoder ( )
default

◆ AX25Decoder() [2/2]

tinymodem::AX25Decoder::AX25Decoder ( Print & out)
inline

Member Function Documentation

◆ addSample()

void tinymodem::AX25Decoder::addSample ( float x)
inlineprotected

◆ audioInfo()

audio_tools::AudioInfo tinymodem::AX25Decoder::audioInfo ( )
inlineoverride

◆ begin() [1/2]

bool tinymodem::AX25Decoder::begin ( )
inlineoverride

◆ begin() [2/2]

bool tinymodem::AX25Decoder::begin ( AX25Config config)
inline

Starts the processing with the indicated configuration.

◆ config()

AX25Config & tinymodem::AX25Decoder::config ( )
inline

The configuration which was provided in begin().

◆ correctedCount()

size_t tinymodem::AX25Decoder::correctedCount ( )
inline

Number of bytes which were corrected by FX.25 and IL2P.

◆ defaultConfig()

AX25Config tinymodem::AX25Decoder::defaultConfig ( )
inline

Provides a default configuration: APRS (1200 baud AFSK).

◆ deliver()

void tinymodem::AX25Decoder::deliver ( const uint8_t * frame,
int len )
inlineprotected

Writes a received frame (without FCS) to the output.

◆ deliverPending()

void tinymodem::AX25Decoder::deliverPending ( )
inlineprotected

◆ end()

void tinymodem::AX25Decoder::end ( )
inlineoverride

Reports the statistics.

◆ errorCount()

size_t tinymodem::AX25Decoder::errorCount ( )
inline

Number of frames with a wrong frame check sequence.

◆ flush()

void tinymodem::AX25Decoder::flush ( )
inlineoverridevirtual

Provides a frame which is held back during an FX.25 block.

Implements tinymodem::ModemDecoder.

◆ frameCount()

size_t tinymodem::AX25Decoder::frameCount ( )
inline

Number of received frames with a correct frame check sequence.

◆ fx25()

void tinymodem::AX25Decoder::fx25 ( int bit)
inlineprotected

FX.25: correlation tag and Reed-Solomon block.

◆ fx25Count()

size_t tinymodem::AX25Decoder::fx25Count ( )
inline

Number of received FX.25 frames.

◆ hdlc()

void tinymodem::AX25Decoder::hdlc ( int bit)
inlineprotected

◆ il2p()

void tinymodem::AX25Decoder::il2p ( int raw)
inlineprotected

IL2P: sync word, header and payload.

◆ il2pCount()

size_t tinymodem::AX25Decoder::il2pCount ( )
inline

Number of received IL2P frames.

◆ isCarrier()

bool tinymodem::AX25Decoder::isCarrier ( )
inlineoverridevirtual

true while a frame is received

Implements tinymodem::ModemDecoder.

◆ isFinished()

bool tinymodem::AX25Decoder::isFinished ( )
inlineoverridevirtual

The decoder never stops.

Implements tinymodem::ModemDecoder.

◆ noise()

float tinymodem::AX25Decoder::noise ( )
inlineprotected

uniform random value in the range -0.5 to 0.5

◆ operator bool()

tinymodem::AX25Decoder::operator bool ( )
inlineoverride

◆ popcount()

int tinymodem::AX25Decoder::popcount ( uint32_t v)
inlinestaticprotected

◆ processFrame()

void tinymodem::AX25Decoder::processFrame ( )
inlineprotected

◆ recalculate()

void tinymodem::AX25Decoder::recalculate ( )
inlineprotected

Avoids the accumulation of rounding errors.

◆ resetState()

void tinymodem::AX25Decoder::resetState ( )
inlineprotected

◆ setAudioInfo()

void tinymodem::AX25Decoder::setAudioInfo ( audio_tools::AudioInfo info)
inlineoverride

Defines the format of the input audio data.

◆ write()

size_t tinymodem::AX25Decoder::write ( const uint8_t * data,
size_t len )
inlineoverride

Provide PCM data to the decoder.

Member Data Documentation

◆ bit_tone

bool tinymodem::AX25Decoder::bit_tone = false
protected

◆ cfg

AX25Config tinymodem::AX25Decoder::cfg
protected

◆ corrected_bytes

size_t tinymodem::AX25Decoder::corrected_bytes = 0
protected

◆ current

uint8_t tinymodem::AX25Decoder::current = 0
protected

◆ current_bits

int tinymodem::AX25Decoder::current_bits = 0
protected

◆ errors

size_t tinymodem::AX25Decoder::errors = 0
protected

◆ frame

uint8_t tinymodem::AX25Decoder::frame[AX25Frame::MAX_FRAME+2]
protected

◆ frame_len

int tinymodem::AX25Decoder::frame_len = 0
protected

◆ frames

size_t tinymodem::AX25Decoder::frames = 0
protected

◆ fx25_frames

size_t tinymodem::AX25Decoder::fx25_frames = 0
protected

◆ fx_accum

uint64_t tinymodem::AX25Decoder::fx_accum = 0
protected

◆ fx_bits

int tinymodem::AX25Decoder::fx_bits = 0
protected

◆ fx_block

uint8_t tinymodem::AX25Decoder::fx_block[FX25::BLOCK_SIZE]
protected

◆ fx_len

int tinymodem::AX25Decoder::fx_len = 0
protected

◆ fx_tag

int tinymodem::AX25Decoder::fx_tag = 0
protected

◆ fx_total

int tinymodem::AX25Decoder::fx_total = 0
protected

◆ history

uint8_t tinymodem::AX25Decoder::history = 0
protected

◆ il2p_frames

size_t tinymodem::AX25Decoder::il2p_frames = 0
protected

◆ IL2P_MAX_ENCODED

int tinymodem::AX25Decoder::IL2P_MAX_ENCODED = AX25Frame::MAX_FRAME + 2 * 16
staticconstexprprotected

◆ il_accum

uint32_t tinymodem::AX25Decoder::il_accum = 0
protected

◆ il_bits

int tinymodem::AX25Decoder::il_bits = 0
protected

◆ il_corrected

int tinymodem::AX25Decoder::il_corrected = 0
protected

◆ il_header

uint8_t tinymodem::AX25Decoder::il_header[IL2P::HEADER_SIZE]
protected

◆ il_inverted

bool tinymodem::AX25Decoder::il_inverted = false
protected

◆ il_len

int tinymodem::AX25Decoder::il_len = 0
protected

◆ il_need

int tinymodem::AX25Decoder::il_need = 0
protected

◆ il_payload

uint8_t tinymodem::AX25Decoder::il_payload[IL2P_MAX_ENCODED]
protected

◆ il_raw_header

uint8_t tinymodem::AX25Decoder::il_raw_header[IL2P::HEADER_SIZE+IL2P::HEADER_PARITY]
protected

◆ il_state

int tinymodem::AX25Decoder::il_state = 0
protected

◆ in_frame

bool tinymodem::AX25Decoder::in_frame = false
protected

◆ input

PcmInput tinymodem::AX25Decoder::input
protected

◆ is_active

bool tinymodem::AX25Decoder::is_active = false
protected

◆ last_tone

bool tinymodem::AX25Decoder::last_tone = false
protected

◆ mark

Phasor tinymodem::AX25Decoder::mark
protected

◆ noise_seed

uint32_t tinymodem::AX25Decoder::noise_seed = 1
protected

◆ ones

int tinymodem::AX25Decoder::ones = 0
protected

◆ pending

uint8_t tinymodem::AX25Decoder::pending[AX25Frame::MAX_FRAME]
protected

◆ pending_len

int tinymodem::AX25Decoder::pending_len = 0
protected

◆ pll

float tinymodem::AX25Decoder::pll = 0
protected

◆ PLL_GAIN

float tinymodem::AX25Decoder::PLL_GAIN = 0.15f
staticconstexprprotected

◆ pll_step

float tinymodem::AX25Decoder::pll_step = 0.025f
protected

◆ pos

int tinymodem::AX25Decoder::pos = 0
protected

◆ products

audio_tools::Vector<float> tinymodem::AX25Decoder::products
protected

◆ sample_count

uint32_t tinymodem::AX25Decoder::sample_count = 0
protected

◆ space

Phasor tinymodem::AX25Decoder::space
protected

◆ sums

float tinymodem::AX25Decoder::sums[4] = {0, 0, 0, 0}
protected

◆ text

char tinymodem::AX25Decoder::text[AX25Frame::MAX_FRAME *2]
protected

◆ window

int tinymodem::AX25Decoder::window = 40
protected

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