From bd668e97b632e68a131df738cc5aee49fc9df3e4 Mon Sep 17 00:00:00 2001 From: Mike Walters Date: Wed, 5 Aug 2020 21:06:25 +0100 Subject: [PATCH] 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 --- lib/hackrf/hackrf_common.h | 2 +- lib/hackrf/hackrf_source_c.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/hackrf/hackrf_common.h b/lib/hackrf/hackrf_common.h index ea093b9..bb553c3 100644 --- a/lib/hackrf/hackrf_common.h +++ b/lib/hackrf/hackrf_common.h @@ -34,7 +34,7 @@ #define BUF_LEN (16 * 32 * 512) /* must be multiple of 512 */ #define BUF_NUM 15 -#define BYTES_PER_SAMPLE 2 /* HackRF device produces/consumes 8 bit unsigned IQ data */ +#define BYTES_PER_SAMPLE 2 /* HackRF device produces/consumes 8 bit signed IQ data */ #define HACKRF_FORMAT_ERROR(ret, msg) \ boost::str( boost::format(msg " (%1%) %2%") \ diff --git a/lib/hackrf/hackrf_source_c.cc b/lib/hackrf/hackrf_source_c.cc index 4f2fb78..662d04a 100644 --- a/lib/hackrf/hackrf_source_c.cc +++ b/lib/hackrf/hackrf_source_c.cc @@ -88,7 +88,7 @@ hackrf_source_c::hackrf_source_c (const std::string &args) // create a lookup table for gr_complex values for (unsigned int i = 0; i <= 0xff; i++) { - _lut.push_back( float(i) * (1.0f/128.0f) ); + _lut.push_back( float(int8_t(i)) * (1.0f/128.0f) ); } if ( BUF_NUM != _buf_num || BUF_LEN != _buf_len ) {