Start TX/RX in hackrf_transfer after all other requests.

This avoids glitches and lost samples at the start of a transmission.
This commit is contained in:
Martin Ling
2022-09-15 09:51:11 +01:00
parent f2d00adab8
commit 09c6030ec9

View File

@ -1176,15 +1176,6 @@ int main(int argc, char** argv)
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if (transceiver_mode == TRANSCEIVER_MODE_RX) {
result = hackrf_set_vga_gain(device, vga_gain);
result |= hackrf_set_lna_gain(device, lna_gain);
result |= hackrf_start_rx(device, rx_callback, NULL);
} else {
result = hackrf_set_txvga_gain(device, txvga_gain);
result |= hackrf_enable_tx_flush(device, 1);
result |= hackrf_start_tx(device, tx_callback, NULL);
}
if (result != HACKRF_SUCCESS) { if (result != HACKRF_SUCCESS) {
fprintf(stderr, fprintf(stderr,
"hackrf_start_?x() failed: %s (%d)\n", "hackrf_start_?x() failed: %s (%d)\n",
@ -1255,6 +1246,16 @@ int main(int argc, char** argv)
} }
} }
if (transceiver_mode == TRANSCEIVER_MODE_RX) {
result = hackrf_set_vga_gain(device, vga_gain);
result |= hackrf_set_lna_gain(device, lna_gain);
result |= hackrf_start_rx(device, rx_callback, NULL);
} else {
result = hackrf_set_txvga_gain(device, txvga_gain);
result |= hackrf_enable_tx_flush(device, 1);
result |= hackrf_start_tx(device, tx_callback, NULL);
}
if (limit_num_samples) { if (limit_num_samples) {
fprintf(stderr, fprintf(stderr,
"samples_to_xfer %s/%sMio\n", "samples_to_xfer %s/%sMio\n",