[HackRF] Added missing build configs and changed some functions to go along with the rest of the project.

This commit is contained in:
Carlos Pizarro 2019-12-14 21:40:43 -03:00
parent 0f0696c97b
commit 1223f7f29a
No known key found for this signature in database
GPG Key ID: DDA8A83567C1D234
3 changed files with 25 additions and 24 deletions

2
debian/control vendored
View File

@ -2,7 +2,7 @@ Source: dump1090-fa
Section: embedded Section: embedded
Priority: extra Priority: extra
Maintainer: Oliver Jowett <oliver@mutability.co.uk> Maintainer: Oliver Jowett <oliver@mutability.co.uk>
Build-Depends: debhelper(>=9), librtlsdr-dev, libusb-1.0-0-dev, pkg-config, dh-systemd, libncurses5-dev, libbladerf-dev Build-Depends: debhelper(>=9), librtlsdr-dev, libusb-1.0-0-dev, pkg-config, dh-systemd, libncurses5-dev, libbladerf-dev, libhackrf-dev
Standards-Version: 3.9.3 Standards-Version: 3.9.3
Homepage: http://www.flightaware.com/ Homepage: http://www.flightaware.com/
Vcs-Git: https://github.com/flightaware/dump1090.git Vcs-Git: https://github.com/flightaware/dump1090.git

2
debian/rules vendored
View File

@ -20,7 +20,7 @@ ifeq ($(DEB_HOST_ARCH),armhf)
endif endif
override_dh_auto_build: override_dh_auto_build:
dh_auto_build -- RTLSDR=yes BLADERF=yes DUMP1090_VERSION=$(DEB_VERSION) dh_auto_build -- RTLSDR=yes BLADERF=yes HACKRF=yes DUMP1090_VERSION=$(DEB_VERSION)
override_dh_install: override_dh_install:
dh_install dh_install

View File

