Added -h/-? option for help to all command line tools.
This commit is contained in:
@ -45,6 +45,7 @@ uint8_t data[MAX_XSVF_LENGTH];
|
||||
|
||||
static struct option long_options[] = {
|
||||
{ "xsvf", required_argument, 0, 'x' },
|
||||
{ "help", no_argument, 0, 'h' },
|
||||
{ 0, 0, 0, 0 },
|
||||
};
|
||||
|
||||
@ -79,7 +80,8 @@ int parse_int(char* s, uint32_t* const value)
|
||||
static void usage()
|
||||
{
|
||||
printf("Usage:\n");
|
||||
printf("\t-x <filename>: XSVF file to be written to CPLD.\n");
|
||||
printf("\t-h, --help: this help\n");
|
||||
printf("\t-x, --xsvf <filename>: XSVF file to be written to CPLD.\n");
|
||||
printf("\t-d <serialnumber>: Serial number of device, if multiple devices\n");
|
||||
}
|
||||
|
||||
@ -97,7 +99,7 @@ int main(int argc, char** argv)
|
||||
ssize_t bytes_read;
|
||||
uint8_t* pdata = &data[0];
|
||||
|
||||
while ((opt = getopt_long(argc, argv, "x:d:", long_options,
|
||||
while ((opt = getopt_long(argc, argv, "x:d:h?", long_options,
|
||||
&option_index)) != EOF) {
|
||||
switch (opt) {
|
||||
case 'x':
|
||||
@ -107,8 +109,13 @@ int main(int argc, char** argv)
|
||||
case 'd':
|
||||
serial_number = optarg;
|
||||
break;
|
||||
case 'h':
|
||||
case '?':
|
||||
usage();
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "unknown argument '-%c %s'\n", opt, optarg);
|
||||
usage();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
static void usage() {
|
||||
printf("\nUsage:\n");
|
||||
printf("\t-h, --help: this help\n");
|
||||
printf("\t-n, --register <n>: set register number for subsequent read/write operations\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");
|
||||
@ -41,6 +42,7 @@ static struct option long_options[] = {
|
||||
{ "register", required_argument, 0, 'n' },
|
||||
{ "write", required_argument, 0, 'w' },
|
||||
{ "read", no_argument, 0, 'r' },
|
||||
{ "help", no_argument, 0, 'h' },
|
||||
{ 0, 0, 0, 0 },
|
||||
};
|
||||
|
||||
@ -127,16 +129,16 @@ int main(int argc, char** argv) {
|
||||
int result = hackrf_init();
|
||||
if( result ) {
|
||||
printf("hackrf_init() failed: %s (%d)\n", hackrf_error_name(result), result);
|
||||
return -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
result = hackrf_open(&device);
|
||||
if( result ) {
|
||||
printf("hackrf_open() failed: %s (%d)\n", hackrf_error_name(result), result);
|
||||
return -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
while( (opt = getopt_long(argc, argv, "n:rw:", long_options, &option_index)) != EOF ) {
|
||||
while( (opt = getopt_long(argc, argv, "n:rw:h?", long_options, &option_index)) != EOF ) {
|
||||
switch( opt ) {
|
||||
case 'n':
|
||||
result = parse_int(optarg, ®ister_number);
|
||||
@ -157,8 +159,14 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
case 'h':
|
||||
case '?':
|
||||
usage();
|
||||
return EXIT_SUCCESS;
|
||||
default:
|
||||
fprintf(stderr, "unknown argument '-%c %s'\n", opt, optarg);
|
||||
usage();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if( result != HACKRF_SUCCESS ) {
|
||||
@ -170,10 +178,10 @@ int main(int argc, char** argv) {
|
||||
result = hackrf_close(device);
|
||||
if( result ) {
|
||||
printf("hackrf_close() failed: %s (%d)\n", hackrf_error_name(result), result);
|
||||
return -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
hackrf_exit();
|
||||
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ typedef int bool;
|
||||
|
||||
static void usage() {
|
||||
printf("\nUsage:\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-o, --address <n>: specify a particular operacake by address [default: 0x00]\n");
|
||||
@ -45,6 +46,7 @@ static struct option long_options[] = {
|
||||
{ "device", no_argument, 0, 'd' },
|
||||
{ "serial", no_argument, 0, 's' },
|
||||
{ "address", no_argument, 0, 'o' },
|
||||
{ "help", no_argument, 0, 'h' },
|
||||
{ 0, 0, 0, 0 },
|
||||
};
|
||||
|
||||
@ -78,7 +80,7 @@ int main(int argc, char** argv) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
while( (opt = getopt_long(argc, argv, "d:s:o:a:b:v", long_options, &option_index)) != EOF ) {
|
||||
while( (opt = getopt_long(argc, argv, "d:s:o:a:b:vh?", long_options, &option_index)) != EOF ) {
|
||||
switch( opt ) {
|
||||
case 'd':
|
||||
device_index = atoi(optarg);
|
||||
@ -103,9 +105,15 @@ int main(int argc, char** argv) {
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
case 'h':
|
||||
case '?':
|
||||
usage();
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "unknown argument '-%c %s'\n", opt, optarg);
|
||||
usage();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if( result != HACKRF_SUCCESS ) {
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
static void usage() {
|
||||
printf("\nUsage:\n");
|
||||
printf("\t-h, --help: this help\n");
|
||||
printf("\t-n, --register <n>: set register number for subsequent read/write operations\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");
|
||||
@ -42,6 +43,7 @@ static struct option long_options[] = {
|
||||
{ "register", required_argument, 0, 'n' },
|
||||
{ "write", required_argument, 0, 'w' },
|
||||
{ "read", no_argument, 0, 'r' },
|
||||
{ "help", no_argument, 0, 'h' },
|
||||
{ 0, 0, 0, 0 },
|
||||
};
|
||||
|
||||
@ -128,16 +130,16 @@ int main(int argc, char** argv) {
|
||||
int result = hackrf_init();
|
||||
if( result ) {
|
||||
printf("hackrf_init() failed: %s (%d)\n", hackrf_error_name(result), result);
|
||||
return -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
result = hackrf_open(&device);
|
||||
if( result ) {
|
||||
printf("hackrf_open() failed: %s (%d)\n", hackrf_error_name(result), result);
|
||||
return -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
while( (opt = getopt_long(argc, argv, "n:rw:", long_options, &option_index)) != EOF ) {
|
||||
while( (opt = getopt_long(argc, argv, "n:rw:h?", long_options, &option_index)) != EOF ) {
|
||||
switch( opt ) {
|
||||
case 'n':
|
||||
result = parse_int(optarg, ®ister_number);
|
||||
@ -157,9 +159,15 @@ int main(int argc, char** argv) {
|
||||
result = dump_register(device, register_number);
|
||||
}
|
||||
break;
|
||||
case 'h':
|
||||
case '?':
|
||||
usage();
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "unknown argument '-%c %s'\n", opt, optarg);
|
||||
usage();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if( result != HACKRF_SUCCESS ) {
|
||||
@ -172,10 +180,10 @@ int main(int argc, char** argv) {
|
||||
result = hackrf_close(device);
|
||||
if( result ) {
|
||||
printf("hackrf_close() failed: %s (%d)\n", hackrf_error_name(result), result);
|
||||
return -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
hackrf_exit();
|
||||
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ typedef int bool;
|
||||
|
||||
static void usage() {
|
||||
printf("\nUsage:\n");
|
||||
printf("\t-h, --help: this help\n");
|
||||
printf("\t-c, --config: print textual configuration information\n");
|
||||
printf("\t-n, --register <n>: set register number for subsequent read/write operations\n");
|
||||
printf("\t-r, --read: read register specified by last -n argument, or all registers\n");
|
||||
@ -52,6 +53,7 @@ static struct option long_options[] = {
|
||||
{ "read", no_argument, 0, 'r' },
|
||||
{ "device", no_argument, 0, 'd' },
|
||||
{ "serial", no_argument, 0, 's' },
|
||||
{ "help", no_argument, 0, 'h' },
|
||||
{ 0, 0, 0, 0 },
|
||||
};
|
||||
|
||||
@ -209,10 +211,10 @@ int main(int argc, char** argv) {
|
||||
int result = hackrf_init();
|
||||
if( result ) {
|
||||
printf("hackrf_init() failed: %s (%d)\n", hackrf_error_name(result), result);
|
||||
return -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
while( (opt = getopt_long(argc, argv, "d:s:cn:rw:", long_options, &option_index)) != EOF ) {
|
||||
while( (opt = getopt_long(argc, argv, "d:s:cn:rw:h?", long_options, &option_index)) != EOF ) {
|
||||
switch( opt ) {
|
||||
case 'n':
|
||||
result = parse_int(optarg, ®ister_number);
|
||||
@ -237,9 +239,15 @@ int main(int argc, char** argv) {
|
||||
case 's':
|
||||
serial_number = optarg;
|
||||
break;
|
||||
case 'h':
|
||||
case '?':
|
||||
usage();
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "unknown argument '-%c %s'\n", opt, optarg);
|
||||
usage();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if( result != HACKRF_SUCCESS ) {
|
||||
@ -261,7 +269,7 @@ int main(int argc, char** argv) {
|
||||
|
||||
if( result ) {
|
||||
printf("hackrf_open() failed: %s (%d)\n", hackrf_error_name(result), result);
|
||||
return -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if(write) {
|
||||
@ -282,10 +290,10 @@ int main(int argc, char** argv) {
|
||||
result = hackrf_close(device);
|
||||
if( result ) {
|
||||
printf("hackrf_close() failed: %s (%d)\n", hackrf_error_name(result), result);
|
||||
return -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
hackrf_exit();
|
||||
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ static struct option long_options[] = {
|
||||
{ "read", required_argument, 0, 'r' },
|
||||
{ "write", required_argument, 0, 'w' },
|
||||
{ "verbose", no_argument, 0, 'v' },
|
||||
{ "help", no_argument, 0, 'h' },
|
||||
{ 0, 0, 0, 0 },
|
||||
};
|
||||
|
||||
@ -86,6 +87,7 @@ int parse_u32(char* s, uint32_t* const value)
|
||||
static void usage()
|
||||
{
|
||||
printf("Usage:\n");
|
||||
printf("\t-h, --help: this help\n");
|
||||
printf("\t-a, --address <n>: starting address (default: 0)\n");
|
||||
printf("\t-l, --length <n>: number of bytes to read (default: %d)\n", MAX_LENGTH);
|
||||
printf("\t-r <filename>: Read data into file.\n");
|
||||
@ -115,7 +117,7 @@ int main(int argc, char** argv)
|
||||
bool verbose = false;
|
||||
bool reset = false;
|
||||
|
||||
while ((opt = getopt_long(argc, argv, "a:l:r:w:d:vR", long_options,
|
||||
while ((opt = getopt_long(argc, argv, "a:l:r:w:d:vRh?", long_options,
|
||||
&option_index)) != EOF) {
|
||||
switch (opt) {
|
||||
case 'a':
|
||||
@ -148,9 +150,10 @@ int main(int argc, char** argv)
|
||||
reset = true;
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
case '?':
|
||||
usage();
|
||||
return EXIT_FAILURE;
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "unknown argument '-%c %s'\n", opt, optarg);
|
||||
|
@ -235,6 +235,7 @@ int rx_callback(hackrf_transfer* transfer) {
|
||||
|
||||
static void usage() {
|
||||
fprintf(stderr, "Usage:\n");
|
||||
fprintf(stderr, "\t[-h] # this help\n");
|
||||
fprintf(stderr, "\t[-d serial_number] # Serial number of desired HackRF.\n");
|
||||
fprintf(stderr, "\t[-a amp_enable] # RX/TX RF amplifier 1=Enable, 0=Disable.\n");
|
||||
fprintf(stderr, "\t[-f freq_min:freq_max # Specify minimum & maximum sweep frequencies (MHz).\n");
|
||||
@ -276,7 +277,7 @@ int main(int argc, char** argv) {
|
||||
uint16_t frequencies[MAX_FREQ_COUNT];
|
||||
uint32_t num_samples = DEFAULT_SAMPLE_COUNT;
|
||||
|
||||
while( (opt = getopt(argc, argv, "a:f:p:l:g:x:d:n:")) != EOF ) {
|
||||
while( (opt = getopt(argc, argv, "a:f:p:l:g:x:d:n:h?")) != EOF ) {
|
||||
result = HACKRF_SUCCESS;
|
||||
switch( opt )
|
||||
{
|
||||
@ -325,6 +326,11 @@ int main(int argc, char** argv) {
|
||||
result = parse_u32(optarg, &num_samples);
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
case '?':
|
||||
usage();
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "unknown argument '-%c %s'\n", opt, optarg);
|
||||
usage();
|
||||
|
@ -469,6 +469,7 @@ int tx_callback(hackrf_transfer* transfer) {
|
||||
|
||||
static void usage() {
|
||||
printf("Usage:\n");
|
||||
printf("\t-h # this help\n");
|
||||
printf("\t[-d serial_number] # Serial number of desired HackRF.\n");
|
||||
printf("\t-r <filename> # Receive data into file (use '-' for stdout).\n");
|
||||
printf("\t-t <filename> # Transmit data from file (use '-' for stdin).\n");
|
||||
@ -544,7 +545,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, "Hwr:t:f:i:o:m:a:p:s:n:b:l:g:x:c:d:C:RS:")) != EOF )
|
||||
while( (opt = getopt(argc, argv, "Hwr:t:f:i:o:m:a:p:s:n:b:l:g:x:c:d:C:RS:h?")) != EOF )
|
||||
{
|
||||
result = HACKRF_SUCCESS;
|
||||
switch( opt )
|
||||
@ -673,9 +674,10 @@ int main(int argc, char** argv) {
|
||||
result = parse_u32(optarg, &crystal_correct_ppm);
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
case '?':
|
||||
usage();
|
||||
return EXIT_FAILURE;
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "unknown argument '-%c %s'\n", opt, optarg);
|
||||
|
Reference in New Issue
Block a user