hackrf_sweep: improve -w (bin_width) guidance

This commit is contained in:
Michael Ossmann
2021-11-14 12:05:29 -07:00
parent 9856452215
commit 8a3547e71e

View File

@ -349,7 +349,7 @@ static void usage() {
fprintf(stderr, "\t[-p antenna_enable] # Antenna port power, 1=Enable, 0=Disable\n"); fprintf(stderr, "\t[-p antenna_enable] # Antenna port power, 1=Enable, 0=Disable\n");
fprintf(stderr, "\t[-l gain_db] # RX LNA (IF) gain, 0-40dB, 8dB steps\n"); fprintf(stderr, "\t[-l gain_db] # RX LNA (IF) gain, 0-40dB, 8dB steps\n");
fprintf(stderr, "\t[-g gain_db] # RX VGA (baseband) gain, 0-62dB, 2dB steps\n"); fprintf(stderr, "\t[-g gain_db] # RX VGA (baseband) gain, 0-62dB, 2dB steps\n");
fprintf(stderr, "\t[-w bin_width] # FFT bin width (frequency resolution) in Hz\n"); fprintf(stderr, "\t[-w bin_width] # FFT bin width (frequency resolution) in Hz, 2444-5000000\n");
fprintf(stderr, "\t[-1] # one shot mode\n"); fprintf(stderr, "\t[-1] # one shot mode\n");
fprintf(stderr, "\t[-N num_sweeps] # Number of sweeps to perform\n"); fprintf(stderr, "\t[-N num_sweeps] # Number of sweeps to perform\n");
fprintf(stderr, "\t[-B] # binary output\n"); fprintf(stderr, "\t[-B] # binary output\n");
@ -529,15 +529,25 @@ int main(int argc, char** argv) {
return EXIT_FAILURE; return EXIT_FAILURE;
} }
/*
* The FFT bin width must be no more than a quarter of the sample rate
* for interleaved mode. With our fixed sample rate of 20 Msps, that
* results in a maximum bin width of 5000000 Hz.
*/
if(4 > fftSize) { if(4 > fftSize) {
fprintf(stderr, fprintf(stderr,
"argument error: FFT bin width (-w) must be no more than one quarter the sample rate\n"); "argument error: FFT bin width (-w) must be no more than 5000000\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
/*
* The maximum number of FFT bins we support is equal to the number of
* samples in a block. With our fixed sample rate of 20 Msps, that
* results in a minimum bin width of 2444 Hz.
*/
if(8184 < fftSize) { if(8184 < fftSize) {
fprintf(stderr, fprintf(stderr,
"argument error: FFT bin width (-w) too small, resulted in more than 8184 FFT bins\n"); "argument error: FFT bin width (-w) must be no less than 2444\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }