spandsp 3.0.0
async.h File Reference

Go to the source code of this file.

Typedefs

typedef void(* span_put_msg_func_t) (void *user_data, const uint8_t *msg, int len)
 
typedef void(* put_msg_func_t) (void *user_data, const uint8_t *msg, int len)
 
typedef int(* span_get_msg_func_t) (void *user_data, uint8_t *msg, int max_len)
 
typedef int(* get_msg_func_t) (void *user_data, uint8_t *msg, int max_len)
 
typedef void(* span_put_byte_func_t) (void *user_data, int byte)
 
typedef void(* put_byte_func_t) (void *user_data, int byte)
 
typedef int(* span_get_byte_func_t) (void *user_data)
 
typedef int(* get_byte_func_t) (void *user_data)
 
typedef void(* span_put_bit_func_t) (void *user_data, int bit)
 
typedef void(* put_bit_func_t) (void *user_data, int bit)
 
typedef int(* span_get_bit_func_t) (void *user_data)
 
typedef int(* get_bit_func_t) (void *user_data)
 
typedef void(* span_modem_status_func_t) (void *user_data, int status)
 
typedef void(* modem_status_func_t) (void *user_data, int status)
 
typedef struct async_tx_state_s async_tx_state_t
 
typedef struct async_rx_state_s async_rx_state_t
 

Enumerations

enum  {
  SIG_STATUS_CARRIER_DOWN = -1 , SIG_STATUS_CARRIER_UP = -2 , SIG_STATUS_TRAINING_IN_PROGRESS = -3 , SIG_STATUS_TRAINING_SUCCEEDED = -4 ,
  SIG_STATUS_TRAINING_FAILED = -5 , SIG_STATUS_FRAMING_OK = -6 , SIG_STATUS_END_OF_DATA = -7 , SIG_STATUS_ABORT = -8 ,
  SIG_STATUS_BREAK = -9 , SIG_STATUS_SHUTDOWN_COMPLETE = -10 , SIG_STATUS_OCTET_REPORT = -11 , SIG_STATUS_POOR_SIGNAL_QUALITY = -12 ,
  SIG_STATUS_MODEM_RETRAIN_OCCURRED = -13 , SIG_STATUS_LINK_CONNECTED = -14 , SIG_STATUS_LINK_DISCONNECTED = -15 , SIG_STATUS_LINK_ERROR = -16 ,
  SIG_STATUS_LINK_IDLE = -17
}
 
enum  {
  ASYNC_PARITY_NONE = 0 , ASYNC_PARITY_EVEN , ASYNC_PARITY_ODD , ASYNC_PARITY_MARK ,
  ASYNC_PARITY_SPACE
}
 

Functions

const char * signal_status_to_str (int status)
 Convert a signal status to a short text description.
 
void async_rx_put_bit (void *user_data, int bit)
 Accept a bit from a received serial bit stream.
 
int async_rx_get_parity_errors (async_rx_state_t *s, bool reset)
 
int async_rx_get_framing_errors (async_rx_state_t *s, bool reset)
 
async_rx_state_tasync_rx_init (async_rx_state_t *s, int data_bits, int parity, int stop_bits, bool use_v14, span_put_byte_func_t put_byte, void *user_data)
 Initialise an asynchronous data receiver context.
 
int async_rx_release (async_rx_state_t *s)
 
int async_rx_free (async_rx_state_t *s)
 
void async_tx_presend_bits (async_tx_state_t *s, int bits)
 Set a minimum number of bit times of stop bit state before character transmission commences.
 
int async_tx_get_bit (void *user_data)
 Get the next bit of a transmitted serial bit stream.
 
async_tx_state_tasync_tx_init (async_tx_state_t *s, int data_bits, int parity, int stop_bits, bool use_v14, span_get_byte_func_t get_byte, void *user_data)
 Initialise an asynchronous data transmit context.
 
int async_tx_release (async_tx_state_t *s)
 
int async_tx_free (async_tx_state_t *s)
 

Typedef Documentation

◆ async_rx_state_t

