Skip to content

Instantly share code, notes, and snippets.

@jynik
Created June 28, 2015 03:18
Show Gist options
  • Save jynik/e1b3fb544fd8e02c6067 to your computer and use it in GitHub Desktop.
Save jynik/e1b3fb544fd8e02c6067 to your computer and use it in GitHub Desktop.
Print bladeRF library and device versions
#include <stdlib.h>
#include <stdio.h>
#include <libbladeRF.h>
int main(int argc, char *argv[])
{
int ret = 0;
int status;
struct bladerf *dev;
const char *dev_specifier = NULL;
struct bladerf_version lib_version, fpga_version, fw_version;
if (argc >= 2) {
dev_specifier = argv[1];
}
status = bladerf_open(&dev, dev_specifier);
if (status != 0) {
fprintf(stderr, "Failed to open device: %s\n",
bladerf_strerror(status));
return EXIT_FAILURE;
}
bladerf_version(&lib_version);
printf(" libbladeRF version: %s\n", lib_version.describe);
status = bladerf_fw_version(dev, &fw_version);
if (status == 0) {
printf(" Firmware version: %s\n", fw_version.describe);
} else {
fprintf(stderr, "Failed to get firmware version: %s\n",
bladerf_strerror(status));
ret = EXIT_FAILURE;
}
status = bladerf_is_fpga_configured(dev);
if (status == 1) {
status = bladerf_fpga_version(dev, &fpga_version);
if (status == 0) {
printf(" FPGA version: %s\n", fpga_version.describe);
} else {
fprintf(stderr, "Failed to get FPGA version: %s\n",
bladerf_strerror(status));
}
} else if (status == 0) {
printf("FPGA not loaded.\n");
} else {
fprintf(stderr, "Failed to determine if FPGA is configured: %s\n",
bladerf_strerror(status));
ret = EXIT_FAILURE;
}
bladerf_close(dev);
return ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment