| libbladeRF 2.6.0-git-fcf94233-dirty Nuand bladeRF library

Loading...
Searching...
No Matches
Functions
Synchronous API
Streaming

## Description

This group of functions presents synchronous, blocking calls (with optional timeouts) for transmitting and receiving samples.

The synchronous interface is built atop the asynchronous interface, and is generally less complex and easier to work with. It alleviates the need to explicitly spawn threads (it is done under the hood) and manually manage sample buffers.

Under the hood, this interface spawns worker threads to handle an asynchronous stream and perform thread-safe buffer management.

These functions are thread-safe.

The following pages provide additional information and example usage:

- Basic usage without metadata
- Synchronous RX with metadata
- Synchronous TX with metadata

## Functions
API_EXPORT int CALL_CONV | bladerf_sync_config (struct bladerf *dev, bladerf_channel_layout layout, bladerf_format format, unsigned int num_buffers, unsigned int buffer_size, unsigned int num_transfers, unsigned int stream_timeout)
API_EXPORT int CALL_CONV | bladerf_sync_tx (struct bladerf *dev, const void *samples, unsigned int num_samples, struct bladerf_metadata *metadata, unsigned int timeout_ms)
API_EXPORT int CALL_CONV | bladerf_sync_rx (struct bladerf *dev, void *samples, unsigned int num_samples, struct bladerf_metadata *metadata, unsigned int timeout_ms)

## Function Documentation

## ◆ bladerf_sync_config()

API_EXPORT int CALL_CONV bladerf_sync_config | ( | struct bladerf * | dev,
|  | bladerf_channel_layout | layout,
|  | bladerf_format | format,
|  | unsigned int | num_buffers,
|  | unsigned int | buffer_size,
|  | unsigned int | num_transfers,
|  | unsigned int | stream_timeout )

(Re)Configure a device for synchronous transmission or reception

This function sets up the device for the specified format and initializes the underlying asynchronous stream parameters

This function does not call bladerf_enable_module(). The API user is responsible for enabling/disable streams when desired.

Note that (re)configuring the TX direction does not affect the RX direction, and vice versa. This call configures each direction independently.

Memory allocated by this function will be deallocated when bladerf_close() is called.

See also
  The bladerf_init_stream() documentation for information on determining appropriate values for buffers_size, num_transfers, and stream_timeout.

Note
  The num_buffers parameter should generally be increased as the amount of work done between bladerf_sync_rx() or bladerf_sync_tx() calls increases.

Parameters

  | dev | Device to configure
  [in] | layout | Stream direction and layout
  [in] | format | Format to use in synchronous data transfers
  [in] | num_buffers | The number of buffers to use in the underlying data stream. This must be greater than the num_xfers parameter.
  [in] | buffer_size | The size of the underlying stream buffers, in samples. Must be a multiple of: 8192 bytes (2048 for FW < v2.5.0) For SC16_Q11_PACKED format, multiply by 3 Invalid sizes are automatically rounded up.
  [in] | num_transfers | The number of active USB transfers that may be in-flight at any given time. If unsure of what to use here, try values of 4, 8, or 16.
  [in] | stream_timeout | Timeout (milliseconds) for transfers in the underlying data stream.

Returns
  0 on success, BLADERF_ERR_UNSUPPORTED if libbladeRF is not built with support for this functionality, or a value from Error codes list on failures.

## ◆ bladerf_sync_rx()

API_EXPORT int CALL_CONV bladerf_sync_rx | ( | struct bladerf * | dev,
|  | void * | samples,
|  | unsigned int | num_samples,
|  | struct bladerf_metadata * | metadata,
|  | unsigned int | timeout_ms )

Receive IQ samples.

Under the hood, this call starts up an underlying asynchronous stream as needed. This stream can be stopped by disabling the RX channel. (See bladerf_enable_module for more details.)

Precondition
  A bladerf_sync_config() call has been to configure the device for synchronous data transfer.

Note
  A call to bladerf_enable_module() should be made before attempting to receive samples. Failing to do this may result in timeouts and other errors.

Parameters

  | dev | Device handle
  [out] | samples | Buffer to store samples in. The caller is responsible for ensuring this buffer is sufficiently large for the number of samples requested, considering the size of the sample format being used.
  [in] | num_samples | Number of samples to read
  [out] | metadata | Sample metadata. This must be provided when using the BLADERF_FORMAT_SC16_Q11_META format, but may be NULL when the interface is configured for the BLADERF_FORMAT_SC16_Q11 format.
  [in] | timeout_ms | Timeout (milliseconds) for this call to complete. Zero implies "infinite."

Returns
  0 on success, BLADERF_ERR_UNSUPPORTED if libbladeRF is not built with support for this functionality, or a value from Error codes list on failures.

## ◆ bladerf_sync_tx()

API_EXPORT int CALL_CONV bladerf_sync_tx | ( | struct bladerf * | dev,
|  | const void * | samples,
|  | unsigned int | num_samples,
|  | struct bladerf_metadata * | metadata,
|  | unsigned int | timeout_ms )

Transmit IQ samples.

Under the hood, this call starts up an underlying asynchronous stream as needed. This stream can be stopped by disabling the TX channel. (See bladerf_enable_module for more details.)

Samples will only be sent to the FPGA when a buffer have been filled. The number of samples required to fill a buffer corresponds to the buffer_size parameter passed to bladerf_sync_config().

Precondition
  A bladerf_sync_config() call has been to configure the device for synchronous data transfer.

Note
  A call to bladerf_enable_module() should be made before attempting to transmit samples. Failing to do this may result in timeouts and other errors.

Parameters

  | dev | Device handle
  [in] | samples | Array of samples
  [in] | num_samples | Number of samples to write
  [in] | metadata | Sample metadata. This must be provided when using the BLADERF_FORMAT_SC16_Q11_META format, but may be NULL when the interface is configured for the BLADERF_FORMAT_SC16_Q11 format.
  [in] | timeout_ms | Timeout (milliseconds) for this call to complete. Zero implies "infinite."

Returns
  0 on success, BLADERF_ERR_UNSUPPORTED if libbladeRF is not built with support for this functionality, or a value from Error codes list on failures.