spandsp 0.0.6
async.h File Reference

Go to the source code of this file.

Macros

#define modem_rx_status_func_t   modem_status_func_t
 
#define modem_tx_status_func_t   modem_status_func_t
 

Typedefs

typedef void(* put_msg_func_t) (void *user_data, const uint8_t *msg, int len)
 
typedef int(* get_msg_func_t) (void *user_data, uint8_t *msg, int max_len)
 
typedef void(* put_byte_func_t) (void *user_data, int byte)
 
typedef int(* get_byte_func_t) (void *user_data)
 
typedef void(* put_bit_func_t) (void *user_data, int bit)
 
typedef int(* get_bit_func_t) (void *user_data)
 
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
}
 
enum  { ASYNC_PARITY_NONE = 0 , ASYNC_PARITY_EVEN , ASYNC_PARITY_ODD }
 

Functions

const char * signal_status_to_str (int status)
 Convert a signal status to a short text description. More...
 
async_tx_state_tasync_tx_init (async_tx_state_t *s, int data_bits, int parity_bits, int stop_bits, int use_v14, get_byte_func_t get_byte, void *user_data)
 Initialise an asynchronous data transmit context. More...
 
int async_tx_release (async_tx_state_t *s)
 
int async_tx_free (async_tx_state_t *s)
 
 SPAN_DECLARE_NONSTD (int) async_tx_get_bit(void *user_data)
 Get the next bit of a transmitted serial bit stream. More...
 
async_rx_state_tasync_rx_init (async_rx_state_t *s, int data_bits, int parity_bits, int stop_bits, int use_v14, put_byte_func_t put_byte, void *user_data)
 Initialise an asynchronous data receiver context. More...
 
int async_rx_release (async_rx_state_t *s)
 
