Add dwell time argument to hackrf sweep
- untested because I'm not able to fire up my HackRF right now
This commit is contained in:

committed by
Mike Walters

parent
6463479888
commit
a95d1ac027
@ -40,11 +40,15 @@ static uint64_t sweep_freq;
|
||||
bool odd = true;
|
||||
static uint16_t frequencies[MAX_FREQ_COUNT];
|
||||
static uint16_t frequency_count = 0;
|
||||
static uint32_t dwell_blocks = 0;
|
||||
|
||||
usb_request_status_t usb_vendor_request_init_sweep(
|
||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)
|
||||
{
|
||||
uint32_t dwell_time;
|
||||
if (stage == USB_TRANSFER_STAGE_SETUP) {
|
||||
dwell_time = (endpoint->setup.index << 16) | endpoint->setup.value;
|
||||
dwell_blocks = dwell_time / 0x4000;
|
||||
frequency_count = endpoint->setup.length / sizeof(uint16_t);
|
||||
usb_transfer_schedule_block(endpoint->out, &frequencies,
|
||||
endpoint->setup.length, NULL, NULL);
|
||||
@ -95,7 +99,7 @@ void sweep_mode(void) {
|
||||
transfer = false;
|
||||
}
|
||||
|
||||
if (blocks_queued > 2) {
|
||||
if (blocks_queued >= dwell_blocks) {
|
||||
if(++ifreq >= frequency_count)
|
||||
ifreq = 0;
|
||||
sweep_freq = frequencies[ifreq];
|
||||
|
@ -24,7 +24,7 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
project(hackrf-tools C)
|
||||
set(MAJOR_VERSION 0)
|
||||
set(MINOR_VERSION 4)
|
||||
set(MINOR_VERSION 5)
|
||||
set(PACKAGE hackrf-tools)
|
||||
set(VERSION_STRING ${MAJOR_VERSION}.${MINOR_VERSION})
|
||||
set(VERSION ${VERSION_STRING})
|
||||
|
@ -94,6 +94,8 @@ int gettimeofday(struct timeval *tv, void* ignored) {
|
||||
#define FREQ_STEP (DEFAULT_SAMPLE_RATE_HZ / FREQ_ONE_MHZ)
|
||||
#define MAX_FREQ_COUNT 1000
|
||||
|
||||
#define DEFAULT_DWELL_TIME 0x4000
|
||||
|
||||
#if defined _WIN32
|
||||
#define sleep(a) Sleep( (a*1000) )
|
||||
#endif
|
||||
@ -239,6 +241,7 @@ static void usage() {
|
||||
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[-x gain_db] # TX VGA (IF) gain, 0-47dB, 1dB steps\n");
|
||||
fprintf(stderr, "\t[-s dwell_time] # Dwell time in samples, 0-%lu\n", (uint64_t)1<<32);
|
||||
}
|
||||
|
||||
static hackrf_device* device = NULL;
|
||||
@ -270,8 +273,9 @@ int main(int argc, char** argv) {
|
||||
float time_diff;
|
||||
unsigned int lna_gain=16, vga_gain=20, txvga_gain=0;
|
||||
uint16_t frequencies[MAX_FREQ_COUNT];
|
||||
uint32_t dwell_time = DEFAULT_DWELL_TIME;
|
||||
|
||||
while( (opt = getopt(argc, argv, "a:f:p:l:g:x:d:")) != EOF ) {
|
||||
while( (opt = getopt(argc, argv, "a:f:p:l:g:x:d:s:")) != EOF ) {
|
||||
result = HACKRF_SUCCESS;
|
||||
switch( opt )
|
||||
{
|
||||
@ -316,6 +320,10 @@ int main(int argc, char** argv) {
|
||||
result = parse_u32(optarg, &txvga_gain);
|
||||
break;
|
||||
|
||||
case 's':
|
||||
result = parse_u32(optarg, &dwell_time);
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "unknown argument '-%c %s'\n", opt, optarg);
|
||||
usage();
|
||||
@ -335,6 +343,11 @@ int main(int argc, char** argv) {
|
||||
if (vga_gain % 2)
|
||||
fprintf(stderr, "warning: vga_gain (-g) must be a multiple of 2\n");
|
||||
|
||||
if (dwell_time % 0x4000) {
|
||||
fprintf(stderr, "warning: dwell_time (-s) must be a multiple of 16384\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if( amp ) {
|
||||
if( amp_enable > 1 ) {
|
||||
fprintf(stderr, "argument error: amp_enable shall be 0 or 1.\n");
|
||||
@ -433,8 +446,7 @@ int main(int argc, char** argv) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* DGS FIXME: allow upper and lower frequencies to be set */
|
||||
result = hackrf_init_sweep(device, frequencies, ifreq);
|
||||
result = hackrf_init_sweep(device, frequencies, ifreq, dwell_time);
|
||||
if( result != HACKRF_SUCCESS ) {
|
||||
fprintf(stderr, "hackrf_init_sweep() failed: %s (%d)\n",
|
||||
hackrf_error_name(result), result);
|
||||
|
@ -1699,7 +1699,7 @@ uint32_t ADDCALL hackrf_compute_baseband_filter_bw(const uint32_t bandwidth_hz)
|
||||
|
||||
int ADDCALL hackrf_init_sweep(hackrf_device* device,
|
||||
uint16_t* frequency_list,
|
||||
int length)
|
||||
int length, uint32_t dwell_time)
|
||||
{
|
||||
int result, i;
|
||||
int size = length * sizeof(frequency_list[0]);
|
||||
@ -1711,8 +1711,8 @@ int ADDCALL hackrf_init_sweep(hackrf_device* device,
|
||||
device->usb_device,
|
||||
LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,
|
||||
HACKRF_VENDOR_REQUEST_INIT_SWEEP,
|
||||
0,
|
||||
0,
|
||||
dwell_time & 0xff,
|
||||
(dwell_time >> 16) & 0xff,
|
||||
(unsigned char*)frequency_list,
|
||||
size,
|
||||
0
|
||||
|
@ -199,7 +199,7 @@ extern ADDAPI uint32_t ADDCALL hackrf_compute_baseband_filter_bw(const uint32_t
|
||||
/* Start scan mode */
|
||||
extern ADDAPI int ADDCALL hackrf_init_sweep(hackrf_device* device,
|
||||
uint16_t* frequency_list,
|
||||
int length);
|
||||
int length, uint32_t dwell_time);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // __cplusplus defined.
|
||||
|
Reference in New Issue
Block a user