Asynchronous data receive descriptor. This defines the state of a single working instance of an asynchronous serial to byte converter, for use in FSK modems.

◆ async_tx_state_t

Asynchronous data transmit descriptor. This defines the state of a single working instance of a byte to asynchronous serial converter, for use in FSK modems.

◆ span_get_bit_func_t

typedef int(* span_get_bit_func_t) (void *user_data)

Bit get function for data pumps

◆ span_get_byte_func_t

typedef int(* span_get_byte_func_t) (void *user_data)

Byte get function for data pumps

◆ span_get_msg_func_t

typedef int(* span_get_msg_func_t) (void *user_data, uint8_t *msg, int max_len)

Message get function for data pumps

◆ span_modem_status_func_t

typedef void(* span_modem_status_func_t) (void *user_data, int status)

Status change callback function for data pumps

◆ span_put_bit_func_t

typedef void(* span_put_bit_func_t) (void *user_data, int bit)

Bit put function for data pumps

◆ span_put_byte_func_t

typedef void(* span_put_byte_func_t) (void *user_data, int byte)

Byte put function for data pumps

◆ span_put_msg_func_t

typedef void(* span_put_msg_func_t) (void *user_data, const uint8_t *msg, int len)

Message put function for data pumps

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Special "bit" values for the bitstream put and get functions, and the signal status functions.

Enumerator
SIG_STATUS_CARRIER_DOWN 

The carrier signal has dropped.

SIG_STATUS_CARRIER_UP 

The carrier signal is up. This merely indicates that carrier energy has been seen. It is not an indication that the carrier is either valid, or of the expected type.

SIG_STATUS_TRAINING_IN_PROGRESS 

The modem is training. This is an early indication that the signal seems to be of the right type. This may be needed in time critical applications, like T.38, to forward an early indication of what is happening on the wire.

SIG_STATUS_TRAINING_SUCCEEDED 

The modem has trained, and is ready for data exchange.

SIG_STATUS_TRAINING_FAILED 

The modem has failed to train.

SIG_STATUS_FRAMING_OK 

Packet framing (e.g. HDLC framing) is OK.

SIG_STATUS_END_OF_DATA 

The data stream has ended.

SIG_STATUS_ABORT 

An abort signal (e.g. an HDLC abort) has been received.

SIG_STATUS_BREAK 

A break signal (e.g. an async break) has been received.

SIG_STATUS_SHUTDOWN_COMPLETE 

A modem has completed its task, and shut down.

SIG_STATUS_OCTET_REPORT 

Regular octet report for things like HDLC to the MTP standards.

SIG_STATUS_POOR_SIGNAL_QUALITY 

Notification that a modem has detected signal quality degradation.

SIG_STATUS_MODEM_RETRAIN_OCCURRED 

Notification that a modem retrain has occurred.

SIG_STATUS_LINK_CONNECTED 

The link protocol (e.g. V.42) has connected.

SIG_STATUS_LINK_DISCONNECTED 

The link protocol (e.g. V.42) has disconnected.

SIG_STATUS_LINK_ERROR 

An error has occurred in the link protocol (e.g. V.42).

SIG_STATUS_LINK_IDLE 

Keep the link in an idle state, as there is nothing to send.

◆ anonymous enum

anonymous enum
Enumerator
ASYNC_PARITY_NONE 

No parity bit should be used

ASYNC_PARITY_EVEN 

An even parity bit will exist, after the data bits

ASYNC_PARITY_ODD 

An odd parity bit will exist, after the data bits

Function Documentation

◆ async_rx_init()

async_rx_state_t * async_rx_init ( async_rx_state_t * s,
int data_bits,
int parity,
int stop_bits,
bool use_v14,
span_put_byte_func_t put_byte,
void * user_data )

Initialise an asynchronous data receiver context.

Initialise an asynchronous data receiver context.

Parameters
sThe receiver context.
data_bitsThe number of data bits.
parityThe type of parity.
stop_bitsThe number of stop bits.
use_v14True if V.14 rate adaption processing should be used.
put_byteThe callback routine used to put the received data.
user_dataAn opaque pointer.
Returns
A pointer to the initialised context, or NULL if there was a problem.

