Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for HackRF One #57

Merged
merged 2 commits into from
Aug 3, 2020
Merged

Added support for HackRF One #57

merged 2 commits into from
Aug 3, 2020

Conversation

kr105
Copy link

@kr105 kr105 commented Dec 9, 2019

I have added support for HackRF One device using libhackrf. I tested all the new functions successfully for a few days.

@cyclops1982
Copy link

I tested this and it works!

@mutability mutability changed the base branch from master to dev August 3, 2020 03:33
@mutability mutability added the new sdr support support for different SDR types label Aug 3, 2020
Copy link

@mutability mutability left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. A couple of minor things I'll fix when merging.

I don't have hardware to test on, but it compiles OK and "runs" (up to the point of failing to find hardware) OK.

Comment on lines +131 to +185
status = hackrf_init();
if (status != 0) {
fprintf(stderr, "HackRF: hackrf_init failed with code %d", status);
hackrf_close(HackRF.device);
hackrf_exit();
return false;
}

status = hackrf_open(&HackRF.device);
if (status != 0) {
fprintf(stderr, "HackRF: hackrf_open failed with code %d", status);
hackrf_close(HackRF.device);
hackrf_exit();
return false;
}

status = hackrf_set_freq(HackRF.device, HackRF.freq);
if (status != 0) {
fprintf(stderr, "HackRF: hackrf_set_freq failed with code %d", status);
hackrf_close(HackRF.device);
hackrf_exit();
return false;
}

status = hackrf_set_sample_rate(HackRF.device, HackRF.rate);
if (status != 0) {
fprintf(stderr, "HackRF: hackrf_set_sample_rate failed with code %d", status);
hackrf_close(HackRF.device);
hackrf_exit();
return false;
}

status = hackrf_set_amp_enable(HackRF.device, HackRF.enable_amp);
if (status != 0) {
fprintf(stderr, "HackRF: hackrf_set_amp_enable failed with code %d", status);
hackrf_close(HackRF.device);
hackrf_exit();
return false;
}

status = hackrf_set_lna_gain(HackRF.device, HackRF.lna_gain);
if (status != 0) {
fprintf(stderr, "HackRF: hackrf_set_lna_gain failed with code %d", status);
hackrf_close(HackRF.device);
hackrf_exit();
return false;
}

status = hackrf_set_vga_gain(HackRF.device, HackRF.vga_gain);
if (status != 0) {
fprintf(stderr, "HackRF: hackrf_set_vga_gain failed with code %d", status);
hackrf_close(HackRF.device);
hackrf_exit();
return false;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing trailing \n on these error messages


struct timespec thread_cpu;

int handle_hackrf_samples(hackrf_transfer *transfer)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to become static now that we're building with -Wmissing-declarations (that change postdates your PR)

Comment on lines +131 to +145
status = hackrf_init();
if (status != 0) {
fprintf(stderr, "HackRF: hackrf_init failed with code %d", status);
hackrf_close(HackRF.device);
hackrf_exit();
return false;
}

status = hackrf_open(&HackRF.device);
if (status != 0) {
fprintf(stderr, "HackRF: hackrf_open failed with code %d", status);
hackrf_close(HackRF.device);
hackrf_exit();
return false;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand the hackrf API correctly, the cleanup paths here need to be a little more careful (don't call exit if init failed; don't call close if open failed)

mutability added a commit that referenced this pull request Aug 3, 2020
@mutability mutability merged commit 5261b98 into flightaware:dev Aug 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new sdr support support for different SDR types
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants