146 Commits

Author SHA1 Message Date
Simon Berger
c0181b46d1 hackrf-tools: handle ctrl+break signal on windows 2024-10-18 14:32:56 +00:00
Michael Ossmann
3d687a20fd increase forceable IF range to 2000-3000 MHz 2022-12-23 06:06:22 -05:00
Michael Ossmann
86c1d8ce6e restrict IF to 2170-2740 MHz 2022-12-09 09:12:37 -05:00
Michael Ossmann
0e8b941897 hackrf_transfer: fix function name in debug output 2022-09-24 14:23:29 -04:00
Michael Ossmann
06b9d7bee0 Clean up source code copyright notices. 2022-09-23 14:46:52 -04:00
Michael Ossmann
45504ff397 Don't repeat file that can't advance its position.
This avoids a confusing condition when hackrf_transfer is reading from
stdin with -R in which it does not repeat previous data but repeatedly
restarts reading new data after the user types Ctrl-D to indicate EOF.

The -R option should repeat previous data or should do nothing if the
input file cannot be rewound.
2022-09-23 06:48:01 -04:00
Michael Ossmann
8fbaf1336c Improve handling of file read results. 2022-09-23 06:47:54 -04:00
Martin Ling
db33e1bdaf Revert rename of byte_count now that we only have one count. 2022-09-23 05:19:29 -04:00
Martin Ling
0becbc6b4a Indicate success or failure to flush callback. 2022-09-23 05:19:29 -04:00
Martin Ling
c089bb0b88 Fix handling of EOF and error conditions after fread. 2022-09-23 05:19:29 -04:00
Martin Ling
eae7049284 Fix empty report when TX ends soon after the last report. 2022-09-23 05:19:29 -04:00
Martin Ling
14093fe73b Provide a callback for completion of a TX transfer. 2022-09-23 05:19:29 -04:00
Martin Ling
2448796e35 Handle failures in fread from TX callback. 2022-09-23 05:19:29 -04:00
Martin Ling
cb8fc333aa Fix inaccurate error message when TX completes near a 1 second boundary. 2022-09-23 05:19:29 -04:00
Martin Ling
98faa5429f Fix inaccurate statistics in hackrf_transfer. 2022-09-23 05:19:29 -04:00
Martin Ling
b872647e97 Provide a callback for TX flush, rather than a wait function. 2022-09-23 05:19:29 -04:00
Michael Ossmann
1167f49b7f hackrf_transfer: refer to triggers as "triggers" 2022-09-21 10:37:40 -04:00
Michael Ossmann
f4202d1163 hackrf_transfer: Don't skip preload stats in RX
Fixes a bug introduced in 8a9af7a: Statistics skipped for initial
buffers not only when preloaded in TX mode but also in RX mode with no
preloading.

The total bytes transferred may appear inflated in RX mode when
receiving a small number of samples with -n, but the stats represent
data transferred over USB, some of which may have been discarded by the
host.
2022-09-18 13:27:51 -04:00
Michael Ossmann
82ecfce414 hackrf_transfer: simplify hardware sync mode logic
The -H option now requires no argument.
2022-09-18 05:49:03 -04:00
Michael Ossmann
9181cbe049 hackrf_transfer: send signal to own PID
Instead of sending a signal to the process group, get our own process ID
and send the signal to it. This fixes a bug that prevented termination
when called from a script.
2022-09-18 05:07:09 -04:00
Martin Ling
55fdddd81e Merge remote-tracking branch 'origin/master' into tx-transfer-sizing 2022-09-15 15:32:20 +01:00
Martin Ling
09c6030ec9 Start TX/RX in hackrf_transfer after all other requests.
This avoids glitches and lost samples at the start of a transmission.
2022-09-15 09:51:11 +01:00
Martin Ling
f1e34b7cea Correct the calculation of dBfs signal level.
dBFS is defined in AES Standard AES17-1998, IEC 61606, and ITU-T Recs.
P.381 and P.382, such that the RMS value of a full-scale sine wave is
designated 0 dBFS.

A full scale sine wave on HackRF has the range -127 to 127.

We calculate the full scale ratio relative to a signal in which both I
and Q are held at 127. This represents a signal with sqrt(2) times
the amplitude, and thus twice the power, of a full scale sine wave.