References ASYNC_PARITY_NONE, async_rx_state_s::bitpos, async_rx_state_s::data_bits, async_rx_state_s::frame_in_progress, async_rx_state_s::framing_errors, async_rx_state_s::parity, async_rx_state_s::parity_errors, async_rx_state_s::put_byte, async_rx_state_s::total_data_bits, async_rx_state_s::use_v14, and async_rx_state_s::user_data.

◆ async_rx_put_bit()

void async_rx_put_bit ( void * user_data,
int bit )

Accept a bit from a received serial bit stream.

Accept a bit from a received serial bit stream

Parameters
user_dataAn opaque point which must point to a receiver context.
bitThe new bit. Some special values are supported for this field.
  • SIG_STATUS_CARRIER_UP
  • SIG_STATUS_CARRIER_DOWN
  • SIG_STATUS_TRAINING_SUCCEEDED
  • SIG_STATUS_TRAINING_FAILED
  • SIG_STATUS_END_OF_DATA

References ASYNC_PARITY_EVEN, ASYNC_PARITY_NONE, ASYNC_PARITY_ODD, async_rx_state_s::bitpos, async_rx_state_s::frame_in_progress, async_rx_state_s::framing_errors, async_rx_state_s::parity, async_rx_state_s::parity_errors, async_rx_state_s::put_byte, SIG_STATUS_CARRIER_DOWN, SIG_STATUS_CARRIER_UP, SIG_STATUS_END_OF_DATA, SIG_STATUS_TRAINING_FAILED, SIG_STATUS_TRAINING_IN_PROGRESS, SIG_STATUS_TRAINING_SUCCEEDED, async_rx_state_s::total_data_bits, async_rx_state_s::use_v14, and async_rx_state_s::user_data.

◆ async_tx_get_bit()

int async_tx_get_bit ( void * user_data)

Get the next bit of a transmitted serial bit stream.

Get the next bit of a transmitted serial bit stream.

Parameters
user_dataAn opaque point which must point to a transmitter context.
Returns
the next bit, or a status value passed through from the routine which gets the data bytes.

References ASYNC_PARITY_EVEN, ASYNC_PARITY_ODD, async_tx_state_s::bitpos, async_tx_state_s::data_bits, async_tx_state_s::frame_in_progress, async_tx_state_s::get_byte, async_tx_state_s::parity, async_tx_state_s::presend_bits, SIG_STATUS_LINK_IDLE, async_tx_state_s::total_bits, async_tx_state_s::total_data_bits, and async_tx_state_s::user_data.

◆ async_tx_init()

async_tx_state_t * async_tx_init ( async_tx_state_t * s,
int data_bits,
int parity,
int stop_bits,
bool use_v14,
span_get_byte_func_t get_byte,
void * user_data )

Initialise an asynchronous data transmit context.

Initialise an asynchronous data transmit context.

Parameters
sThe transmitter context.
data_bitsThe number of data bit.
parityThe type of parity.
stop_bitsThe number of stop bits.
use_v14True if V.14 rate adaption processing should be used.
get_byteThe callback routine used to get the data to be transmitted.
user_dataAn opaque pointer.
Returns
A pointer to the initialised context, or NULL if there was a problem.

References ASYNC_PARITY_NONE, async_tx_state_s::bitpos, async_tx_state_s::data_bits, async_tx_state_s::frame_in_progress, async_tx_state_s::get_byte, async_tx_state_s::parity, async_tx_state_s::presend_bits, async_tx_state_s::total_bits, async_tx_state_s::total_data_bits, and async_tx_state_s::user_data.

◆ async_tx_presend_bits()

void async_tx_presend_bits ( async_tx_state_t * s,
int bits )

Set a minimum number of bit times of stop bit state before character transmission commences.

Set a minimum number of bit times of stop bit state before character transmission commences.

Parameters
user_dataAn opaque point which must point to a transmitter context.
thenumber of bits.

References async_tx_state_s::presend_bits.

◆ signal_status_to_str()

const char * signal_status_to_str ( int status)