mirror of
https://github.com/greatscottgadgets/hackrf.git
synced 2026-03-04 06:25:25 +01:00
Add USB requests and host support to set TX/RX shortfall limits.
This adds `-T` and `-R` options to `hackrf_debug`, which set the TX underrun and RX overrun limits in bytes.
This commit is contained in:
@@ -405,6 +405,8 @@ static void usage() {
|
||||
printf("\t-s, --si5351c: target SI5351C\n");
|
||||
printf("\t-f, --rffc5072: target RFFC5072\n");
|
||||
printf("\t-S, --state: display M0 state\n");
|
||||
printf("\t-T, --tx-underrun-limit <n>: set TX underrun limit in bytes (0 for no limit)\n");
|
||||
printf("\t-R, --rx-overrun-limit <n>: set RX overrun limit in bytes (0 for no limit)\n");
|
||||
printf("\t-u, --ui <1/0>: enable/disable UI\n");
|
||||
printf("\nExamples:\n");
|
||||
printf("\thackrf_debug --si5351c -n 0 -r # reads from si5351c register 0\n");
|
||||
@@ -425,6 +427,8 @@ static struct option long_options[] = {
|
||||
{ "si5351c", no_argument, 0, 's' },
|
||||
{ "rffc5072", no_argument, 0, 'f' },
|
||||
{ "state", no_argument, 0, 'S' },
|
||||
{ "tx-underrun-limit", required_argument, 0, 'T' },
|
||||
{ "rx-overrun-limit", required_argument, 0, 'R' },
|
||||
{ "ui", required_argument, 0, 'u' },
|
||||
{ 0, 0, 0, 0 },
|
||||
};
|
||||
@@ -443,6 +447,10 @@ int main(int argc, char** argv) {
|
||||
const char* serial_number = NULL;
|
||||
bool set_ui = false;
|
||||
uint32_t ui_enable;
|
||||
uint32_t tx_limit;
|
||||
uint32_t rx_limit;
|
||||
bool set_tx_limit = false;
|
||||
bool set_rx_limit = false;
|
||||
|
||||
int result = hackrf_init();
|
||||
if(result) {
|
||||
@@ -450,7 +458,7 @@ int main(int argc, char** argv) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
while( (opt = getopt_long(argc, argv, "n:rw:d:cmsfSh?u:", long_options, &option_index)) != EOF ) {
|
||||
while( (opt = getopt_long(argc, argv, "n:rw:d:cmsfST:R:h?u:", long_options, &option_index)) != EOF ) {
|
||||
switch( opt ) {
|
||||
case 'n':
|
||||
result = parse_int(optarg, ®ister_number);
|
||||
@@ -473,6 +481,15 @@ int main(int argc, char** argv) {
|
||||
dump_state = true;
|
||||
break;
|
||||
|
||||
case 'T':
|
||||
set_tx_limit = true;
|
||||
result = parse_int(optarg, &tx_limit);
|
||||
break;
|
||||
case 'R':
|
||||
set_rx_limit = true;
|
||||
result = parse_int(optarg, &rx_limit);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
serial_number = optarg;
|
||||
break;
|
||||
@@ -541,13 +558,13 @@ int main(int argc, char** argv) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if(!(write || read || dump_config || dump_state || set_ui)) {
|
||||
if(!(write || read || dump_config || dump_state || set_tx_limit || set_rx_limit || set_ui)) {
|
||||
fprintf(stderr, "Specify read, write, or config option.\n");
|
||||
usage();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if(part == PART_NONE && !set_ui && !dump_state) {
|
||||
if(part == PART_NONE && !set_ui && !dump_state && !set_tx_limit && !set_rx_limit) {
|
||||
fprintf(stderr, "Specify a part to read, write, or print config from.\n");
|
||||
usage();
|
||||
return EXIT_FAILURE;
|
||||
@@ -575,6 +592,22 @@ int main(int argc, char** argv) {
|
||||
si5351c_read_configuration(device);
|
||||
}
|
||||
|
||||
if (set_tx_limit) {
|
||||
result = hackrf_set_tx_underrun_limit(device, tx_limit);
|
||||
if(result != HACKRF_SUCCESS) {
|
||||
printf("hackrf_set_tx_underrun_limit() failed: %s (%d)\n", hackrf_error_name(result), result);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (set_rx_limit) {
|
||||
result = hackrf_set_rx_overrun_limit(device, rx_limit);
|
||||
if(result != HACKRF_SUCCESS) {
|
||||
printf("hackrf_set_rx_overrun_limit() failed: %s (%d)\n", hackrf_error_name(result), result);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if(dump_state) {
|
||||
hackrf_m0_state state;
|
||||
result = hackrf_get_m0_state(device, &state);
|
||||
|
||||
Reference in New Issue
Block a user