int async_rx_free (async_rx_state_t *s)
 
 SPAN_DECLARE_NONSTD (void) async_rx_put_bit(void *user_data
 Accept a bit from a received serial bit stream. More...
 

Variables

int bit
 

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.

◆ get_bit_func_t

typedef int(* get_bit_func_t) (void *user_data)

Bit get function for data pumps

◆ get_byte_func_t

typedef int(* get_byte_func_t) (void *user_data)

Byte get function for data pumps

◆ get_msg_func_t

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

Message get function for data pumps

◆ modem_status_func_t

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

Status change callback function for data pumps

◆ put_bit_func_t

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

Bit put function for data pumps

◆ put_byte_func_t

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

Byte put function for data pumps

◆ put_msg_func_t

typedef void(* 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).

◆ 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_bits,
int  stop_bits,
int  use_v14,
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.
parity_bitsThe 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.

◆ async_tx_init()

async_tx_state_t * async_tx_init ( async_tx_state_t s,
int  data_bits,
int  parity_bits,
int  stop_bits,
int  use_v14,
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.
parity_bitsThe 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.

◆ signal_status_to_str()

const char * signal_status_to_str ( int  status)

◆ SPAN_DECLARE_NONSTD() [1/2]

SPAN_DECLARE_NONSTD ( int  )

Get the next bit of a transmitted serial bit stream.

Process a block of received V.8 audio samples.

Fake processing of a missing block of received V.29 modem audio samples.

Fake processing of a missing block of received V.27ter modem audio samples.

Generate a block of V.22bis modem audio samples.

Fake processing of a missing block of received V.22bis modem audio samples.

Process a block of received V.18 audio samples.

Fake processing of a missing block of received V.17 modem audio samples.

Generate a block of FAX audio samples.

Apply fake received audio processing.

Process a received T.38 IFP packet from a reliable stream (e.g. TCP).

Generate a block of T.31 modem audio samples.

Fake processing of a missing block of received T.31 modem audio samples.

Dummy receive fillin callback.

Dummy receive callback.

Process a block of samples through an instance of the modem connect tones detector.

Get the next sequence of bytes for transmission.

Get the next byte for transmission.

Fake processing of a missing block of received FSK modem audio samples.

Process a block of received FSK modem audio samples.

Apply T.30 transmit processing to generate a block of audio samples.

Apply fake T.30 receive processing.

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 PUTBIT_END_OF_DATA to indicate the data stream has ended.

Apply fake T.30 receive processing when a block of audio samples is missing (e.g due to packet loss).

Parameters
sThe FAX context.
lenThe number of samples to fake.
Returns
The number of samples unprocessed. This should only be non-zero if the software has reached the end of the FAX call.

Apply T.30 transmit processing to generate a block of audio samples.

Parameters
sThe FAX context.
ampThe audio sample buffer.
max_lenThe number of samples to be generated.
Returns
The number of samples actually generated. This will be zero when there is nothing to send.

Process a block of received FSK modem audio samples.

Parameters
sThe modem context.
ampThe audio sample buffer.
lenThe number of samples in the buffer.
Returns
The number of samples unprocessed.

Fake processing of a missing block of received FSK modem audio samples (e.g due to packet loss).

Parameters
sThe modem context.
lenThe number of samples to fake.
Returns
The number of samples unprocessed.
Parameters
sA pointer to an HDLC transmitter context.
Returns
The next byte for transmission.
Parameters
sA pointer to an HDLC transmitter context.
bufThe buffer for the data.
max_lenThe number of bytes to get.
Returns
The number of bytes actually got.
Parameters
sThe context.
ampAn array of signal samples.
lenThe number of samples in the array.
Returns
The number of unprocessed samples.

A dummy routine to use as a receive callback, when we aren't really trying to process what is received. It just absorbs and ignores the data.

Parameters
user_dataThe context.
ampThe signal.buffer
lenThe length of the signal buffer
Returns
0.

A dummy routine to use as a receive fillin callback, when we aren't really trying to process what is received. It just absorbs and ignores the request.

Parameters
user_dataThe context.
lenThe length of the signal buffer
Returns
0.

Fake processing of a missing block of received T.31 modem audio samples (e.g due to packet loss).

Parameters
sThe T.31 modem context.
lenThe number of samples to fake.
Returns
The number of samples unprocessed.

Generate a block of T.31 modem audio samples.

Parameters
sThe T.31 modem context.
ampThe audio sample buffer.
max_lenThe number of samples to be generated.
Returns
The number of samples actually generated.
Parameters
sThe T.38 context.
bufThe packet contents.
lenThe length of the packet contents.
seq_noThe packet sequence number, used for logging purposes.
Returns
The length of the packet processed, or -1 if there is an error in the packet, or too few bytes of data to complete it.

Apply fake processing when a block of audio samples is missing (e.g due to packet loss).

Parameters
sThe T.38 context.
lenThe number of samples to fake.
Returns
The number of samples unprocessed. This should only be non-zero if the software has reached the end of the FAX call.

Generate a block of FAX audio samples.

Parameters
sThe T.38 context.
ampThe audio sample buffer.
max_lenThe number of samples to be generated.
Returns
The number of samples actually generated.

Fake processing of a missing block of received V.17 modem audio samples. (e.g due to packet loss).

Parameters
sThe modem context.
lenThe number of samples to fake.
Returns
The number of samples unprocessed.

Process a block of received V.18 audio samples.

Parameters
sThe V.18 context.
ampThe audio sample buffer.
lenThe number of samples in the buffer.

Fake processing of a missing block of received V.22bis modem audio samples. (e.g due to packet loss).

Parameters
sThe modem context.
lenThe number of samples to fake.
Returns
The number of samples unprocessed.

Generate a block of V.22bis modem audio samples.

Parameters
sThe modem context.
ampThe audio sample buffer.
lenThe number of samples to be generated.
Returns
The number of samples actually generated.

Fake processing of a missing block of received V.27ter modem audio samples. (e.g due to packet loss).

Parameters
sThe modem context.
lenThe number of samples to fake.
Returns
The number of samples unprocessed.

Fake processing of a missing block of received V.29 modem audio samples. (e.g due to packet loss).

Parameters
sThe modem context.
lenThe number of samples to fake.
Returns
The number of samples unprocessed.

Process a block of received V.8 audio samples.

Parameters
sThe V.8 context.
ampThe audio sample buffer.
lenThe number of samples in the buffer.

Get the next bit of a transmitted serial bit stream.

Apply T.30 transmit processing to generate a block of audio samples.

Apply fake T.30 receive processing.

Apply T.30 receive processing to a block of audio samples.

Parameters
sThe FAX context.
ampThe audio sample buffer.
lenThe number of samples in the buffer.
Returns
The number of samples unprocessed. This should only be non-zero if the software has reached the end of the FAX call.

Apply fake T.30 receive processing when a block of audio samples is missing (e.g due to packet loss).

Parameters
sThe FAX context.
lenThe number of samples to fake.
Returns
The number of samples unprocessed. This should only be non-zero if the software has reached the end of the FAX call.

Apply T.30 transmit processing to generate a block of audio samples.

Parameters
sThe FAX context.
ampThe audio sample buffer.
max_lenThe number of samples to be generated.
Returns
The number of samples actually generated. This will be zero when there is nothing to send.

Get the next bit of a transmitted serial bit stream.

Fake processing of a missing block of received FSK modem audio samples.

Process a block of received FSK modem audio samples.

Generate a block of FSK modem audio samples.

Parameters
sThe modem context.
ampThe audio sample buffer.
lenThe number of samples to be generated.
Returns
The number of samples actually generated.

Process a block of received FSK modem audio samples.

Parameters
sThe modem context.
ampThe audio sample buffer.
lenThe number of samples in the buffer.
Returns
The number of samples unprocessed.

Fake processing of a missing block of received FSK modem audio samples (e.g due to packet loss).

Parameters
sThe modem context.
lenThe number of samples to fake.
Returns
The number of samples unprocessed.

Get the next bit of a transmitted serial bit stream.

Get the next sequence of bytes for transmission.

Get the next byte for transmission.

Parameters
sA pointer to an HDLC transmitter context.
Returns
The next bit for transmission.
Parameters
sA pointer to an HDLC transmitter context.
Returns
The next byte for transmission.
Parameters
sA pointer to an HDLC transmitter context.
bufThe buffer for the data.
max_lenThe number of bytes to get.
Returns
The number of bytes actually got.

Get the next bit of a transmitted serial bit stream.

Process a block of samples through an instance of the modem connect tones detector.

Parameters
sThe context.
ampAn array of signal samples.
lenThe number of samples to generate.
Returns
The number of samples generated.
Parameters
sThe context.
ampAn array of signal samples.
lenThe number of samples in the array.
Returns
The number of unprocessed samples.

Get the next bit of a transmitted serial bit stream.

Dummy receive fillin callback.

Dummy receive callback.

Generate a block of silent audio samples.

Parameters
sThe silence generator context.
ampThe audio sample buffer.
max_lenThe number of samples to be generated.
Returns
The number of samples actually generated. This will be zero when there is nothing to send.

A dummy routine to use as a receive callback, when we aren't really trying to process what is received. It just absorbs and ignores the data.

Parameters
user_dataThe context.
ampThe signal.buffer
lenThe length of the signal buffer
Returns
0.

A dummy routine to use as a receive fillin callback, when we aren't really trying to process what is received. It just absorbs and ignores the request.

Parameters
user_dataThe context.
lenThe length of the signal buffer
Returns
0.

Get the next bit of a transmitted serial bit stream.

Generate a block of T.31 modem audio samples.

Fake processing of a missing block of received T.31 modem audio samples.

Process a block of received T.31 modem audio samples.

Parameters
sThe T.31 modem context.
ampThe audio sample buffer.
lenThe number of samples in the buffer.
Returns
The number of samples unprocessed.

Fake processing of a missing block of received T.31 modem audio samples (e.g due to packet loss).

Parameters
sThe T.31 modem context.
lenThe number of samples to fake.
Returns
The number of samples unprocessed.

Generate a block of T.31 modem audio samples.

Parameters
sThe T.31 modem context.
ampThe audio sample buffer.
max_lenThe number of samples to be generated.
Returns
The number of samples actually generated.

Get the next bit of a transmitted serial bit stream.

Process a received T.38 IFP packet from a reliable stream (e.g. TCP).

Parameters
sThe T.38 context.
bufThe packet contents.
lenThe length of the packet contents.
seq_noThe packet sequence number.
Returns
0 for OK, else -1.
Parameters
sThe T.38 context.
bufThe packet contents.
lenThe length of the packet contents.
seq_noThe packet sequence number, used for logging purposes.
Returns
The length of the packet processed, or -1 if there is an error in the packet, or too few bytes of data to complete it.

Get the next bit of a transmitted serial bit stream.

Generate a block of FAX audio samples.

Apply fake received audio processing.

Process a block of received FAX audio samples.

Parameters
sThe T.38 context.
ampThe audio sample buffer.
lenThe number of samples in the buffer.
Returns
The number of samples unprocessed.

Apply fake processing when a block of audio samples is missing (e.g due to packet loss).

Parameters
sThe T.38 context.
lenThe number of samples to fake.
Returns
The number of samples unprocessed. This should only be non-zero if the software has reached the end of the FAX call.

Generate a block of FAX audio samples.

Parameters
sThe T.38 context.
ampThe audio sample buffer.
max_lenThe number of samples to be generated.
Returns
The number of samples actually generated.

Get the next bit of a transmitted serial bit stream.

Fake processing of a missing block of received V.17 modem audio samples.

Process a block of received V.17 modem audio samples.

Parameters
sThe modem context.
ampThe audio sample buffer.
lenThe number of samples in the buffer.
Returns
The number of samples unprocessed.

Fake processing of a missing block of received V.17 modem audio samples. (e.g due to packet loss).

Parameters
sThe modem context.
lenThe number of samples to fake.
Returns
The number of samples unprocessed.

Get the next bit of a transmitted serial bit stream.

Generate a block of V.17 modem audio samples.

Parameters
sThe modem context.
ampThe audio sample buffer.
lenThe number of samples to be generated.
Returns
The number of samples actually generated.

Get the next bit of a transmitted serial bit stream.

Process a block of received V.18 audio samples.

Generate a block of V.18 audio samples.

Parameters
sThe V.18 context.
ampThe audio sample buffer.
max_lenThe number of samples to be generated.
Returns
The number of samples actually generated.

Process a block of received V.18 audio samples.

Parameters
sThe V.18 context.
ampThe audio sample buffer.
lenThe number of samples in the buffer.

Get the next bit of a transmitted serial bit stream.

Generate a block of V.22bis modem audio samples.

Fake processing of a missing block of received V.22bis modem audio samples.

Process a block of received V.22bis modem audio samples.

Parameters
sThe modem context.
ampThe audio sample buffer.
lenThe number of samples in the buffer.
Returns
The number of samples unprocessed.

Fake processing of a missing block of received V.22bis modem audio samples. (e.g due to packet loss).

Parameters
sThe modem context.
lenThe number of samples to fake.
Returns
The number of samples unprocessed.

Generate a block of V.22bis modem audio samples.

Parameters
sThe modem context.
ampThe audio sample buffer.
lenThe number of samples to be generated.
Returns
The number of samples actually generated.

Get the next bit of a transmitted serial bit stream.

Fake processing of a missing block of received V.27ter modem audio samples.

Process a block of received V.27ter modem audio samples.

Parameters
sThe modem context.
ampThe audio sample buffer.
lenThe number of samples in the buffer.
Returns
The number of samples unprocessed.

Fake processing of a missing block of received V.27ter modem audio samples. (e.g due to packet loss).

Parameters
sThe modem context.
lenThe number of samples to fake.
Returns
The number of samples unprocessed.

Get the next bit of a transmitted serial bit stream.

Generate a block of V.27ter modem audio samples.

Parameters
sThe modem context.
ampThe audio sample buffer.
lenThe number of samples to be generated.
Returns
The number of samples actually generated.

Get the next bit of a transmitted serial bit stream.

Fake processing of a missing block of received V.29 modem audio samples.

Process a block of received V.29 modem audio samples.

Parameters
sThe modem context.
ampThe audio sample buffer.
lenThe number of samples in the buffer.
Returns
The number of samples unprocessed.

Fake processing of a missing block of received V.29 modem audio samples. (e.g due to packet loss).

Parameters
sThe modem context.
lenThe number of samples to fake.
Returns
The number of samples unprocessed.

Get the next bit of a transmitted serial bit stream.

Generate a block of V.29 modem audio samples.

Parameters
sThe modem context.
ampThe audio sample buffer.
lenThe number of samples to be generated.
Returns
The number of samples actually generated.

Get the next bit of a transmitted serial bit stream.

Process a block of received V.8 audio samples.

Generate a block of V.8 audio samples.

Parameters
sThe V.8 context.
ampThe audio sample buffer.
max_lenThe number of samples to be generated.
Returns
The number of samples actually generated.

Process a block of received V.8 audio samples.

Parameters
sThe V.8 context.
ampThe audio sample buffer.
lenThe number of samples in the buffer.

◆ SPAN_DECLARE_NONSTD() [2/2]

SPAN_DECLARE_NONSTD ( void  )

Accept a bit from a received serial bit stream.

Process a received HDLC frame.

Put a series of bytes of data to an HDLC receiver.

Put a byte of data to an HDLC receiver.

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
sA pointer to an HDLC receiver context.
new_byteThe byte of data.
sA pointer to an HDLC receiver context.
bufThe buffer of data.
lenThe length of the data in the buffer.

Process a received HDLC frame.

Parameters
user_dataThe T.30 context.
msgThe HDLC message.
lenThe length of the message, in octets.
okTRUE if the frame was received without error.