Merge branch 'master' into sweep-csv
This commit is contained in:
@ -3,6 +3,33 @@
|
|||||||
cmake_minimum_required(VERSION 2.8)
|
cmake_minimum_required(VERSION 2.8)
|
||||||
project (hackrf_all)
|
project (hackrf_all)
|
||||||
|
|
||||||
|
#set(RELEASE "")
|
||||||
|
|
||||||
|
if(NOT DEFINED RELEASE)
|
||||||
|
execute_process(
|
||||||
|
COMMAND git log -n 1 --format=%h
|
||||||
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||||
|
RESULT_VARIABLE GIT_EXIT_VALUE
|
||||||
|
ERROR_QUIET
|
||||||
|
OUTPUT_VARIABLE GIT_VERSION
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
if (GIT_EXIT_VALUE)
|
||||||
|
set(RELEASE "unknown")
|
||||||
|
else (GIT_EXIT_VALUE)
|
||||||
|
execute_process(
|
||||||
|
COMMAND git status -s --untracked-files=no
|
||||||
|
OUTPUT_VARIABLE DIRTY
|
||||||
|
)
|
||||||
|
if ( NOT "${DIRTY}" STREQUAL "" )
|
||||||
|
set(DIRTY_FLAG "*")
|
||||||
|
else()
|
||||||
|
set(DIRTY_FLAG "")
|
||||||
|
endif()
|
||||||
|
set(RELEASE "git-${GIT_VERSION}${DIRTY_FLAG}")
|
||||||
|
endif (GIT_EXIT_VALUE)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_subdirectory(libhackrf)
|
add_subdirectory(libhackrf)
|
||||||
add_subdirectory(hackrf-tools)
|
add_subdirectory(hackrf-tools)
|
||||||
|
|
||||||
|
@ -23,11 +23,8 @@
|
|||||||
|
|
||||||
cmake_minimum_required(VERSION 2.8)
|
cmake_minimum_required(VERSION 2.8)
|
||||||
project(hackrf-tools C)
|
project(hackrf-tools C)
|
||||||
set(MAJOR_VERSION 0)
|
|
||||||
set(MINOR_VERSION 5)
|
|
||||||
set(PACKAGE hackrf-tools)
|
set(PACKAGE hackrf-tools)
|
||||||
set(VERSION_STRING ${MAJOR_VERSION}.${MINOR_VERSION})
|
add_definitions(-DTOOL_RELEASE="${RELEASE}")
|
||||||
set(VERSION ${VERSION_STRING})
|
|
||||||
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../cmake/modules)
|
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../cmake/modules)
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
|
@ -44,6 +44,10 @@ int main(void)
|
|||||||
hackrf_error_name(result), result);
|
hackrf_error_name(result), result);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("hackrf_info version: %s\n", TOOL_RELEASE);
|
||||||
|
printf("libhackrf version: %s (%s)\n", hackrf_library_release(),
|
||||||
|
hackrf_library_version());
|
||||||
|
|
||||||
list = hackrf_device_list();
|
list = hackrf_device_list();
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ static void usage() {
|
|||||||
printf("\t-n, --register <n>: set register number for read/write operations\n");
|
printf("\t-n, --register <n>: set register number for read/write operations\n");
|
||||||
printf("\t-r, --read: read register specified by last -n argument, or all registers\n");
|
printf("\t-r, --read: read register specified by last -n argument, or all registers\n");
|
||||||
printf("\t-w, --write <v>: write register specified by last -n argument with value <v>\n");
|
printf("\t-w, --write <v>: write register specified by last -n argument with value <v>\n");
|
||||||
|
printf("\t-d, --device <s>: specify a particular device by serial number\n");
|
||||||
printf("\nExamples:\n");
|
printf("\nExamples:\n");
|
||||||
printf("\t<command> -n 12 -r # reads from register 12\n");
|
printf("\t<command> -n 12 -r # reads from register 12\n");
|
||||||
printf("\t<command> -r # reads all registers\n");
|
printf("\t<command> -r # reads all registers\n");
|
||||||
@ -48,6 +49,7 @@ static struct option long_options[] = {
|
|||||||
{ "register", required_argument, 0, 'n' },
|
{ "register", required_argument, 0, 'n' },
|
||||||
{ "write", required_argument, 0, 'w' },
|
{ "write", required_argument, 0, 'w' },
|
||||||
{ "read", no_argument, 0, 'r' },
|
{ "read", no_argument, 0, 'r' },
|
||||||
|
{ "device", no_argument, 0, 'd' },
|
||||||
{ "help", no_argument, 0, 'h' },
|
{ "help", no_argument, 0, 'h' },
|
||||||
{ 0, 0, 0, 0 },
|
{ 0, 0, 0, 0 },
|
||||||
};
|
};
|
||||||
@ -133,6 +135,7 @@ int main(int argc, char** argv) {
|
|||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
bool read = false;
|
bool read = false;
|
||||||
bool write = false;
|
bool write = false;
|
||||||
|
const char* serial_number = NULL;
|
||||||
|
|
||||||
int result = hackrf_init();
|
int result = hackrf_init();
|
||||||
if( result ) {
|
if( result ) {
|
||||||
@ -140,7 +143,7 @@ int main(int argc, char** argv) {
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
while( (opt = getopt_long(argc, argv, "n:rw:h?", long_options, &option_index)) != EOF ) {
|
while( (opt = getopt_long(argc, argv, "n:rw:d:h?", long_options, &option_index)) != EOF ) {
|
||||||
switch( opt ) {
|
switch( opt ) {
|
||||||
case 'n':
|
case 'n':
|
||||||
result = parse_int(optarg, ®ister_number);
|
result = parse_int(optarg, ®ister_number);
|
||||||
@ -155,6 +158,10 @@ int main(int argc, char** argv) {
|
|||||||
read = true;
|
read = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'd':
|
||||||
|
serial_number = optarg;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'h':
|
case 'h':
|
||||||
case '?':
|
case '?':
|
||||||
usage();
|
usage();
|
||||||
@ -184,7 +191,7 @@ int main(int argc, char** argv) {
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = hackrf_open(&device);
|
result = hackrf_open_by_serial(serial_number, &device);
|
||||||
if(result) {
|
if(result) {
|
||||||
printf("hackrf_open() failed: %s (%d)\n", hackrf_error_name(result), result);
|
printf("hackrf_open() failed: %s (%d)\n", hackrf_error_name(result), result);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@ -34,8 +34,7 @@ typedef int bool;
|
|||||||
static void usage() {
|
static void usage() {
|
||||||
printf("\nUsage:\n");
|
printf("\nUsage:\n");
|
||||||
printf("\t-h, --help: this help\n");
|
printf("\t-h, --help: this help\n");
|
||||||
printf("\t-s, --serial <s>: specify a particular device by serial number\n");
|
printf("\t-d, --device <n>: specify a particular device by serial number\n");
|
||||||
printf("\t-d, --device <n>: specify a particular device by number\n");
|
|
||||||
printf("\t-o, --address <n>: specify a particular operacake by address [default: 0x00]\n");
|
printf("\t-o, --address <n>: specify a particular operacake by address [default: 0x00]\n");
|
||||||
printf("\t-a <n>: set port A connection\n");
|
printf("\t-a <n>: set port A connection\n");
|
||||||
printf("\t-b <n>: set port B connection\n");
|
printf("\t-b <n>: set port B connection\n");
|
||||||
@ -44,7 +43,6 @@ static void usage() {
|
|||||||
|
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
{ "device", no_argument, 0, 'd' },
|
{ "device", no_argument, 0, 'd' },
|
||||||
{ "serial", no_argument, 0, 's' },
|
|
||||||
{ "address", no_argument, 0, 'o' },
|
{ "address", no_argument, 0, 'o' },
|
||||||
{ "list", no_argument, 0, 'v' },
|
{ "list", no_argument, 0, 'v' },
|
||||||
{ "help", no_argument, 0, 'h' },
|
{ "help", no_argument, 0, 'h' },
|
||||||
@ -65,7 +63,6 @@ int parse_int(char* const s, uint16_t* const value) {
|
|||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
int opt;
|
int opt;
|
||||||
const char* serial_number = NULL;
|
const char* serial_number = NULL;
|
||||||
int device_index = 0;
|
|
||||||
int operacake_address = 0;
|
int operacake_address = 0;
|
||||||
int port_a = 0;
|
int port_a = 0;
|
||||||
int port_b = 0;
|
int port_b = 0;
|
||||||
@ -83,13 +80,9 @@ int main(int argc, char** argv) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while( (opt = getopt_long(argc, argv, "d:s:o:a:b:lh?", long_options, &option_index)) != EOF ) {
|
while( (opt = getopt_long(argc, argv, "d:o:a:b:lh?", long_options, &option_index)) != EOF ) {
|
||||||
switch( opt ) {
|
switch( opt ) {
|
||||||
case 'd':
|
case 'd':
|
||||||
device_index = atoi(optarg);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 's':
|
|
||||||
serial_number = optarg;
|
serial_number = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -132,20 +125,11 @@ int main(int argc, char** argv) {
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(serial_number != NULL) {
|
result = hackrf_open_by_serial(serial_number, &device);
|
||||||
result = hackrf_open_by_serial(serial_number, &device);
|
if (result != HACKRF_SUCCESS) {
|
||||||
} else {
|
fprintf(stderr, "hackrf_open() failed: %s (%d)\n",
|
||||||
hackrf_device_list_t* device_list = hackrf_device_list();
|
hackrf_error_name(result), result);
|
||||||
if(device_list->devicecount <= 0) {
|
return EXIT_FAILURE;
|
||||||
result = HACKRF_ERROR_NOT_FOUND;
|
|
||||||
} else {
|
|
||||||
result = hackrf_device_list_open(device_list, device_index, &device);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( result ) {
|
|
||||||
printf("hackrf_open() failed: %s (%d)\n", hackrf_error_name(result), result);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(list) {
|
if(list) {
|
||||||
|
@ -39,6 +39,7 @@ static void usage() {
|
|||||||
printf("\t-n, --register <n>: set register number for read/write operations\n");
|
printf("\t-n, --register <n>: set register number for read/write operations\n");
|
||||||
printf("\t-r, --read: read register specified by last -n argument, or all registers\n");
|
printf("\t-r, --read: read register specified by last -n argument, or all registers\n");
|
||||||
printf("\t-w, --write <v>: write register specified by last -n argument with value <v>\n");
|
printf("\t-w, --write <v>: write register specified by last -n argument with value <v>\n");
|
||||||
|
printf("\t-d, --device <s>: specify a particular device by serial number\n");
|
||||||
printf("\nExamples:\n");
|
printf("\nExamples:\n");
|
||||||
printf("\t<command> -n 12 -r # reads from register 12\n");
|
printf("\t<command> -n 12 -r # reads from register 12\n");
|
||||||
printf("\t<command> -r # reads all registers\n");
|
printf("\t<command> -r # reads all registers\n");
|
||||||
@ -49,6 +50,7 @@ static struct option long_options[] = {
|
|||||||
{ "register", required_argument, 0, 'n' },
|
{ "register", required_argument, 0, 'n' },
|
||||||
{ "write", required_argument, 0, 'w' },
|
{ "write", required_argument, 0, 'w' },
|
||||||
{ "read", no_argument, 0, 'r' },
|
{ "read", no_argument, 0, 'r' },
|
||||||
|
{ "device", no_argument, 0, 'd' },
|
||||||
{ "help", no_argument, 0, 'h' },
|
{ "help", no_argument, 0, 'h' },
|
||||||
{ 0, 0, 0, 0 },
|
{ 0, 0, 0, 0 },
|
||||||
};
|
};
|
||||||
@ -134,6 +136,7 @@ int main(int argc, char** argv) {
|
|||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
bool read = false;
|
bool read = false;
|
||||||
bool write = false;
|
bool write = false;
|
||||||
|
const char* serial_number = NULL;
|
||||||
|
|
||||||
int result = hackrf_init();
|
int result = hackrf_init();
|
||||||
if( result ) {
|
if( result ) {
|
||||||
@ -141,7 +144,7 @@ int main(int argc, char** argv) {
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
while( (opt = getopt_long(argc, argv, "n:rw:h?", long_options, &option_index)) != EOF ) {
|
while( (opt = getopt_long(argc, argv, "n:rw:d:h?", long_options, &option_index)) != EOF ) {
|
||||||
switch( opt ) {
|
switch( opt ) {
|
||||||
case 'n':
|
case 'n':
|
||||||
result = parse_int(optarg, ®ister_number);
|
result = parse_int(optarg, ®ister_number);
|
||||||
@ -153,6 +156,9 @@ int main(int argc, char** argv) {
|
|||||||
case 'r':
|
case 'r':
|
||||||
read = true;
|
read = true;
|
||||||
break;
|
break;
|
||||||
|
case 'd':
|
||||||
|
serial_number = optarg;
|
||||||
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
case '?':
|
case '?':
|
||||||
usage();
|
usage();
|
||||||
@ -182,7 +188,7 @@ int main(int argc, char** argv) {
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = hackrf_open(&device);
|
result = hackrf_open_by_serial(serial_number, &device);
|
||||||
if(result) {
|
if(result) {
|
||||||
printf("hackrf_open() failed: %s (%d)\n", hackrf_error_name(result), result);
|
printf("hackrf_open() failed: %s (%d)\n", hackrf_error_name(result), result);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@ -38,8 +38,8 @@ static void usage() {
|
|||||||
printf("\t-n, --register <n>: set register number for read/write operations\n");
|
printf("\t-n, --register <n>: set register number for read/write operations\n");
|
||||||
printf("\t-r, --read: read register specified by last -n argument, or all registers\n");
|
printf("\t-r, --read: read register specified by last -n argument, or all registers\n");
|
||||||
printf("\t-w, --write <v>: write register specified by last -n argument with value <v>\n");
|
printf("\t-w, --write <v>: write register specified by last -n argument with value <v>\n");
|
||||||
printf("\t-s, --serial <s>: specify a particular device by serial number\n");
|
printf("\t-d, --device <s>: specify a particular device by serial number\n");
|
||||||
printf("\t-d, --device <n>: specify a particular device by number\n");
|
printf("\t-D, --device-idx <n>: specify a particular device by number\n");
|
||||||
printf("\nExamples:\n");
|
printf("\nExamples:\n");
|
||||||
printf("\t<command> -n 12 -r # reads from register 12\n");
|
printf("\t<command> -n 12 -r # reads from register 12\n");
|
||||||
printf("\t<command> -r # reads all registers\n");
|
printf("\t<command> -r # reads all registers\n");
|
||||||
@ -52,7 +52,7 @@ static struct option long_options[] = {
|
|||||||
{ "write", required_argument, 0, 'w' },
|
{ "write", required_argument, 0, 'w' },
|
||||||
{ "read", no_argument, 0, 'r' },
|
{ "read", no_argument, 0, 'r' },
|
||||||
{ "device", no_argument, 0, 'd' },
|
{ "device", no_argument, 0, 'd' },
|
||||||
{ "serial", no_argument, 0, 's' },
|
{ "device-idx", no_argument, 0, 'D' },
|
||||||
{ "help", no_argument, 0, 'h' },
|
{ "help", no_argument, 0, 'h' },
|
||||||
{ 0, 0, 0, 0 },
|
{ 0, 0, 0, 0 },
|
||||||
};
|
};
|
||||||
@ -214,7 +214,7 @@ int main(int argc, char** argv) {
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
while( (opt = getopt_long(argc, argv, "d:s:cn:rw:h?", long_options, &option_index)) != EOF ) {
|
while( (opt = getopt_long(argc, argv, "d:D:cn:rw:h?", long_options, &option_index)) != EOF ) {
|
||||||
switch( opt ) {
|
switch( opt ) {
|
||||||
case 'n':
|
case 'n':
|
||||||
result = parse_int(optarg, ®ister_number);
|
result = parse_int(optarg, ®ister_number);
|
||||||
@ -233,11 +233,11 @@ int main(int argc, char** argv) {
|
|||||||
dump_config = true;
|
dump_config = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'd':
|
case 'D':
|
||||||
device_index = atoi(optarg);
|
device_index = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 'd':
|
||||||
serial_number = optarg;
|
serial_number = optarg;
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
|
@ -24,10 +24,12 @@
|
|||||||
cmake_minimum_required(VERSION 2.8)
|
cmake_minimum_required(VERSION 2.8)
|
||||||
project(libhackrf C)
|
project(libhackrf C)
|
||||||
set(MAJOR_VERSION 0)
|
set(MAJOR_VERSION 0)
|
||||||
set(MINOR_VERSION 4)
|
set(MINOR_VERSION 5)
|
||||||
set(PACKAGE libhackrf)
|
set(PACKAGE libhackrf)
|
||||||
set(VERSION_STRING ${MAJOR_VERSION}.${MINOR_VERSION})
|
set(VERSION_STRING ${MAJOR_VERSION}.${MINOR_VERSION})
|
||||||
set(VERSION ${VERSION_STRING})
|
set(VERSION ${VERSION_STRING})
|
||||||
|
add_definitions(-DLIBRARY_VERSION="${VERSION_STRING}")
|
||||||
|
add_definitions(-DLIBRARY_RELEASE="${RELEASE}")
|
||||||
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../cmake/modules)
|
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../cmake/modules)
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
|
@ -145,6 +145,7 @@ static const uint16_t hackrf_one_usb_pid = 0x6089;
|
|||||||
static const uint16_t rad1o_usb_pid = 0xcc15;
|
static const uint16_t rad1o_usb_pid = 0xcc15;
|
||||||
|
|
||||||
static libusb_context* g_libusb_context = NULL;
|
static libusb_context* g_libusb_context = NULL;
|
||||||
|
int last_libusb_error = LIBUSB_SUCCESS;
|
||||||
|
|
||||||
static void request_exit(void)
|
static void request_exit(void)
|
||||||
{
|
{
|
||||||
@ -249,6 +250,7 @@ static int prepare_transfers(
|
|||||||
error = libusb_submit_transfer(device->transfers[transfer_index]);
|
error = libusb_submit_transfer(device->transfers[transfer_index]);
|
||||||
if( error != 0 )
|
if( error != 0 )
|
||||||
{
|
{
|
||||||
|
last_libusb_error = error;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -269,6 +271,7 @@ static int detach_kernel_drivers(libusb_device_handle* usb_device_handle)
|
|||||||
result = libusb_get_active_config_descriptor(dev, &config);
|
result = libusb_get_active_config_descriptor(dev, &config);
|
||||||
if( result < 0 )
|
if( result < 0 )
|
||||||
{
|
{
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,11 +285,13 @@ static int detach_kernel_drivers(libusb_device_handle* usb_device_handle)
|
|||||||
if( result == LIBUSB_ERROR_NOT_SUPPORTED ) {
|
if( result == LIBUSB_ERROR_NOT_SUPPORTED ) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
} else if( result == 1 ) {
|
} else if( result == 1 ) {
|
||||||
result = libusb_detach_kernel_driver(usb_device_handle, i);
|
result = libusb_detach_kernel_driver(usb_device_handle, i);
|
||||||
if( result != 0 )
|
if( result != 0 )
|
||||||
{
|
{
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -300,6 +305,7 @@ static int set_hackrf_configuration(libusb_device_handle* usb_device, int config
|
|||||||
result = libusb_get_configuration(usb_device, &curr_config);
|
result = libusb_get_configuration(usb_device, &curr_config);
|
||||||
if( result != 0 )
|
if( result != 0 )
|
||||||
{
|
{
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,6 +319,7 @@ static int set_hackrf_configuration(libusb_device_handle* usb_device, int config
|
|||||||
result = libusb_set_configuration(usb_device, config);
|
result = libusb_set_configuration(usb_device, config);
|
||||||
if( result != 0 )
|
if( result != 0 )
|
||||||
{
|
{
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -340,6 +347,7 @@ int ADDCALL hackrf_init(void)
|
|||||||
libusb_error = libusb_init(&g_libusb_context);
|
libusb_error = libusb_init(&g_libusb_context);
|
||||||
if( libusb_error != 0 )
|
if( libusb_error != 0 )
|
||||||
{
|
{
|
||||||
|
last_libusb_error = libusb_error;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
} else {
|
} else {
|
||||||
return HACKRF_SUCCESS;
|
return HACKRF_SUCCESS;
|
||||||
@ -357,6 +365,22 @@ int ADDCALL hackrf_exit(void)
|
|||||||
return HACKRF_SUCCESS;
|
return HACKRF_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef LIBRARY_VERSION
|
||||||
|
#define LIBRARY_VERSION "unknown"
|
||||||
|
#endif
|
||||||
|
const char* ADDCALL hackrf_library_version()
|
||||||
|
{
|
||||||
|
return LIBRARY_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef LIBRARY_RELEASE
|
||||||
|
#define LIBRARY_RELEASE "unknown"
|
||||||
|
#endif
|
||||||
|
const char* ADDCALL hackrf_library_release()
|
||||||
|
{
|
||||||
|
return LIBRARY_RELEASE;
|
||||||
|
}
|
||||||
|
|
||||||
hackrf_device_list_t* ADDCALL hackrf_device_list()
|
hackrf_device_list_t* ADDCALL hackrf_device_list()
|
||||||
{
|
{
|
||||||
ssize_t i;
|
ssize_t i;
|
||||||
@ -511,6 +535,7 @@ static int hackrf_open_setup(libusb_device_handle* usb_device, hackrf_device** d
|
|||||||
result = libusb_claim_interface(usb_device, 0);
|
result = libusb_claim_interface(usb_device, 0);
|
||||||
if( result != LIBUSB_SUCCESS )
|
if( result != LIBUSB_SUCCESS )
|
||||||
{
|
{
|
||||||
|
last_libusb_error = result;
|
||||||
libusb_close(usb_device);
|
libusb_close(usb_device);
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
}
|
}
|
||||||
@ -601,7 +626,7 @@ int ADDCALL hackrf_open_by_serial(const char* const desired_serial_number, hackr
|
|||||||
int ADDCALL hackrf_device_list_open(hackrf_device_list_t *list, int idx, hackrf_device** device)
|
int ADDCALL hackrf_device_list_open(hackrf_device_list_t *list, int idx, hackrf_device** device)
|
||||||
{
|
{
|
||||||
libusb_device_handle* usb_device;
|
libusb_device_handle* usb_device;
|
||||||
int i;
|
int i, result;
|
||||||
|
|
||||||
if( device == NULL || list == NULL || idx < 0 || idx >= list->devicecount )
|
if( device == NULL || list == NULL || idx < 0 || idx >= list->devicecount )
|
||||||
{
|
{
|
||||||
@ -610,8 +635,10 @@ int ADDCALL hackrf_device_list_open(hackrf_device_list_t *list, int idx, hackrf_
|
|||||||
|
|
||||||
i = list->usb_device_index[idx];
|
i = list->usb_device_index[idx];
|
||||||
|
|
||||||
if( libusb_open(list->usb_devices[i], &usb_device) != 0 ) {
|
result = libusb_open(list->usb_devices[i], &usb_device);
|
||||||
|
if(result != 0) {
|
||||||
usb_device = NULL;
|
usb_device = NULL;
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -634,6 +661,7 @@ int ADDCALL hackrf_set_transceiver_mode(hackrf_device* device, hackrf_transceive
|
|||||||
|
|
||||||
if( result != 0 )
|
if( result != 0 )
|
||||||
{
|
{
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
} else {
|
} else {
|
||||||
return HACKRF_SUCCESS;
|
return HACKRF_SUCCESS;
|
||||||
@ -662,6 +690,7 @@ int ADDCALL hackrf_max2837_read(hackrf_device* device, uint8_t register_number,
|
|||||||
|
|
||||||
if( result < 2 )
|
if( result < 2 )
|
||||||
{
|
{
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
} else {
|
} else {
|
||||||
return HACKRF_SUCCESS;
|
return HACKRF_SUCCESS;
|
||||||
@ -694,6 +723,7 @@ int ADDCALL hackrf_max2837_write(hackrf_device* device, uint8_t register_number,
|
|||||||
|
|
||||||
if( result != 0 )
|
if( result != 0 )
|
||||||
{
|
{
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
} else {
|
} else {
|
||||||
return HACKRF_SUCCESS;
|
return HACKRF_SUCCESS;
|
||||||
@ -724,6 +754,7 @@ int ADDCALL hackrf_si5351c_read(hackrf_device* device, uint16_t register_number,
|
|||||||
|
|
||||||
if( result < 1 )
|
if( result < 1 )
|
||||||
{
|
{
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
} else {
|
} else {
|
||||||
*value = temp_value;
|
*value = temp_value;
|
||||||
@ -756,6 +787,7 @@ int ADDCALL hackrf_si5351c_write(hackrf_device* device, uint16_t register_number
|
|||||||
|
|
||||||
if( result != 0 )
|
if( result != 0 )
|
||||||
{
|
{
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
} else {
|
} else {
|
||||||
return HACKRF_SUCCESS;
|
return HACKRF_SUCCESS;
|
||||||
@ -778,6 +810,7 @@ int ADDCALL hackrf_set_baseband_filter_bandwidth(hackrf_device* device, const ui
|
|||||||
|
|
||||||
if( result != 0 )
|
if( result != 0 )
|
||||||
{
|
{
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
} else {
|
} else {
|
||||||
return HACKRF_SUCCESS;
|
return HACKRF_SUCCESS;
|
||||||
@ -807,6 +840,7 @@ int ADDCALL hackrf_rffc5071_read(hackrf_device* device, uint8_t register_number,
|
|||||||
|
|
||||||
if( result < 2 )
|
if( result < 2 )
|
||||||
{
|
{
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
} else {
|
} else {
|
||||||
return HACKRF_SUCCESS;
|
return HACKRF_SUCCESS;
|
||||||
@ -835,6 +869,7 @@ int ADDCALL hackrf_rffc5071_write(hackrf_device* device, uint8_t register_number
|
|||||||
|
|
||||||
if( result != 0 )
|
if( result != 0 )
|
||||||
{
|
{
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
} else {
|
} else {
|
||||||
return HACKRF_SUCCESS;
|
return HACKRF_SUCCESS;
|
||||||
@ -857,6 +892,7 @@ int ADDCALL hackrf_spiflash_erase(hackrf_device* device)
|
|||||||
|
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
} else {
|
} else {
|
||||||
return HACKRF_SUCCESS;
|
return HACKRF_SUCCESS;
|
||||||
@ -886,6 +922,7 @@ int ADDCALL hackrf_spiflash_write(hackrf_device* device, const uint32_t address,
|
|||||||
|
|
||||||
if (result < length)
|
if (result < length)
|
||||||
{
|
{
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
} else {
|
} else {
|
||||||
return HACKRF_SUCCESS;
|
return HACKRF_SUCCESS;
|
||||||
@ -915,6 +952,7 @@ int ADDCALL hackrf_spiflash_read(hackrf_device* device, const uint32_t address,
|
|||||||
|
|
||||||
if (result < length)
|
if (result < length)
|
||||||
{
|
{
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
} else {
|
} else {
|
||||||
return HACKRF_SUCCESS;
|
return HACKRF_SUCCESS;
|
||||||
@ -944,6 +982,7 @@ int ADDCALL hackrf_cpld_write(hackrf_device* device,
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (result != LIBUSB_SUCCESS) {
|
if (result != LIBUSB_SUCCESS) {
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -967,6 +1006,7 @@ int ADDCALL hackrf_board_id_read(hackrf_device* device, uint8_t* value)
|
|||||||
|
|
||||||
if (result < 1)
|
if (result < 1)
|
||||||
{
|
{
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
} else {
|
} else {
|
||||||
return HACKRF_SUCCESS;
|
return HACKRF_SUCCESS;
|
||||||
@ -990,6 +1030,7 @@ int ADDCALL hackrf_version_string_read(hackrf_device* device, char* version,
|
|||||||
|
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
{
|
{
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
} else {
|
} else {
|
||||||
version[result] = '\0';
|
version[result] = '\0';
|
||||||
@ -1005,8 +1046,10 @@ extern ADDAPI int ADDCALL hackrf_usb_api_version_read(hackrf_device* device,
|
|||||||
struct libusb_device_descriptor desc;
|
struct libusb_device_descriptor desc;
|
||||||
dev = libusb_get_device(device->usb_device);
|
dev = libusb_get_device(device->usb_device);
|
||||||
result = libusb_get_device_descriptor(dev, &desc);
|
result = libusb_get_device_descriptor(dev, &desc);
|
||||||
if (result < 0)
|
if (result < 0) {
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
|
}
|
||||||
|
|
||||||
*version = desc.bcdDevice;
|
*version = desc.bcdDevice;
|
||||||
return HACKRF_SUCCESS;
|
return HACKRF_SUCCESS;
|
||||||
@ -1053,6 +1096,7 @@ int ADDCALL hackrf_set_freq(hackrf_device* device, const uint64_t freq_hz)
|
|||||||
|
|
||||||
if (result < length)
|
if (result < length)
|
||||||
{
|
{
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
} else {
|
} else {
|
||||||
return HACKRF_SUCCESS;
|
return HACKRF_SUCCESS;
|
||||||
@ -1104,6 +1148,7 @@ int ADDCALL hackrf_set_freq_explicit(hackrf_device* device,
|
|||||||
|
|
||||||
if (result < length)
|
if (result < length)
|
||||||
{
|
{
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
} else {
|
} else {
|
||||||
return HACKRF_SUCCESS;
|
return HACKRF_SUCCESS;
|
||||||
@ -1145,6 +1190,7 @@ int ADDCALL hackrf_set_sample_rate_manual(hackrf_device* device,
|
|||||||
|
|
||||||
if (result < length)
|
if (result < length)
|
||||||
{
|
{
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
} else {
|
} else {
|
||||||
return hackrf_set_baseband_filter_bandwidth(device,
|
return hackrf_set_baseband_filter_bandwidth(device,
|
||||||
@ -1214,6 +1260,7 @@ int ADDCALL hackrf_set_amp_enable(hackrf_device* device, const uint8_t value)
|
|||||||
|
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
} else {
|
} else {
|
||||||
return HACKRF_SUCCESS;
|
return HACKRF_SUCCESS;
|
||||||
@ -1239,6 +1286,7 @@ int ADDCALL hackrf_board_partid_serialno_read(hackrf_device* device, read_partid
|
|||||||
|
|
||||||
if (result < length)
|
if (result < length)
|
||||||
{
|
{
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@ -1358,6 +1406,7 @@ int ADDCALL hackrf_set_antenna_enable(hackrf_device* device, const uint8_t value
|
|||||||
|
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
} else {
|
} else {
|
||||||
return HACKRF_SUCCESS;
|
return HACKRF_SUCCESS;
|
||||||
@ -1606,6 +1655,10 @@ const char* ADDCALL hackrf_error_name(enum hackrf_error errcode)
|
|||||||
return "insufficient memory";
|
return "insufficient memory";
|
||||||
|
|
||||||
case HACKRF_ERROR_LIBUSB:
|
case HACKRF_ERROR_LIBUSB:
|
||||||
|
#if defined(LIBUSB_API_VERSION) && (LIBUSB_API_VERSION >= 0x01000103)
|
||||||
|
if(last_libusb_error != LIBUSB_SUCCESS)
|
||||||
|
return libusb_strerror(last_libusb_error);
|
||||||
|
#endif
|
||||||
return "USB error";
|
return "USB error";
|
||||||
|
|
||||||
case HACKRF_ERROR_THREAD:
|
case HACKRF_ERROR_THREAD:
|
||||||
@ -1750,6 +1803,7 @@ int ADDCALL hackrf_set_hw_sync_mode(hackrf_device* device, const uint8_t value)
|
|||||||
|
|
||||||
if( result != 0 )
|
if( result != 0 )
|
||||||
{
|
{
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
} else {
|
} else {
|
||||||
return HACKRF_SUCCESS;
|
return HACKRF_SUCCESS;
|
||||||
@ -1778,6 +1832,7 @@ int ADDCALL hackrf_init_sweep(hackrf_device* device, uint16_t* frequency_list, i
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (result < size) {
|
if (result < size) {
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
} else {
|
} else {
|
||||||
return HACKRF_SUCCESS;
|
return HACKRF_SUCCESS;
|
||||||
@ -1804,6 +1859,7 @@ int ADDCALL hackrf_get_operacake_boards(hackrf_device* device, uint8_t* boards)
|
|||||||
|
|
||||||
if (result < 8)
|
if (result < 8)
|
||||||
{
|
{
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
} else {
|
} else {
|
||||||
return HACKRF_SUCCESS;
|
return HACKRF_SUCCESS;
|
||||||
@ -1839,6 +1895,7 @@ int ADDCALL hackrf_set_operacake_ports(hackrf_device* device,
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
} else {
|
} else {
|
||||||
return HACKRF_SUCCESS;
|
return HACKRF_SUCCESS;
|
||||||
@ -1859,6 +1916,7 @@ int ADDCALL hackrf_reset(hackrf_device* device) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if( result != 0 ) {
|
if( result != 0 ) {
|
||||||
|
last_libusb_error = result;
|
||||||
return HACKRF_ERROR_LIBUSB;
|
return HACKRF_ERROR_LIBUSB;
|
||||||
} else {
|
} else {
|
||||||
return HACKRF_SUCCESS;
|
return HACKRF_SUCCESS;
|
||||||
|
@ -133,6 +133,9 @@ extern "C"
|
|||||||
extern ADDAPI int ADDCALL hackrf_init();
|
extern ADDAPI int ADDCALL hackrf_init();
|
||||||
extern ADDAPI int ADDCALL hackrf_exit();
|
extern ADDAPI int ADDCALL hackrf_exit();
|
||||||
|
|
||||||
|
extern ADDAPI const char* ADDCALL hackrf_library_version();
|
||||||
|
extern ADDAPI const char* ADDCALL hackrf_library_release();
|
||||||
|
|
||||||
extern ADDAPI hackrf_device_list_t* ADDCALL hackrf_device_list();
|
extern ADDAPI hackrf_device_list_t* ADDCALL hackrf_device_list();
|
||||||
extern ADDAPI int ADDCALL hackrf_device_list_open(hackrf_device_list_t *list, int idx, hackrf_device** device);
|
extern ADDAPI int ADDCALL hackrf_device_list_open(hackrf_device_list_t *list, int idx, hackrf_device** device);
|
||||||
extern ADDAPI void ADDCALL hackrf_device_list_free(hackrf_device_list_t *list);
|
extern ADDAPI void ADDCALL hackrf_device_list_free(hackrf_device_list_t *list);
|
||||||
|
Reference in New Issue
Block a user