Commit Graph

65 Commits

Author SHA1 Message Date
Clayton Smith 159885f9e6 Replace boost::shared_ptr with std::shared_ptr
Signed-off-by: Eric Wild <ewild@sysmocom.de>
2021-01-18 21:15:57 +01:00
Clayton Smith bc629b03fe hackrf: fix bandwidth setting
The T/R switching code added in ae2253c516
fails to set custom filter bandwidths because it sets bandwidth and
sample rate in the wrong order. As noted in the documentation for
hackrf_set_sample_rate: "If you want to override the baseband filter
selection, you must do so after setting the sample rate."

To solve this problem I moved the set_bandwidth call after
set_sample_rate. It was also necessary to skip the call if a custom
bandwidth was not requested.

Signed-off-by: Eric Wild <ewild@sysmocom.de>
2021-01-04 22:27:53 +01:00
Adrian Chadd 9b386707d8 Fix hackrf receive hangs by checking before each lock wait
Fix receive path hangs if another thread closes down the hackrf
receive whilst this buffer receive function is waiting to be
woken up.

Now:

* Sleep for up to 100ms each time waiting for the cond to be kicked;
* Check whether streaming is still enabled each time rather than
  only when the function is entered.

This fixes hangs where consumers like gqrx via gnuradio
will do a stop_rx/start_rx very quickly to change something, and
the buffer receive path is waiting for a buffer.

Signed-off-by: Eric Wild <ewild@sysmocom.de>
2020-12-18 13:22:24 +01:00
Mike Walters bd668e97b6 HackRF: fix hackrf_source signedness
The LUT changes in 2e7d343fed inadvertently started interpreting samples
as unsigned. This change puts it back to signed (and fixes an outdated
comment).

Signed-off-by: Eric Wild <ewild@sysmocom.de>
2020-08-09 14:48:49 +02:00
Eric Wild dadabeceaf cmake: actually make linking work
Appending to lists from subdirs does not work as expected, so work
around that to allow collecting the necessary libs.
2020-08-03 02:20:16 +02:00
Wim Lewis 2e7d343fed HackRF: convert _lut to float[] to reduce size by a factor of 256
Similar to commit 33a8d1c for RTL-SDR, this uses two lookups in a
256-element LUT instead of one lookup in a 65536-element LUT, which
saves a bit of CPU cache. It also eliminates a dependency on the
host's byte ordering.

Signed-off-by: Eric Wild <ewild@sysmocom.de>
2020-08-03 01:20:52 +02:00
Clayton Smith 52fcb0935f A lot of Boost functionality is available in C++11. Since GNU Radio is moving away from Boost, it probably makes sense to do so in gr-osmosdr as well.
This change removes all usage of boost::mutex,
boost::mutex::scoped_lock, boost::unique_lock, and
boost::condition_variable. It also removes usage of boost::shared_ptr
and boost::weak_ptr outside of block definitions (which must continue to
use Boost until GNU Radio 3.9).

Signed-off-by: Eric Wild <ewild@sysmocom.de>
2020-08-02 23:52:25 +02:00
Piotr Krysik 8cf6840da1 cmake: Go back CMake min ver. 3.8 by removing need for CMP0079
CMake 3.13 is not present in older (~2 years old)
Linux distributions and GNU Radio requires min CMake
version 3.8.

All that is needed in order to avoid bumping CMake version
is to not use 'target_link_libraries' in subdirectories.
Here this is done by creating a list of needed
libraries and adding them for linking at the end (like
it was done in gr-osmosdr before porting to GNU Radio 3.8).

One thing that is lost here is 'PRIVATE' statement in case
of FCD libraries linking.

Signed-off-by: Eric Wild <ewild@sysmocom.de>
2020-08-02 22:17:05 +02:00
Clayton Smith 4d1c05e84b hackrf: replace boost::assign with C++11
Since GNU Radio is gradually replacing Boost with C++11, it seemed worth
doing that for the HackRF blocks I was working on. This change removes
all usage of boost::assign.

From: Clayton Smith <argilo@gmail.com>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2020-02-16 09:52:00 +01:00
Clayton Smith ae2253c516 hackrf: allow transmit/receive switching
To allow switching between transmit and receive mode within a single
flow graph, I've followed the model used by the BladeRF: I factored
common code into hackrf_common.cc and hackrf_common.h, and created a
"_devs" map there to keep track of which devices have been previously
opened. Shared pointers are used to track how many source & sink blocks
are using a particular device.

