mirror of
https://github.com/greatscottgadgets/hackrf.git
synced 2026-03-08 08:18:11 +01:00
Merge branch 'master' of https://github.com/mossmann/hackrf
This commit is contained in:
@@ -80,6 +80,7 @@ static void usage()
|
||||
{
|
||||
printf("Usage:\n");
|
||||
printf("\t-x <filename>: XSVF file to be written to CPLD.\n");
|
||||
printf("\t-d <serialnumber>: Serial number of device, if multiple devices\n");
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
@@ -88,6 +89,7 @@ int main(int argc, char** argv)
|
||||
uint32_t length = 0;
|
||||
uint32_t total_length = 0;
|
||||
const char* path = NULL;
|
||||
const char* serial_number = NULL;
|
||||
hackrf_device* device = NULL;
|
||||
int result = HACKRF_SUCCESS;
|
||||
int option_index = 0;
|
||||
@@ -95,13 +97,17 @@ int main(int argc, char** argv)
|
||||
ssize_t bytes_read;
|
||||
uint8_t* pdata = &data[0];
|
||||
|
||||
while ((opt = getopt_long(argc, argv, "x:", long_options,
|
||||
while ((opt = getopt_long(argc, argv, "x:d:", long_options,
|
||||
&option_index)) != EOF) {
|
||||
switch (opt) {
|
||||
case 'x':
|
||||
path = optarg;
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
serial_number = optarg;
|
||||
break;
|
||||
|
||||
default:
|
||||
usage();
|
||||
return EXIT_FAILURE;
|
||||
@@ -158,7 +164,7 @@ int main(int argc, char** argv)
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
result = hackrf_open(&device);
|
||||
result = hackrf_open_by_serial(serial_number, &device);
|
||||
if (result != HACKRF_SUCCESS) {
|
||||
fprintf(stderr, "hackrf_open() failed: %s (%d)\n",
|
||||
hackrf_error_name(result), result);
|
||||
|
||||
@@ -28,11 +28,12 @@
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
hackrf_device* device = NULL;
|
||||
int result = HACKRF_SUCCESS;
|
||||
uint8_t board_id = BOARD_ID_INVALID;
|
||||
char version[255 + 1];
|
||||
read_partid_serialno_t read_partid_serialno;
|
||||
hackrf_device_list_t *list;
|
||||
int i;
|
||||
|
||||
result = hackrf_init();
|
||||
if (result != HACKRF_SUCCESS) {
|
||||
@@ -40,55 +41,71 @@ int main(int argc, char** argv)
|
||||
hackrf_error_name(result), result);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
result = hackrf_open(&device);
|
||||
if (result != HACKRF_SUCCESS) {
|
||||
fprintf(stderr, "hackrf_open() failed: %s (%d)\n",
|
||||
hackrf_error_name(result), result);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
printf("Found HackRF board.\n");
|
||||
|
||||
result = hackrf_board_id_read(device, &board_id);
|
||||
if (result != HACKRF_SUCCESS) {
|
||||
fprintf(stderr, "hackrf_board_id_read() failed: %s (%d)\n",
|
||||
hackrf_error_name(result), result);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("Board ID Number: %d (%s)\n", board_id,
|
||||
hackrf_board_id_name(board_id));
|
||||
|
||||
result = hackrf_version_string_read(device, &version[0], 255);
|
||||
if (result != HACKRF_SUCCESS) {
|
||||
fprintf(stderr, "hackrf_version_string_read() failed: %s (%d)\n",
|
||||
hackrf_error_name(result), result);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("Firmware Version: %s\n", version);
|
||||
|
||||
result = hackrf_board_partid_serialno_read(device, &read_partid_serialno);
|
||||
if (result != HACKRF_SUCCESS) {
|
||||
fprintf(stderr, "hackrf_board_partid_serialno_read() failed: %s (%d)\n",
|
||||
hackrf_error_name(result), result);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("Part ID Number: 0x%08x 0x%08x\n",
|
||||
read_partid_serialno.part_id[0],
|
||||
read_partid_serialno.part_id[1]);
|
||||
printf("Serial Number: 0x%08x 0x%08x 0x%08x 0x%08x\n",
|
||||
read_partid_serialno.serial_no[0],
|
||||
read_partid_serialno.serial_no[1],
|
||||
read_partid_serialno.serial_no[2],
|
||||
read_partid_serialno.serial_no[3]);
|
||||
|
||||
result = hackrf_close(device);
|
||||
if (result != HACKRF_SUCCESS) {
|
||||
fprintf(stderr, "hackrf_close() failed: %s (%d)\n",
|
||||
hackrf_error_name(result), result);
|
||||
list = hackrf_device_list();
|
||||
|
||||
if (list->devicecount < 1 ) {
|
||||
printf("No HackRF boards found.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
for (i = 0; i < list->devicecount; i++) {
|
||||
if (i > 0)
|
||||
printf("\n");
|
||||
|
||||
printf("Found HackRF board %d:\n", i);
|
||||
|
||||
if (list->serial_numbers[i])
|
||||
printf("USB descriptor string: %s\n", list->serial_numbers[i]);
|
||||
|
||||
hackrf_device* device = NULL;
|
||||
result = hackrf_device_list_open(list, i, &device);
|
||||
if (result != HACKRF_SUCCESS) {
|
||||
fprintf(stderr, "hackrf_open() failed: %s (%d)\n",
|
||||
hackrf_error_name(result), result);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
result = hackrf_board_id_read(device, &board_id);
|
||||
if (result != HACKRF_SUCCESS) {
|
||||
fprintf(stderr, "hackrf_board_id_read() failed: %s (%d)\n",
|
||||
hackrf_error_name(result), result);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("Board ID Number: %d (%s)\n", board_id,
|
||||
hackrf_board_id_name(board_id));
|
||||
|
||||
result = hackrf_version_string_read(device, &version[0], 255);
|
||||
if (result != HACKRF_SUCCESS) {
|
||||
fprintf(stderr, "hackrf_version_string_read() failed: %s (%d)\n",
|
||||
hackrf_error_name(result), result);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("Firmware Version: %s\n", version);
|
||||
|
||||
result = hackrf_board_partid_serialno_read(device, &read_partid_serialno);
|
||||
if (result != HACKRF_SUCCESS) {
|
||||
fprintf(stderr, "hackrf_board_partid_serialno_read() failed: %s (%d)\n",
|
||||
hackrf_error_name(result), result);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("Part ID Number: 0x%08x 0x%08x\n",
|
||||
read_partid_serialno.part_id[0],
|
||||
read_partid_serialno.part_id[1]);
|
||||
printf("Serial Number: 0x%08x 0x%08x 0x%08x 0x%08x\n",
|
||||
read_partid_serialno.serial_no[0],
|
||||
read_partid_serialno.serial_no[1],
|
||||
read_partid_serialno.serial_no[2],
|
||||
read_partid_serialno.serial_no[3]);
|
||||
|
||||
result = hackrf_close(device);
|
||||
if (result != HACKRF_SUCCESS) {
|
||||
fprintf(stderr, "hackrf_close() failed: %s (%d)\n",
|
||||
hackrf_error_name(result), result);
|
||||
}
|
||||
}
|
||||
|
||||
hackrf_device_list_free(list);
|
||||
hackrf_exit();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
@@ -89,6 +89,7 @@ static void usage()
|
||||
printf("\t-l, --length <n>: number of bytes to read (default: 0)\n");
|
||||
printf("\t-r <filename>: Read data into file.\n");
|
||||
printf("\t-w <filename>: Write data from file.\n");
|
||||
printf("\t-d <serialnumber>: Serial number of device, if multiple devices\n");
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
@@ -99,6 +100,7 @@ int main(int argc, char** argv)
|
||||
uint32_t tmp_length;
|
||||
uint16_t xfer_len = 0;
|
||||
const char* path = NULL;
|
||||
const char* serial_number = NULL;
|
||||
hackrf_device* device = NULL;
|
||||
int result = HACKRF_SUCCESS;
|
||||
int option_index = 0;
|
||||
@@ -108,7 +110,7 @@ int main(int argc, char** argv)
|
||||
bool read = false;
|
||||
bool write = false;
|
||||
|
||||
while ((opt = getopt_long(argc, argv, "a:l:r:w:", long_options,
|
||||
while ((opt = getopt_long(argc, argv, "a:l:r:w:d:", long_options,
|
||||
&option_index)) != EOF) {
|
||||
switch (opt) {
|
||||
case 'a':
|
||||
@@ -128,6 +130,10 @@ int main(int argc, char** argv)
|
||||
write = true;
|
||||
path = optarg;
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
serial_number = optarg;
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "opt error: %d\n", opt);
|
||||
@@ -213,7 +219,7 @@ int main(int argc, char** argv)
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
result = hackrf_open(&device);
|
||||
result = hackrf_open_by_serial(serial_number, &device);
|
||||
if (result != HACKRF_SUCCESS) {
|
||||
fprintf(stderr, "hackrf_open() failed: %s (%d)\n",
|
||||
hackrf_error_name(result), result);
|
||||
|
||||
@@ -168,13 +168,6 @@ t_wav_file_hdr wave_file_hdr =
|
||||
}
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
TRANSCEIVER_MODE_OFF = 0,
|
||||
TRANSCEIVER_MODE_RX = 1,
|
||||
TRANSCEIVER_MODE_TX = 2,
|
||||
TRANSCEIVER_MODE_SS = 3
|
||||
|
||||
} transceiver_mode_t;
|
||||
static transceiver_mode_t transceiver_mode = TRANSCEIVER_MODE_RX;
|
||||
|
||||
#define U64TOA_MAX_DIGIT (31)
|
||||
@@ -422,6 +415,7 @@ int tx_callback(hackrf_transfer* transfer) {
|
||||
|
||||
static void usage() {
|
||||
printf("Usage:\n");
|
||||
printf("\t[-d serial_number] # Serial number of desired HackRF.\n");
|
||||
printf("\t-r <filename> # Receive data into file.\n");
|
||||
printf("\t-t <filename> # Transmit data from file.\n");
|
||||
printf("\t-w # Receive data into file with WAV header and automatic name.\n");
|
||||
@@ -477,6 +471,7 @@ int main(int argc, char** argv) {
|
||||
char path_file[PATH_FILE_MAX_LEN];
|
||||
char date_time[DATE_TIME_MAX_LEN];
|
||||
const char* path = NULL;
|
||||
const char* serial_number = NULL;
|
||||
int result;
|
||||
time_t rawtime;
|
||||
struct tm * timeinfo;
|
||||
@@ -486,7 +481,7 @@ int main(int argc, char** argv) {
|
||||
float time_diff;
|
||||
unsigned int lna_gain=8, vga_gain=20, txvga_gain=0;
|
||||
|
||||
while( (opt = getopt(argc, argv, "wr:t:f:i:o:m:a:p:s:n:b:l:g:x:c:")) != EOF )
|
||||
while( (opt = getopt(argc, argv, "wr:t:f:i:o:m:a:p:s:n:b:l:g:x:c:d:")) != EOF )
|
||||
{
|
||||
result = HACKRF_SUCCESS;
|
||||
switch( opt )
|
||||
@@ -505,6 +500,10 @@ int main(int argc, char** argv) {
|
||||
path = optarg;
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
serial_number = optarg;
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
automatic_tuning = true;
|
||||
result = parse_u64(optarg, &freq_hz);
|
||||
@@ -782,7 +781,7 @@ int main(int argc, char** argv) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
result = hackrf_open(&device);
|
||||
result = hackrf_open_by_serial(serial_number, &device);
|
||||
if( result != HACKRF_SUCCESS ) {
|
||||
printf("hackrf_open() failed: %s (%d)\n", hackrf_error_name(result), result);
|
||||
usage();
|
||||
|
||||
Reference in New Issue
Block a user