Therefore to obtain dBfs by the above definition, we add 3dB.
2022-09-14 18:21:07 +01:00
Martin Ling
66fa76c550 In CW mode, set only the I component to the specified amplitude. 2022-09-14 18:14:59 +01:00
Martin Ling
d5d2b09fe8 Restrict CW mode amplitude to 127. 2022-09-14 18:14:23 +01:00
Martin Ling
f2d00adab8 Add commentary to TX callback. 2022-09-14 15:55:07 +01:00
Martin Ling
e38534b99d Don't return -1 from the TX callback that provides the last data. 2022-09-14 15:55:07 +01:00
Martin Ling
5ad08cfd96 Set valid_length correctly in hackrf_transfer TX callback. 2022-09-14 15:55:04 +01:00
Martin Ling
9905e960a4 Rearrange to avoid duplicating sample limit return path. 2022-09-14 15:16:18 +01:00
Martin Ling
16f93d9b27 Move duplicated code to one place. 2022-09-14 15:15:34 +01:00
Martin Ling
29787cd291 Clarify variables used in TX callback.
The power measurement depends on the number of bytes that were valid
from the previous use of the transfer buffer.

The number of bytes to be read to fill the next transfer, is the full
size of the buffer.
2022-09-14 15:10:13 +01:00
Michael Ossmann
fdfe310f9a Merge pull request #1139 from martinling/tx-flush
Support flushing the device TX buffer before ending transmission
2022-09-14 05:45:40 -04:00
Martin Ling
7650236839 Flush buffer when CW mode is used with -n. 2022-09-12 16:50:53 +01:00
Martin Ling
0142ae6da9 Don't await buffer flush if interrupted by Ctrl-C. 2022-09-12 16:32:11 +01:00
Michael Ossmann
8a9af7a1ad hackrf_transfer: report on only actual transfers
The statistics reported to the user now reflect only completed USB
transfers and do not include information about the empty buffers that
are preloaded with data at the start of a TX operation.
2022-09-09 16:32:07 -04:00
Michael Ossmann
e7b19ef2c2 hackrf_transfer: accept CW amplitude up to 128 2022-09-09 05:17:28 -04:00
Michael Ossmann
755ca960e5 hackrf_transfer: report power, not amplitude
improve accuracy and reliability of digital signal power measurement
2022-09-09 05:15:15 -04:00
Martin Ling
8f60e6b66f Wait for TX buffer flush at end of hackrf_transfer. 2022-08-24 23:48:24 +01:00
Martin Ling
9b6a0259a7 Remove message when rewinding input file.
For small input files this may be printed a very large number of times.
2022-08-23 09:30:04 +01:00
Martin Ling
0c35cff05b In repeat mode, rewind file as many times as needed to fill buffer.
Fixes #720.
2022-08-23 09:30:04 +01:00
Martin Ling
06a0c2b189 One more early return to simplify TX callback. 2022-08-23 09:30:02 +01:00
Martin Ling
85a86b8baa Use more early returns to further simplify callbacks. 2022-08-23 09:29:13 +01:00
Martin Ling
bcaebc00c3 Use some early returns to reduce deeply indented callbacks. 2022-08-23 09:26:00 +01:00
Martin Ling
344af5094b Merge pull request #1131 from martinling/hackrf-transfer-validation
Additional argument validation for hackrf_transfer
2022-08-23 08:57:17 +01:00
Michael Ossmann
c703a72ac0 add parentheses to avoid compiler warning
avoids a warning from -Wparentheses
2022-08-23 08:44:29 +01:00
Martin Ling
a09e9a20ed Overhaul timing in hackrf_transfer.
Rather than using sleep() for 1s at a time, set up an interval timer
that will fire once per second, and wait in the main loop for either
this or some other event.

On POSIX, the timing is set up with setitimer(), which generates a
SIGALRM signal each time the timer fires. The main loop runs pause() to
wait for any signal.

On Windows, the timing is set up using CreateWaitableTimer, which
provides an event handle that is set each time the timer fires. The main
loop runs WaitForMultipleObjects() to wait on this and an interrupt
event.

The TX and RX callbacks can now stop the main loop immediately when they
stop streaming. This fixes #1019.
2022-08-17 13:05:03 +01:00
Martin Ling
eeaaaf3b9b Make use of Win32 functions conditional on _WIN32, not _MSC_VER.
Using _MSC_VER here means that the choice of signal() versus
SetConsoleCtrlHandler depends on the compiler being used, rather
than the OS being targeted. When built with MinGW rather than MSVC,
this happens to work because MinGW's signal emulation is used, but
that emulation is quite limited.

Instead, be consistent and use the Win32 API when building for that
platform, regardless of compiler.

Note that if building for Cygwin, _WIN32 is not defined and POSIX
APIs are used.
2022-08-17 12:54:22 +01:00
Martin Ling
e88a0387cb Extend force option to frequency ranges outside 1MHz-6GHz. 2022-08-15 21:47:49 +01:00
Martin Ling
2e1f55c2d5 Add hackrf_transfer -F option to force unsupported sample rates. 2022-08-15 21:47:49 +01:00
Martin Ling
8c12fa6007 Validate sample rates passed to hackrf_transfer. 2022-08-15 21:47:42 +01:00