Removed UHD source build and used versioned binary instead

This commit is contained in:
30hours 2024-01-14 12:05:58 +00:00
parent 3714d8e347
commit 068ae901f1
2 changed files with 30 additions and 41 deletions

View file

@ -3,13 +3,14 @@ LABEL maintainer="30hours <nathan@30hours.dev>"
WORKDIR /blah2
ADD lib lib
RUN apt-get update \
&& apt-get install -y g++ make cmake git curl zip unzip doxygen graphviz \
RUN apt-get update && apt-get install -y software-properties-common \
&& apt-add-repository ppa:ettusresearch/uhd \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y \
g++ make cmake git curl zip unzip doxygen graphviz \
libfftw3-dev pkg-config gfortran \
# UHD api dependencies
autoconf automake build-essential ccache cpufrequtils ethtool inetutils-tools \
libboost-all-dev libncurses5 libncurses5-dev libusb-1.0-0 libusb-1.0-0-dev libusb-dev python3-dev \
python3-mako python3-numpy python3-requests python3-scipy python3-setuptools python3-ruamel.yaml \
libuhd-dev=4.6.0.0-0ubuntu1~jammy1 \
uhd-host=4.6.0.0-0ubuntu1~jammy1 \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
@ -31,15 +32,7 @@ RUN chmod +x /blah2/lib/sdrplay-3.0.7/SDRplay_RSP_API-Linux-3.07.1.run \
&& ldconfig
# install UHD API
RUN git clone -b v4.6.0.0 --depth 1 https://github.com/EttusResearch/uhd /opt/uhd \
&& mkdir -p /opt/uhd/host/build && cd /opt/uhd/host/build \
&& cmake -DCMAKE_INSTALL_PREFIX=/opt/uhd -DENABLE_PYTHON_API=OFF \
-DENABLE_EXAMPLES=OFF -DENABLE_TESTS=OFF -DENABLE_USRP1=OFF \
-DENABLE_USRP2=OFF -DENABLE_OCTOCLOCK=OFF \
-DENABLE_MANUAL=OFF -DENABLE_DOXYGEN=OFF -DENABLE_MAN_PAGES=OFF \
-DENABLE_DPDK=OFF ../ && make && make install && ldconfig
ENV LD_LIBRARY_PATH=/opt/uhd/lib:$LD_LIBRARY_PATH
RUN /opt/uhd/lib/uhd/utils/uhd_images_downloader.py
RUN uhd_images_downloader
FROM blah2_env as blah2
LABEL maintainer="30hours <nathan@30hours.dev>"

View file

@ -9,6 +9,7 @@
#include <time.h>
#include <unistd.h>
#include <iostream>
#include <vector>
#include <uhd/usrp/multi_usrp.hpp>
#include <complex>
@ -38,20 +39,20 @@ void Usrp::stop()
void Usrp::process(IqData *buffer1, IqData *buffer2)
{
// tmp vars
std::string address = "localhost";
std::string subdev = "A:A A:B";
std::vector<std::string> antenna = {"RX2", "RX2"};
std::vector<double> gain = {20.0, 20.0};
// create a USRP object
uhd::usrp::multi_usrp::sptr usrp =
uhd::usrp::multi_usrp::make("localhost");
uhd::usrp::multi_usrp::make(address);
usrp->set_rx_subdev_spec(uhd::usrp::subdev_spec_t("A:A A:B"), 0);
//usrp->set_rx_subdev_spec(uhd::usrp::subdev_spec_t("A:B"), 1);
usrp->set_rx_subdev_spec(uhd::usrp::subdev_spec_t(subdev), 0);
usrp->set_rx_antenna ("RX2", 0);
usrp->set_rx_antenna ("RX2", 1);
std::cout << "testy " << std::endl;
std::cout << usrp->get_rx_subdev_name(0) << std::endl;
std::cout << usrp->get_rx_antenna(0) << std::endl;
std::cout << usrp->get_rx_antenna(1) << std::endl;
usrp->set_rx_antenna(antenna[0], 0);
usrp->set_rx_antenna(antenna[1], 1);
// set sample rate across all channels
usrp->set_rx_rate((double(fs)));
@ -62,9 +63,8 @@ void Usrp::process(IqData *buffer1, IqData *buffer2)
usrp->set_rx_freq(centerFrequency, 1);
// set the gain
double gain = 20.0; // Replace with your desired gain
usrp->set_rx_gain(gain, 0);
usrp->set_rx_gain(gain, 1);
usrp->set_rx_gain(gain[0], 0);
usrp->set_rx_gain(gain[1], 1);
// create a receive streamer
uhd::stream_args_t streamArgs("fc32", "sc16");
@ -84,7 +84,6 @@ void Usrp::process(IqData *buffer1, IqData *buffer2)
// setup stream
uhd::rx_metadata_t metadata;
uhd::stream_cmd_t streamCmd = uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS;
//streamCmd.stream_now = rxStreamer->get_num_channels() == 1;
streamCmd.stream_now = false;
streamCmd.time_spec = usrp->get_time_now() + uhd::time_spec_t(0.05);
rxStreamer->issue_stream_cmd(streamCmd);
@ -92,25 +91,22 @@ void Usrp::process(IqData *buffer1, IqData *buffer2)
while(true)
{
// Receive samples
size_t numReceived1 = rxStreamer->recv(buff_ptrs, samps_per_buff, metadata);
size_t nReceived = rxStreamer->recv(buff_ptrs, samps_per_buff, metadata);
// Check for errors
// print errors
if (metadata.error_code != uhd::rx_metadata_t::ERROR_CODE_NONE) {
std::cerr << "Error during reception: " << metadata.strerror() << std::endl;
//return;
}
buffer1->lock();
buffer2->lock();
for (size_t i = 0; i < numReceived1; i++)
for (size_t i = 0; i < nReceived; i++)
{
buffer1->push_back({(double)buff_ptrs[0][i].real(), (double)buff_ptrs[0][i].imag()});
buffer2->push_back({(double)buff_ptrs[1][i].real(), (double)buff_ptrs[1][i].imag()});
}
buffer1->unlock();
buffer2->unlock();
sleep(0.1);
}
}