@ -34,7 +34,6 @@ 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 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");
|
||||||
@ -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,15 +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 ) {
|
if( result ) {
|
||||||
|
@ -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':
|
||||||
|
Reference in New Issue
Block a user