diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2024-10-08 15:25:45 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2024-10-08 15:25:45 +0200 |
commit | 1d83a2b247f8e83bbce802a272ffa165bbc6333f (patch) | |
tree | 116a24ec03eabfef4bd2dd73efeb97ecaad57d67 /src/output/UHD.cpp | |
parent | 8736f6160aeafe7a177cb6143fea80157e174e52 (diff) | |
download | dabmod-1d83a2b247f8e83bbce802a272ffa165bbc6333f.tar.gz dabmod-1d83a2b247f8e83bbce802a272ffa165bbc6333f.tar.bz2 dabmod-1d83a2b247f8e83bbce802a272ffa165bbc6333f.zip |
Get fixed_point working with USRP
Diffstat (limited to 'src/output/UHD.cpp')
-rw-r--r-- | src/output/UHD.cpp | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/output/UHD.cpp b/src/output/UHD.cpp index e097692..b30f9e1 100644 --- a/src/output/UHD.cpp +++ b/src/output/UHD.cpp @@ -31,10 +31,7 @@ //#define MDEBUG(fmt, args...) fprintf(LOG, fmt , ## args) #define MDEBUG(fmt, args...) -#include "PcDebug.h" #include "Log.h" -#include "RemoteControl.h" -#include "Utils.h" #include <thread> #include <iomanip> @@ -52,14 +49,12 @@ # include <uhd/utils/thread_priority.hpp> #endif - -#include <cmath> #include <iostream> -#include <assert.h> +#include <cmath> +#include <cassert> #include <stdexcept> -#include <stdio.h> +#include <cstdio> #include <time.h> -#include <errno.h> #include <unistd.h> #include <pthread.h> @@ -235,7 +230,8 @@ UHD::UHD(SDRDeviceConfig& config) : m_usrp->set_rx_gain(m_conf.rxgain); etiLog.log(debug, "OutputUHD:Actual RX Gain: %f", m_usrp->get_rx_gain()); - const uhd::stream_args_t stream_args("fc32"); //complex floats + const uhd::stream_args_t stream_args( + m_conf.fixedPoint ? "sc16" : "fc32"); m_rx_stream = m_usrp->get_rx_stream(stream_args); m_tx_stream = m_usrp->get_tx_stream(stream_args); @@ -319,8 +315,9 @@ double UHD::get_bandwidth(void) const void UHD::transmit_frame(struct FrameData&& frame) { const double tx_timeout = 20.0; - const size_t sizeIn = frame.buf.size() / sizeof(complexf); - const complexf* in_data = reinterpret_cast<const complexf*>(&frame.buf[0]); + + const size_t sample_size = m_conf.fixedPoint ? (2 * sizeof(int16_t)) : sizeof(complexf); + const size_t sizeIn = frame.buf.size() / sample_size; uhd::tx_metadata_t md_tx; @@ -353,9 +350,9 @@ void UHD::transmit_frame(struct FrameData&& frame) samps_to_send <= usrp_max_num_samps ); m_require_timestamp_refresh = false; - //send a single packet + // send a single packet size_t num_tx_samps = m_tx_stream->send( - &in_data[num_acc_samps], + frame.buf.data() + sample_size * num_acc_samps, samps_to_send, md_tx, tx_timeout); etiLog.log(trace, "UHD,sent %zu of %zu", num_tx_samps, samps_to_send); |