Because some properties (center frequency, sample rate, bandwidth, RF
amplifier state, bias tee) are shared between receive and transmit, the
blocks defer setting these until receiving or transmitting is started.
That way a source and sink can safely use different values for these
properties, and the correct values are set during T/R switching.

Because the HackRF driver and/or hardware does not seem to fully
transmit all samples sent to it, the code adds some silence to the end
of transmissions to ensure all samples are transmitted.

I've also replaced boost with C++11 code where possible.

From: Clayton Smith <argilo@gmail.com>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2020-02-16 09:52:00 +01:00
Sylvain Munaut 5d59e56ff9 build: Update build system to GR 3.8 standards
Part of GNURadio 3.8 migration

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2020-02-16 09:52:00 +01:00
Sylvain Munaut 982945a477 build: Update CMakeLists.txt copyright header
Part of GNURadio 3.8 migration

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2020-02-16 09:51:37 +01:00
Dimitri Stolnikov 20a5fd1a68 hackrf: correct gcc6 warnings 2017-02-27 23:01:51 +01:00
Jiří Pinkava ac15e7897b do not check for NULL before calling free 2016-01-10 22:48:31 +01:00
Dimitri Stolnikov 2ca720cfee hackrf: change hackrf i/o from default char to explicit int8_t
original patch provided via github by Dirk Grunwald
2015-12-07 20:37:32 +01:00
Dimitri Stolnikov 69ec75a0b4 hackrf: since devicecount is signed, make comparisons signed as well 2015-12-07 20:27:02 +01:00
Dimitri Stolnikov 46e95395e0 cmake: move check for hackrf_device_list to hackrf subdirectory 2015-06-06 22:01:33 +02:00
Dimitri Stolnikov f33f30815a hackrf: use #ifdef just like in hackrf_sink_c 2015-06-01 22:24:32 +02:00
Heikki Hannikainen dd6690b6ca hackrf: Add cmake magic to figure out if multiple devices support is available in libhackrf, so that backwards compatibility with old libhackrf is maintained.
Signed-off-by: Heikki Hannikainen <hessu@hes.iki.fi>
2015-06-01 22:01:02 +02:00
Heikki Hannikainen 254e1b1981 hackrf_source: adjust error message
Signed-off-by: Heikki Hannikainen <hessu@hes.iki.fi>
2015-06-01 22:01:02 +02:00
Heikki Hannikainen e847176f3e hackrf_source: Support selecting device with index number (hackrf=0)
Signed-off-by: Heikki Hannikainen <hessu@hes.iki.fi>
2015-06-01 22:01:02 +02:00
Heikki Hannikainen dd6536757a hackrf_sink_c: device enumeration
Signed-off-by: Heikki Hannikainen <hessu@hes.iki.fi>
2015-06-01 22:01:02 +02:00
Heikki Hannikainen 485b02e615 hackrf device enumeration: Use only 6 characters of serial (should be unique per user?) and append it in device name
Signed-off-by: Heikki Hannikainen <hessu@hes.iki.fi>
2015-06-01 22:01:02 +02:00
Heikki Hannikainen 592a814bdb hackrf_source: Truncate serial numbers to 16 chars when enumerating, parse USB board IDs correctly
Signed-off-by: Heikki Hannikainen <hessu@hes.iki.fi>
2015-06-01 22:01:01 +02:00
Heikki Hannikainen 8e6ecd0644 hackrf_source: attempt device enumeration with hackrf_device_list
Signed-off-by: Heikki Hannikainen <hessu@hes.iki.fi>
2015-06-01 22:01:01 +02:00
Heikki Hannikainen 69181b0e85 hackrf_sink: support hackrf_open_by_serial
Signed-off-by: Heikki Hannikainen <hessu@hes.iki.fi>
2015-06-01 22:01:01 +02:00
Heikki Hannikainen 5dca656745 style update to match surroundings
Signed-off-by: Heikki Hannikainen <hessu@hes.iki.fi>
2015-06-01 22:01:01 +02:00
Heikki Hannikainen d4387f436d Require hackrf argument to have a non-zero-length value to trigger serial number search
Signed-off-by: Heikki Hannikainen <hessu@hes.iki.fi>
2015-06-01 22:01:01 +02:00
Heikki Hannikainen 9595b044b6 hackrf: support for hackrf_open_by_serial in hackrf source
Signed-off-by: Heikki Hannikainen <hessu@hes.iki.fi>
2015-06-01 22:01:01 +02:00
Dimitri Stolnikov 5943919828 hackrf: introduce bias=0|1 and bias_tx=0|1 parameters
... to support antenna/phantom power via a new device argument "bias"
(to match Airspy's existing bias power syntax). 0=disable and 1=enable.
I also added a device argument to control bias power at transmit time. I
named this option differently - "bias_tx" - to avoid accidentally
enabling bias power in transmit mode when an LNA may be attached in an
input amplifier configuration.

Original patch provided by Brad Hein
2015-05-27 23:55:00 +02:00
Dimitri Stolnikov 42c66fdd70 hackrf: update copyright for SSE/AVX routines 2014-10-21 22:14:52 +02:00
Dimitri Stolnikov 39230788d7 hackrf: disable AMP gain stage by default to protect it from damage
patch proivided by Paul Connolly
2014-10-21 22:13:08 +02:00
Dimitri Stolnikov ab582493dd hackrf: extend frequency range down to BW/2 2014-08-25 23:02:39 +02:00
Dimitri Stolnikov 3afecd6adf hackrf: extend frequency range down to 10MHz 2014-08-14 23:16:31 +02:00
Hoernchen cc083037fe hackrf: signed samples, following commit fd77cfe8a6 2014-02-20 19:47:20 +01:00
Dimitri Stolnikov eb76e35689 osmosdr/rtl/miri/hackrf: use 15 buffers by default
folowing rtl-sdr commit 89f73b183f2dac9c0dd75beca4cf2f77f20c4a36

So far we had 32 * 256KB which was a bit overkill, 15 are more than
enough.

15 was chosen instead of 16 because at least on Linux there seems to be
a system-wide limit of 63 transfers (when they are 256KB large), so 4
dongles can be used on a single machine without lowering the default
transfer number.
2014-02-11 20:52:56 +01:00
Dimitri Stolnikov a71fbeeaa5 hackrf: implement device discovery
Unfortunately libhackrf still doesn't offer a way to enumerate devices
*or* to open a specific device by index or it's serial number. Thus we
have implemented a rather hack-ish way to detect the presence of a
device by trying to open it and closing right after that.
2013-10-25 23:36:32 +02:00
Dimitri Stolnikov c1fb07bca7 hackrf: enable AMP gain stage by default 2013-09-28 13:49:09 +02:00
Dimitri Stolnikov b3bbe0935e hackrf: don't set automatic bandwidth on samplerate change
automatic bandwidth selection may be triggered by calling
set_bandwidth(0) after changing the sample rate
2013-09-28 13:49:00 +02:00
Dimitri Stolnikov 656a9a014f hackrf: select narrower filters in auto bw mode to prevent aliasing 2013-06-09 13:10:16 +02:00
Dimitri Stolnikov ef37d1caae hackrf: use new sample rate function introduced in libhackrf b892bc34ad 2013-06-09 09:01:00 +02:00
Dimitri Stolnikov 40fb250e8f hackrf: add fractional sample rate support introduced in libhackrf
d9c46cbdac
2013-06-07 22:32:21 +02:00
Dimitri Stolnikov 40483d09c8 hackrf: add human readable error prints for all libhackrf funcs 2013-06-07 21:43:52 +02:00
Dimitri Stolnikov 7a129238b7 hackrf: set the default sample rate to 10M
this prevents a regression with early firmware who did not have 8M rate
but 5M instead. they both had 10M, so we use this as default.
2013-06-05 19:20:08 +02:00
Dimitri Stolnikov e17ee6d96e hackrf: change out-of-spec rate 5e6 to 8e6 default 2013-06-03 22:01:20 +02:00
Dimitri Stolnikov 40ca42013b hackrf: disable start/stop as it has caused lock-ups 2013-06-02 15:53:45 +02:00
Dimitri Stolnikov cf06b3caef hackrf: migrate to gain API introduced in libhackrf b5f275abc5 2013-06-02 15:29:19 +02:00
Dimitri Stolnikov 7e55cb9224 introduce osmosdr namespace, remove _c suffix
- the namespace conversion adopts the common gnuradio coding guidelines
- suffix removal is a preparation to support 8/16 bit complex data types
2013-05-30 16:14:22 +02:00
Dimitri Stolnikov 3e6a24e5d9 convert to gnuradio 3.7 interface 2013-05-29 22:34:40 +02:00
Dimitri Stolnikov ceb14f0f13 hackrf: enable buffers argument for the source block 2013-05-26 13:04:06 +02:00