libbladeRF  1.1.0
Nuand bladeRF library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Data Structures | Macros | Enumerations | Functions
Initialization/deinitialization

Data Structures

struct  bladerf_devinfo
 

Macros

#define BLADERF_SERIAL_LENGTH   33
 

Enumerations

enum  bladerf_backend {
  BLADERF_BACKEND_ANY, BLADERF_BACKEND_LINUX, BLADERF_BACKEND_LIBUSB, BLADERF_BACKEND_CYPRESS,
  BLADERF_BACKEND_DUMMY = 100
}
 
enum  bladerf_dev_speed { BLADERF_DEVICE_SPEED_UNKNOWN, BLADERF_DEVICE_SPEED_HIGH, BLADERF_DEVICE_SPEED_SUPER }
 

Functions

API_EXPORT int CALL_CONV bladerf_get_device_list (struct bladerf_devinfo **devices)
 
API_EXPORT void CALL_CONV bladerf_free_device_list (struct bladerf_devinfo *devices)
 
API_EXPORT int CALL_CONV bladerf_open_with_devinfo (struct bladerf **device, struct bladerf_devinfo *devinfo)
 
API_EXPORT int CALL_CONV bladerf_open (struct bladerf **device, const char *device_identifier)
 
API_EXPORT void CALL_CONV bladerf_close (struct bladerf *device)
 

Detailed Description

The functions in this section provide the ability query available devices, initialize them, and deinitialize them. They are not guaranteed to be thread-safe; the caller is responsible for ensuring they are executed atomically.

Macro Definition Documentation

#define BLADERF_SERIAL_LENGTH   33

Length of device serial number string, including NUL-terminator

Definition at line 131 of file libbladeRF.h.

Enumeration Type Documentation

Backend by which the host communicates with the device

Enumerator
BLADERF_BACKEND_ANY 

"Don't Care" – use any available backend

BLADERF_BACKEND_LINUX 

Linux kernel driver

BLADERF_BACKEND_LIBUSB 

libusb

BLADERF_BACKEND_CYPRESS 

CyAPI

BLADERF_BACKEND_DUMMY 

Dummy used for development purposes

Definition at line 111 of file libbladeRF.h.

This enum describes the USB Speed at which the bladeRF is connected. Speeds not listed here are not supported.

Definition at line 124 of file libbladeRF.h.

Function Documentation

API_EXPORT void CALL_CONV bladerf_close ( struct bladerf *  device)

Close device

Note
Failing to close a device will result in memory leaks.
Postcondition
device is deallocated and may no longer be used.
Parameters
deviceDevice handle previously obtained by bladerf_open(). This function does nothing if device is NULL.
API_EXPORT void CALL_CONV bladerf_free_device_list ( struct bladerf_devinfo devices)

Free device list returned by bladerf_get_device_list()

Parameters
devicesList of available devices
API_EXPORT int CALL_CONV bladerf_get_device_list ( struct bladerf_devinfo **  devices)

Obtain a list of bladeRF devices attached to the system

Parameters
[out]devices
Returns
number of items in returned device list, or value from Error codes list on failure
API_EXPORT int CALL_CONV bladerf_open ( struct bladerf **  device,
const char *  device_identifier 
)

Open specified device using a device identifier string. See bladerf_open_with_devinfo() if a device identifier string is not readily available.

The general form of the device identifier string is;

<backend>:[device=<bus>:<addr>] [instance=<n>] [serial=<serial>]

An empty ("") or NULL device identifier will result in the first encountered device being opened (using the first discovered backend)

The 'backend' describes the mechanism used to communicate with the device, and may be one of the following:

  • *: Any available backend
  • libusb: libusb (See libusb changelog notes for required version, given your OS and controller)
  • cypress: Cypress CyUSB/CyAPI backend (Windows only)

If no arguments are provided after the backend, the first encountered device on the specified backend will be opened. Note that a backend is required, if any arguments are to be provided.

Next, any provided arguments are provide as used to find the desired device. Be sure not to over constrain the search. Generally, only one of the above is required – providing all of these may over constrain the search for the desired device (e.g., if a serial number matches, but not on the specified bus and address.)

  • device=<bus>:<addr>
    • Specifies USB bus and address. Decimal or hex prefixed by '0x' is permitted.
  • instance=<n>
    • Nth instance encountered, 0-indexed
  • serial=<serial>
    • Device's serial number.
Parameters
[out]deviceUpdate with device handle on success
[in]device_identifierDevice identifier, formatted as described above
Returns
0 on success, or value from Error codes list on failure
API_EXPORT int CALL_CONV bladerf_open_with_devinfo ( struct bladerf **  device,
struct bladerf_devinfo devinfo 
)

Opens device specified by provided bladerf_devinfo structure

This function is generally preferred over bladerf_open() when a device identifier string is not already provided.

The most common uses of this function are to:

Below is an example of how to use this function to open a device with a specific serial number:

struct bladerf * open_bladerf_from_serial(const char *serial)
{
int status;
struct bladerf *dev;
struct bladerf_devinfo info;
/* Initialize all fields to "don't care" wildcard values.
*
* Immediately passing this to bladerf_open_with_devinfo() would cause
* libbladeRF to open any device on any available backend. */
/* Specify the desired device's serial number, while leaving all other
* fields in the info structure wildcard values */
strncpy(info.serial, serial, BLADERF_SERIAL_LENGTH - 1);
info.serial[BLADERF_SERIAL_LENGTH - 1] = '\0';
status = bladerf_open_with_devinfo(&dev, &info);
if (status == BLADERF_ERR_NODEV) {
printf("No devices available with serial=%s\n", serial);
return NULL;
} else if (status != 0) {
fprintf(stderr, "Failed to open device with serial=%s (%s)\n",
serial, bladerf_strerror(status));
return NULL;
} else {
return dev;
}
}
Parameters
[out]deviceUpdate with device handle on success
[in]devinfoDevice specification. If NULL, any available device will be opened.
Returns
0 on success, or value from Error codes list on failure