hackrf_cpldjtag: added -d for device serial number

This commit is contained in:
Heikki Hannikainen
2015-02-23 22:44:18 +02:00
committed by Heikki Hannikainen
parent 6aa5f00186
commit 33e20bda0c

View File

@ -80,6 +80,7 @@ static void usage()
{ {
printf("Usage:\n"); printf("Usage:\n");
printf("\t-x <filename>: XSVF file to be written to CPLD.\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) int main(int argc, char** argv)
@ -88,6 +89,7 @@ int main(int argc, char** argv)
uint32_t length = 0; uint32_t length = 0;
uint32_t total_length = 0; uint32_t total_length = 0;
const char* path = NULL; const char* path = NULL;
const char* serial_number = NULL;
hackrf_device* device = NULL; hackrf_device* device = NULL;
int result = HACKRF_SUCCESS; int result = HACKRF_SUCCESS;
int option_index = 0; int option_index = 0;
@ -95,13 +97,17 @@ int main(int argc, char** argv)
ssize_t bytes_read; ssize_t bytes_read;
uint8_t* pdata = &data[0]; 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) { &option_index)) != EOF) {
switch (opt) { switch (opt) {
case 'x': case 'x':
path = optarg; path = optarg;
break; break;
case 'd':
serial_number = optarg;
break;
default: default:
usage(); usage();
return EXIT_FAILURE; return EXIT_FAILURE;
@ -158,7 +164,7 @@ int main(int argc, char** argv)
return EXIT_FAILURE; return EXIT_FAILURE;
} }
result = hackrf_open(NULL, &device); result = hackrf_open(serial_number, &device);
if (result != HACKRF_SUCCESS) { if (result != HACKRF_SUCCESS) {
fprintf(stderr, "hackrf_open() failed: %s (%d)\n", fprintf(stderr, "hackrf_open() failed: %s (%d)\n",
hackrf_error_name(result), result); hackrf_error_name(result), result);