486 Commits

Author SHA1 Message Date
Jamie Smith
d60fb83320 Cleanup of host software CMake build system (#664)
* Clean up the CMake build system and improve the FindFFTW3 module.

* Fixes for Linux build

* Include winsock.h to get struct timeval

* Couple more fixes for MSVC, also add new FindMath module

* Update host build README for new CMake changes (esp. Windows)

* Try to fix Travis OS X build error

* Add docs about pthread-win32

* Whoops, AppVeyor caught a bug in FindFFTW where the includes not being found weren't generating a fatal error.

* Travis rebuild bump

* One more fix: replace hardcoded include paths with a PATH_SUFFIX to standard include paths

* Invert Windows preprocessor flag so it's only needed when using a static build.  This preserves compatibility with the previous system.

* Fix copy-paste error

* Update cmake modules from amber-cmake upstream, incorporate TryLinkLibrary into FindUSB1

* Fix missing include
2021-12-03 14:11:04 -05:00
Michael Ossmann
0f4f1addd1 libhackrf: document hackrf_transfer struct 2021-11-17 18:38:00 -07:00
Michael Ossmann
c8695e0a44 hackrf_sweep: correct -w (bin_width) minimum 2021-11-14 12:21:29 -07:00
Michael Ossmann
8a3547e71e hackrf_sweep: improve -w (bin_width) guidance 2021-11-14 12:05:29 -07:00
Michael Ossmann
9856452215 hackrf_sweep: eliminate -n option (num_samples)
The firmware has the capability to dwell on each frequency for a
configurable duration in sweep mode, but the hackrf_sweep host tool did
not behave correctly when asked to use a non-default dwell time. The
option has never worked properly, and it is not a feature anyone seems
to want.
2021-11-14 11:41:56 -07:00
Michael Ossmann
2775279fd0 hackrf_sweep: eliminate time stamp adjustment
We previously attempted to adjust the output time stamp according to the
sample rate and placement of the samples within the USB transfer data,
but the end result was a fixed time offset with respect to the time of
USB transfer completion. We are using only those samples closest to the
end of the transfer, so it makes sense to simply use the time the USB
transfer ends and not try to correct that fixed offset.

It may be possible in the future to have a more accurate time stamp
generated in firmware, but I don't think it is worth complicating the
host code with minor time adjustments until and unless firmware-based
time stamps become available.
2021-11-14 11:20:31 -07:00
Michael Ossmann
3589bc4ed3 Merge pull request #950 from miek/operacake-cleanup
Opera Cake CLI/API cleanup
2021-10-28 17:00:55 -06:00
Fabrice Fontaine
3e32f46c79 cmake/modules/FindFFTW.cmake: fix build without fftw3
Build on Linux fails if libfftw3 is not available since commit
a8c1fc92e9
which replaced
pkg_check_modules(FFTW REQUIRED fftw3f)
by
find_package(FFTW REQUIRED)

Fix this build failure by updating FindFFTW.cmake to check for fftw3f

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2021-10-15 23:42:03 +02:00
Mike Walters
f5a7132805 hackrf_operacake: make main options mutually exclusive
ref #930
2021-10-15 14:45:38 +01:00
Mike Walters
4ecbd5d2c9 hackrf_operacake: add option for default dwell time
This allows for usage like this:

  $ hackrf_operacake -m time -w 1e6 -t A1 -t A2 -t A3
  $ hackrf_transfer -r /dev/null -s 1e6

ref #930
2021-10-15 14:45:38 +01:00
Mike Walters
38ed075437 operacake: replace hackrf_set_operacake_ranges with hackrf_set_operacake_freq_ranges 2021-10-15 14:45:38 +01:00
Mike Walters
0e68be7771 hackrf_operacake: simplify frequency range parsing 2021-10-15 14:45:38 +01:00
Mike Walters
07a9dd73d8 hackrf_operacake: swap argument order for frequency-switching
ref #930
2021-10-15 14:45:38 +01:00
Mike Walters
f9b923fce2 hackrf_operacake: default to address 0
ref #930
2021-10-15 14:45:38 +01:00
Mike Walters
e41314f130 operacake: add API function to set port dwell times 2021-10-14 14:41:52 +01:00
Mike Walters
c50ebb1a36 operacake: add time switching mode 2021-10-14 14:41:52 +01:00
Mike Walters
790b5d35cf operacake: add get/set switching mode functions 2021-10-14 14:36:18 +01:00
Mike Walters
6aa64a80d5 hackrf_operacake: clarify output of list command
Now that addresses are in the range 0-7, this would previously output
"Operacakes found: 0" for the default board address. This is confusing
as it looks like it found no Opera Cakes.
2021-07-14 18:35:31 +01:00
Mike Walters
5e2e06b620 hackrf_info: display Opera Cake addresses in decimal
Fixes #899
2021-07-14 18:35:31 +01:00
Mike Walters
0293cf23db Opera Cake: use 0-7 instead of I2C addresses & bump USB API version 2021-07-14 18:35:31 +01:00
Clifford Heath
a9945ffaa3 Report amplitude once per second during receive (#890)
* Report amplitude once per second during receive

* Added missing M_LN10 for Windoze, fixed short frame detection for RSSI

* Tweaks to math expressions

* Tweaks to math expressions
2021-06-13 11:59:26 -06:00
Michael Ossmann
10b7d67ea5 Merge pull request #874 from metayan/sweeprate
hackrf_sweep: Calculate and show sweep rate for subsecond sweeps
2021-04-23 17:35:31 -06:00
Yan
7c14f876a0 hackrf_sweep: initialise sweep_rate
Thanks to dmaltsiniotis for spotting this.
2021-04-10 13:47:33 +02:00
Yan
90acbcff07 hackrf_sweep: Calculate and show sweep rate for subsecond sweeps 2021-04-08 22:46:42 +02:00
Demetri Maltsiniotis
e664321cc6 Adding call to _setmode for Windows only to specify binary stdout output piping. 2021-04-07 15:11:44 -05:00
Yan
ab4498f8ac hackrf_sweep: exit early from rx_callback if do_exit set
Sometimes, if a small frequency interval is scanned, the callback is
triggered even though we already have the number of sweeps we want, and
sweep_count gets increased, showing the wrong "Total sweeps".
2021-03-20 10:07:51 +01:00
Yan
4c46fc74b3 hackrf_sweep: speed up ending by removing unnecessary code
hackrf_stop_rx() is handled in hackrf_close(), so there seems to be no need
to call it separately.  Furthermore, if hackrf_stop() is called separately,
it causes hackrf_close() to take more than half a second longer.
2021-03-19 16:31:37 +01:00
Yan
2ef7995763 hackrf_sweep: flush output earlier
Gives listener access to complete data faster.
Otherwise the data might be delayed until the whole closing procedure is done.
2021-03-19 16:29:21 +01:00
Michael Ossmann
e6eb4ba29b Merge pull request #848 from mossmann/pre-release
Pre release
2021-03-18 14:36:50 -06:00
Mike Walters
5361b3a7f4 hackrf_sweep: switch main loop timing back to 1Hz
fixes #850
fixes #851
2021-03-18 19:48:53 +00:00
Michael Ossmann
2a8ed4ec59 increment .so/.pc version number to 0.6 2021-03-17 21:44:34 -06:00
Michael Ossmann
2ca991e1df Flush output streams. Do not fclose stdout/stdin. 2021-01-27 12:12:45 -07:00
Michael Ossmann
a6fa7876cb Give descriptive names to streams.
They were previously given the confusing name of fd even though they are
not file descriptors.
2021-01-27 11:59:29 -07:00
Michael Ossmann
8fead43cf2 Merge pull request #748 from ggatis/patch-1
Update hackrf_sweep.c
2021-01-27 11:38:45 -07:00
adrian chadd
61a06b904d Handle hackrf_close() being called without TX or RX being started.
My previous commits didn't handle the specific case of hackrf_close()
being called without the transfers being active.

In this instance the transfers haven't been setup, so calling
cancel_transfers() returned an error.

Instead:

* refactor out the tx/rx stop command from canceling transfers
* send the tx/rx stop command without canceling transfers, since ..
* ... we can then destroy the transfer thread.

I may also need to put an explicit cancel_transfers() before the
call to send the tx/rx stop commands; I'll look at doing that
in a subsequent commit.
2020-12-10 15:57:54 -08:00
Adrian Chadd
b4ea51a36b add 10ms sleep after stop
This seems to stop consumers that are doing quick back to back stop/start
(eg gqrx changing decode mode / filter bandwidth) from hanging the
device.

I now don't have any weird hangs on hackrf with gqrx/freebsd/libusb!

When things hang it isn't erroring out in any way; it just doesn't
start receive.  It doesn't look like a libusb issue; I'd have to get
some USB bus sniffing to see what's going on behind the scenes.
2020-11-09 10:40:44 -08:00
Adrian Chadd
9a278d267a Fix streaming hangs in consumers
* Update device->streaming to reflect whether we're streaming data,
  rather than just whether the streaming thread is active.
  The streaming thread is now always active!
2020-11-09 09:42:34 -08:00
Adrian Chadd
0961a76f26 Fix libusb usage for at least freebsd around the worker thread and transfer cancellation
On at least freebsd-13 trying to cancel a transfer whilst the libusb thread
is not running results in the transfers not completing cancellation.
The next time they're attempted to be re-added the libusb code thinks
they're still active, and returns BUSY on the buffers.

This causes gqrx to error out when one makes DSP changes or stops/starts it.
You have to restart gqrx to fix it.

After digging into it a bit, the libusb code expects that you're actively
running the main loop in order to have some deferred actions run in the
context of said main loop thread.  This includes processing cancelled
transfers - the callbacks have to be run (if they exist) before the
buffers are properly cancelled and have their tracking metadata (a couple of
private pointers and state) removed from inside of libusb.

This patch does the following:

* separate out adding and cancelling transfers from the libusb worker thread
  create/destroy path
* create the libusb worker thread when opening the device
* destroy the libusb worker thread when closing the device
* only add and cancel transfers when starting and stopping tx/rx
* handle cancelled transfers gracefully in the USB callback

Whilst here, also make the libusb device memory zeroed by using
calloc instead of malloc.

This fixes all of the weird libusb related buffer management problems
on FreeBSD.
2020-11-08 21:38:39 -08:00
Michael Ossmann
451873d616 Merge pull request #716 from Jakub6/master
fix _FILE_OFFSET_BITS 64 position in hackrf_transfer.c
2020-07-26 07:39:17 -06:00
ggatis
38f6d4c828 Update hackrf_sweep.c
change if ( fd != NULL ) to if ( ( fd != NULL ) && ( fd != stdout ) )
before fclose( fd );
2020-06-16 13:55:50 +03:00
jaj
a9f6cbc367 fix _FILE_OFFSET_BITS 64 position in hackrf_transfer.c (must be included before <sys/stat.h>) 2020-03-16 13:16:15 +01:00
Mike Walters
1c091a10bf libhackrf: Zero-out initial transfer buffers 2020-02-12 18:53:59 +00:00
Michael Ossmann
c0aed2edb7 firmware: clean up transceiver modes 2020-02-11 16:59:59 +00:00
Mike Walters
4aac303480 Add option to disable HackRF UI
Fixes #608
2020-01-22 21:23:30 +00:00
Michael Ossmann
ecd82e81c1 remove specific sample rate recommendations
HackRF One supports arbitrary sample rates from 2 Msps to 20 Msps.  In
early development we had ideas about preferred sample rates that we no
longer consider valid.
2020-01-22 06:39:08 -07:00
Michael Ossmann
8ff56c615f Merge pull request #661 from mgesteiro/hackrf_transfer-fix
FIXED: remove garbage at the end when capturing to stdout ('-r -')
2020-01-06 16:43:14 -07:00
Matioupi
1442014a80 Modified hackrf_stop_tx and hackrf_stop_rx to first join the transfer thread
before setting the receiver to OFF mode (cf. issue #650)
2020-01-06 16:37:05 -07:00
Michael Ossmann
208fae7538 Merge pull request #645 from jboone/master
Sync up PortaPack UI changes.
2020-01-06 16:31:28 -07:00
Michael Ossmann
1569737109 Merge pull request #607 from dominicgs/portapack_ui_opera_cake_coexistence
Allow portapack and opera cake to coexist and still enable the PP UI
2020-01-06 16:28:58 -07:00
Mike Walters
dcb98f7f51 Get FFTW library dir 2019-12-10 18:46:51 +00:00