@ -57,24 +57,24 @@ bool hackRFHandleOption(int argc, char **argv, int *jptr)
HackRF.lna_gain = atoi(argv[++j]); HackRF.lna_gain = atoi(argv[++j]);
if (HackRF.lna_gain % 8 != 0) { if (HackRF.lna_gain % 8 != 0) {
printf("Error: --lna-gain must be multiple of 8\n"); fprintf(stderr, "Error: --lna-gain must be multiple of 8\n");
return false; return false;
} }
if (HackRF.lna_gain > 40 || HackRF.lna_gain < 0) { if (HackRF.lna_gain > 40 || HackRF.lna_gain < 0) {
printf("Error: --lna-gain range is 0 - 42\n"); fprintf(stderr, "Error: --lna-gain range is 0 - 42\n");
return false; return false;
} }
} else if (!strcmp(argv[j], "--vga-gain") && more) { } else if (!strcmp(argv[j], "--vga-gain") && more) {
HackRF.vga_gain = atoi(argv[++j]); HackRF.vga_gain = atoi(argv[++j]);
if (HackRF.vga_gain % 2 != 0) { if (HackRF.vga_gain % 2 != 0) {
printf("Error: --vga-gain must be multiple of 2\n"); fprintf(stderr, "Error: --vga-gain must be multiple of 2\n");
return false; return false;
} }
if (HackRF.vga_gain > 62 || HackRF.vga_gain < 0) { if (HackRF.vga_gain > 62 || HackRF.vga_gain < 0) {
printf("Error: --vga-gain range is 0 - 62\n"); fprintf(stderr, "Error: --vga-gain range is 0 - 62\n");
return false; return false;
} }
@ -82,7 +82,7 @@ bool hackRFHandleOption(int argc, char **argv, int *jptr)
HackRF.ppm = atoi(argv[++j]); HackRF.ppm = atoi(argv[++j]);
} else if (!strcmp(argv[j], "--samplerate") && more) { } else if (!strcmp(argv[j], "--samplerate") && more) {
HackRF.rate = atoi(argv[++j]); HackRF.rate = atoi(argv[++j]);
} else if (!strcmp(argv[j], "--enable-amp") && more) { } else if (!strcmp(argv[j], "--enable-amp")) {
HackRF.enable_amp = 1; HackRF.enable_amp = 1;
} else { } else {
return false; return false;
@ -107,11 +107,11 @@ void hackRFShowHelp()
static void show_config() static void show_config()
{ {
printf("freq : %ld\n", HackRF.freq); fprintf(stderr, "freq : %ld\n", HackRF.freq);
printf("lna_gain : %d\n", HackRF.lna_gain); fprintf(stderr, "lna_gain : %d\n", HackRF.lna_gain);
printf("vga_gain : %d\n", HackRF.vga_gain); fprintf(stderr, "vga_gain : %d\n", HackRF.vga_gain);
printf("samplerate : %d\n", HackRF.rate); fprintf(stderr, "samplerate : %d\n", HackRF.rate);
printf("ppm : %d\n", HackRF.ppm); fprintf(stderr, "ppm : %d\n", HackRF.ppm);
} }
bool hackRFOpen() bool hackRFOpen()
@ -130,7 +130,7 @@ bool hackRFOpen()
status = hackrf_init(); status = hackrf_init();
if (status != 0) { if (status != 0) {
printf("HackRF: hackrf_init failed with code %d", status); fprintf(stderr, "HackRF: hackrf_init failed with code %d", status);
hackrf_close(HackRF.device); hackrf_close(HackRF.device);
hackrf_exit(); hackrf_exit();
return false; return false;
@ -138,7 +138,7 @@ bool hackRFOpen()
status = hackrf_open(&HackRF.device); status = hackrf_open(&HackRF.device);
if (status != 0) { if (status != 0) {
printf("HackRF: hackrf_open failed with code %d", status); fprintf(stderr, "HackRF: hackrf_open failed with code %d", status);
hackrf_close(HackRF.device); hackrf_close(HackRF.device);
hackrf_exit(); hackrf_exit();
return false; return false;
@ -146,7 +146,7 @@ bool hackRFOpen()
status = hackrf_set_freq(HackRF.device, HackRF.freq); status = hackrf_set_freq(HackRF.device, HackRF.freq);
if (status != 0) { if (status != 0) {
printf("HackRF: hackrf_set_freq failed with code %d", status); fprintf(stderr, "HackRF: hackrf_set_freq failed with code %d", status);
hackrf_close(HackRF.device); hackrf_close(HackRF.device);
hackrf_exit(); hackrf_exit();
return false; return false;
@ -154,7 +154,7 @@ bool hackRFOpen()
status = hackrf_set_sample_rate(HackRF.device, HackRF.rate); status = hackrf_set_sample_rate(HackRF.device, HackRF.rate);
if (status != 0) { if (status != 0) {
printf("HackRF: hackrf_set_sample_rate failed with code %d", status); fprintf(stderr, "HackRF: hackrf_set_sample_rate failed with code %d", status);
hackrf_close(HackRF.device); hackrf_close(HackRF.device);
hackrf_exit(); hackrf_exit();
return false; return false;
@ -162,7 +162,7 @@ bool hackRFOpen()
status = hackrf_set_amp_enable(HackRF.device, HackRF.enable_amp); status = hackrf_set_amp_enable(HackRF.device, HackRF.enable_amp);
if (status != 0) { if (status != 0) {
printf("HackRF: hackrf_set_amp_enable failed with code %d", status); fprintf(stderr, "HackRF: hackrf_set_amp_enable failed with code %d", status);
hackrf_close(HackRF.device); hackrf_close(HackRF.device);
hackrf_exit(); hackrf_exit();
return false; return false;
@ -170,7 +170,7 @@ bool hackRFOpen()
status = hackrf_set_lna_gain(HackRF.device, HackRF.lna_gain); status = hackrf_set_lna_gain(HackRF.device, HackRF.lna_gain);
if (status != 0) { if (status != 0) {
printf("HackRF: hackrf_set_lna_gain failed with code %d", status); fprintf(stderr, "HackRF: hackrf_set_lna_gain failed with code %d", status);
hackrf_close(HackRF.device); hackrf_close(HackRF.device);
hackrf_exit(); hackrf_exit();
return false; return false;
@ -178,7 +178,7 @@ bool hackRFOpen()
status = hackrf_set_vga_gain(HackRF.device, HackRF.vga_gain); status = hackrf_set_vga_gain(HackRF.device, HackRF.vga_gain);
if (status != 0) { if (status != 0) {
printf("HackRF: hackrf_set_vga_gain failed with code %d", status); fprintf(stderr, "HackRF: hackrf_set_vga_gain failed with code %d", status);
hackrf_close(HackRF.device); hackrf_close(HackRF.device);
hackrf_exit(); hackrf_exit();
return false; return false;
@ -191,7 +191,7 @@ bool hackRFOpen()
Modes.dc_filter, Modes.dc_filter,
&HackRF.converter_state); &HackRF.converter_state);
if (!HackRF.converter) { if (!HackRF.converter) {
printf("HackRF: can't initialize sample converter\n"); fprintf(stderr, "HackRF: can't initialize sample converter\n");
return false; return false;
} }
@ -288,7 +288,7 @@ int handle_hackrf_samples(hackrf_transfer *transfer)
void hackRFRun() void hackRFRun()
{ {
if (!HackRF.device) { if (!HackRF.device) {
printf("hackRFRun: HackRF.device = NULL\n"); fprintf(stderr, "hackRFRun: HackRF.device = NULL\n");
return; return;
} }
@ -297,7 +297,7 @@ void hackRFRun()
int status = hackrf_start_rx(HackRF.device, &handle_hackrf_samples, NULL); int status = hackrf_start_rx(HackRF.device, &handle_hackrf_samples, NULL);
if (status != 0) { if (status != 0) {
printf("hackrf_start_rx failed"); fprintf(stderr, "hackrf_start_rx failed");
hackrf_close(HackRF.device); hackrf_close(HackRF.device);
hackrf_exit(); hackrf_exit();
exit (1); exit (1);
@ -306,10 +306,11 @@ void hackRFRun()
// hackrf_start_rx does not block so we need to wait until the streaming is finished // hackrf_start_rx does not block so we need to wait until the streaming is finished
// before returning from the hackRFRun function // before returning from the hackRFRun function
while (hackrf_is_streaming(HackRF.device) == HACKRF_TRUE) { while (hackrf_is_streaming(HackRF.device) == HACKRF_TRUE) {
usleep(10000); struct timespec slp = { 0, 100 * 1000 * 1000};
nanosleep(&slp, NULL);
} }
printf("HackRF stopped streaming %d\n", hackrf_is_streaming(HackRF.device)); fprintf(stderr, "HackRF stopped streaming %d\n", hackrf_is_streaming(HackRF.device));
} }
void hackRFClose() void hackRFClose()