bunch of bugfix and new features

This commit is contained in:
AlexandreRouma 2022-11-12 02:19:53 +01:00
parent c4bac3b298
commit 1c373e9cdb
22 changed files with 219 additions and 59 deletions

View File

@ -51,14 +51,14 @@ jobs:
run: mkdir "C:/Program Files/codec2" ; mkdir "C:/Program Files/codec2/include" ; mkdir "C:/Program Files/codec2/include/codec2" ; mkdir "C:/Program Files/codec2/lib" ; cd "codec2" ; xcopy "src" "C:/Program Files/codec2/include" ; cd "build" ; xcopy "src" "C:/Program Files/codec2/lib" ; xcopy "codec2" "C:/Program Files/codec2/include/codec2"
- name: Install vcpkg dependencies
run: vcpkg install fftw3:x64-windows glfw3:x64-windows portaudio:x64-windows zstd:x64-windows boost:x64-windows boost-config:x64-windows
run: vcpkg install fftw3:x64-windows glfw3:x64-windows portaudio:x64-windows zstd:x64-windows
- name: Install rtaudio
run: git clone https://github.com/thestk/rtaudio ; cd rtaudio ; git checkout 2f2fca4502d506abc50f6d4473b2836d24cfb1e3 ; mkdir build ; cd build ; cmake .. ; cmake --build . --config Release ; cmake --install .
- name: Prepare CMake
working-directory: ${{runner.workspace}}/build
run: cmake "$Env:GITHUB_WORKSPACE" "-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON -DOPT_BUILD_USRP_SOURCE=ON
run: cmake "$Env:GITHUB_WORKSPACE" "-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON
- name: Build
working-directory: ${{runner.workspace}}/build
@ -87,7 +87,7 @@ jobs:
run: brew update
- name: Install dependencies
run: brew install libusb fftw glfw airspy airspyhf portaudio hackrf rtl-sdr libbladerf codec2 uhd zstd && pip3 install mako
run: brew install libusb fftw glfw airspy airspyhf portaudio hackrf rtl-sdr libbladerf codec2 zstd && pip3 install mako
- name: Install volk
run: git clone --recursive https://github.com/gnuradio/volk && cd volk && mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j3 && sudo make install && cd ../../
@ -106,7 +106,7 @@ jobs:
- name: Prepare CMake
working-directory: ${{runner.workspace}}/build
run: cmake $GITHUB_WORKSPACE -DOPT_BUILD_PLUTOSDR_SOURCE=ON -DOPT_BUILD_SOAPY_SOURCE=OFF -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_AUDIO_SINK=OFF -DOPT_BUILD_PORTAUDIO_SINK=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON -DOPT_BUILD_USRP_SOURCE=ON -DUSE_BUNDLE_DEFAULTS=ON -DCMAKE_BUILD_TYPE=Release
run: cmake $GITHUB_WORKSPACE -DOPT_BUILD_PLUTOSDR_SOURCE=ON -DOPT_BUILD_SOAPY_SOURCE=OFF -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_AUDIO_SINK=OFF -DOPT_BUILD_PORTAUDIO_SINK=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON -DUSE_BUNDLE_DEFAULTS=ON -DCMAKE_BUILD_TYPE=Release
- name: Build
working-directory: ${{runner.workspace}}/build

View File

@ -80,7 +80,11 @@ int sdrpp_main(int argc, char* argv[]) {
bool serverMode = (bool)core::args["server"];
#ifdef _WIN32
// Free console if the user hasn't asked for a console and not in server mode
if (!core::args["con"].b() && !serverMode) { FreeConsole(); }
// Set error mode to avoid abnoxious popups
SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_NOGPFAULTERRORBOX | SEM_FAILCRITICALERRORS);
#endif
// Check root directory
@ -168,8 +172,12 @@ int sdrpp_main(int argc, char* argv[]) {
defConfig["moduleInstances"]["File Source"]["enabled"] = true;
defConfig["moduleInstances"]["HackRF Source"]["module"] = "hackrf_source";
defConfig["moduleInstances"]["HackRF Source"]["enabled"] = true;
defConfig["moduleInstances"]["Hermes Source"]["module"] = "hermes_source";
defConfig["moduleInstances"]["Hermes Source"]["enabled"] = true;
defConfig["moduleInstances"]["LimeSDR Source"]["module"] = "limesdr_source";
defConfig["moduleInstances"]["LimeSDR Source"]["enabled"] = true;
defConfig["moduleInstances"]["PlutoSDR Source"]["module"] = "plutosdr_source";
defConfig["moduleInstances"]["PlutoSDR Source"]["enabled"] = true;
defConfig["moduleInstances"]["RFspace Source"]["module"] = "rfspace_source";
defConfig["moduleInstances"]["RFspace Source"]["enabled"] = true;
defConfig["moduleInstances"]["RTL-SDR Source"]["module"] = "rtl_sdr_source";
@ -184,8 +192,6 @@ int sdrpp_main(int argc, char* argv[]) {
defConfig["moduleInstances"]["SoapySDR Source"]["enabled"] = true;
defConfig["moduleInstances"]["SpyServer Source"]["module"] = "spyserver_source";
defConfig["moduleInstances"]["SpyServer Source"]["enabled"] = true;
defConfig["moduleInstances"]["PlutoSDR Source"]["module"] = "plutosdr_source";
defConfig["moduleInstances"]["PlutoSDR Source"]["enabled"] = true;
defConfig["moduleInstances"]["Audio Sink"] = "audio_sink";
defConfig["moduleInstances"]["Network Sink"] = "network_sink";

View File

@ -37,7 +37,7 @@ namespace dsp::compression {
if (pcmType == PCMType::PCM_TYPE_F32) {
*scaler = 0;
memcpy(dataBuf, in, count * sizeof(complex_t));
return count;
return 8 + (count * sizeof(complex_t));
}
// Find maximum value

View File

@ -171,4 +171,4 @@ namespace dsp::multirate {
double _outSamplerate;
Mode mode;
};
}
}

View File

@ -6,6 +6,8 @@
template <class K, class T>
class OptionList {
public:
OptionList() { updateText(); }
void define(K key, std::string name, T value) {
if (keyExists(key)) { throw std::runtime_error("Key already exists"); }
if (nameExists(name)) { throw std::runtime_error("Name already exists"); }

View File

@ -6,7 +6,7 @@ cd /root
apt update
apt install -y build-essential cmake git libfftw3-dev libglfw3-dev libvolk2-dev libzstd-dev libsoapysdr-dev libairspyhf-dev libairspy-dev \
libiio-dev libad9361-dev librtaudio-dev libhackrf-dev librtlsdr-dev libbladerf-dev liblimesuite-dev p7zip-full wget portaudio19-dev \
libcodec2-dev libuhd-dev
libcodec2-dev
# Install SDRPlay libraries
wget https://www.sdrplay.com/software/SDRplay_RSP_API-Linux-3.07.1.run
@ -18,7 +18,7 @@ cp inc/* /usr/include/
cd SDRPlusPlus
mkdir build
cd build
cmake .. -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON -DOPT_BUILD_USRP_SOURCE=ON
cmake .. -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON
make VERBOSE=1 -j2
cd ..

View File

@ -6,7 +6,7 @@ cd /root
apt update
apt install -y build-essential cmake git libfftw3-dev libglfw3-dev libvolk1-dev libzstd-dev libsoapysdr-dev libairspyhf-dev libairspy-dev \
libiio-dev libad9361-dev librtaudio-dev libhackrf-dev librtlsdr-dev libbladerf-dev liblimesuite-dev p7zip-full wget portaudio19-dev \
libcodec2-dev libuhd-dev
libcodec2-dev
# Install SDRPlay libraries
wget https://www.sdrplay.com/software/SDRplay_RSP_API-Linux-3.07.1.run
@ -18,7 +18,7 @@ cp inc/* /usr/include/
cd SDRPlusPlus
mkdir build
cd build
cmake .. -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_BLADERF_SOURCE=OFF -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON -DOPT_BUILD_USRP_SOURCE=ON
cmake .. -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_BLADERF_SOURCE=OFF -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON
make VERBOSE=1 -j2
cd ..

View File

@ -6,7 +6,7 @@ cd /root
apt update
apt install -y build-essential cmake git libfftw3-dev libglfw3-dev libvolk2-dev libzstd-dev libsoapysdr-dev libairspyhf-dev libairspy-dev \
libiio-dev libad9361-dev librtaudio-dev libhackrf-dev librtlsdr-dev libbladerf-dev liblimesuite-dev p7zip-full wget portaudio19-dev \
libcodec2-dev libuhd-dev
libcodec2-dev
# Install SDRPlay libraries
wget https://www.sdrplay.com/software/SDRplay_RSP_API-Linux-3.07.1.run
@ -18,7 +18,7 @@ cp inc/* /usr/include/
cd SDRPlusPlus
mkdir build
cd build
cmake .. -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON -DOPT_BUILD_USRP_SOURCE=ON
cmake .. -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON
make VERBOSE=1 -j2
cd ..

View File

@ -12,7 +12,7 @@ apt update
# Install dependencies and tools
apt install -y build-essential cmake git libfftw3-dev libglfw3-dev libvolk1-dev libzstd-dev libsoapysdr-dev libairspy-dev \
libiio-dev libad9361-dev librtaudio-dev libhackrf-dev librtlsdr-dev libbladerf-dev liblimesuite-dev p7zip-full wget portaudio19-dev \
libcodec2-dev libudev-dev libuhd-dev
libcodec2-dev libudev-dev
# Install SDRPlay libraries
wget https://www.sdrplay.com/software/SDRplay_RSP_API-Linux-3.07.1.run
@ -56,7 +56,7 @@ echo 'Cflags: -I/usr/include/codec2' >> /usr/share/pkgconfig/codec2.pc
cd SDRPlusPlus
mkdir build
cd build
cmake .. -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_BLADERF_SOURCE=OFF -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_OVERRIDE_STD_FILESYSTEM=ON -DOPT_BUILD_M17_DECODER=ON -DOPT_BUILD_USRP_SOURCE=ON
cmake .. -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_BLADERF_SOURCE=OFF -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_OVERRIDE_STD_FILESYSTEM=ON -DOPT_BUILD_M17_DECODER=ON
make VERBOSE=1 -j2
# Generate package

View File

@ -6,7 +6,7 @@ cd /root
apt update
apt install -y build-essential cmake git libfftw3-dev libglfw3-dev libvolk2-dev libzstd-dev libsoapysdr-dev libairspyhf-dev libairspy-dev \
libiio-dev libad9361-dev librtaudio-dev libhackrf-dev librtlsdr-dev libbladerf-dev liblimesuite-dev p7zip-full wget portaudio19-dev \
libcodec2-dev libuhd-dev
libcodec2-dev
# Install SDRPlay libraries
wget https://www.sdrplay.com/software/SDRplay_RSP_API-Linux-3.07.1.run
@ -18,7 +18,7 @@ cp inc/* /usr/include/
cd SDRPlusPlus
mkdir build
cd build
cmake .. -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON -DOPT_BUILD_USRP_SOURCE=ON
cmake .. -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON
make VERBOSE=1 -j2
cd ..

View File

@ -6,7 +6,7 @@ cd /root
apt update
apt install -y build-essential cmake git libfftw3-dev libglfw3-dev libvolk2-dev libzstd-dev libsoapysdr-dev libairspyhf-dev libairspy-dev \
libiio-dev libad9361-dev librtaudio-dev libhackrf-dev librtlsdr-dev libbladerf-dev liblimesuite-dev p7zip-full wget portaudio19-dev \
libcodec2-dev libuhd-dev
libcodec2-dev
# Install SDRPlay libraries
wget https://www.sdrplay.com/software/SDRplay_RSP_API-Linux-3.07.1.run
@ -18,7 +18,7 @@ cp inc/* /usr/include/
cd SDRPlusPlus
mkdir build
cd build
cmake .. -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON -DOPT_BUILD_USRP_SOURCE=ON
cmake .. -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON
make VERBOSE=1 -j2
cd ..

View File

@ -46,7 +46,7 @@ bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules/sdrpp_server_source/sdrpp_server_source.dylib
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules/soapy_source/soapy_source.dylib
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules/spyserver_source/spyserver_source.dylib
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules/usrp_source/usrp_source.dylib
# bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/source_modules/usrp_source/usrp_source.dylib
# Sink modules
bundle_install_binary $BUNDLE $BUNDLE/Contents/Plugins $BUILD_DIR/sink_modules/portaudio_sink/audio_sink.dylib

View File

@ -50,7 +50,7 @@ cp $build_dir/source_modules/soapy_source/Release/soapy_source.dll sdrpp_windows
cp $build_dir/source_modules/spyserver_source/Release/spyserver_source.dll sdrpp_windows_x64/modules/
cp $build_dir/source_modules/usrp_source/Release/usrp_source.dll sdrpp_windows_x64/modules/
# cp $build_dir/source_modules/usrp_source/Release/usrp_source.dll sdrpp_windows_x64/modules/
# Copy sink modules

View File

@ -21,6 +21,14 @@ SDR++ is a cross-platform and open source SDR software with the aim of being blo
# Installing
## Nightly Builds
Nightly builds contain the very latest features and bugfixes. They are usually just stable as [normal releases](https://github.com/AlexandreRouma/SDRPlusPlus/releases) but are available basically minutes to hours after a change has been pushed to the code.
You can download them [here](https://www.sdrpp.org/nightly). It'll redirect you to the latest nightly on GitHub, scroll down to "Artifacts" and click on the version for your OS.
GitHub currently requires an account for the files to be downloadable so make sure you are logged in.
## Windows
Download the latest release from [the Releases page](https://github.com/AlexandreRouma/SDRPlusPlus/releases) and extract to the directory of your choice.
@ -277,7 +285,8 @@ Make sure to install portaudio as it'll be needed later.
An example install command would be:
```sh
brew install libusb fftw glfw airspy airspyhf portaudio hackrf rtl-sdr libbladerf codec2 && pip3 install mako zstd
brew install libusb fftw glfw airspy airspyhf portaudio hackrf rtl-sdr libbladerf codec2 zstd
pip3 install mako
```
### Install volk
@ -331,7 +340,7 @@ Modules in beta are still included in releases for the most part but not enabled
| sdrpp_server_source | Working | - | OPT_BUILD_SDRPP_SERVER_SOURCE | ✅ | ✅ | ✅ |
| soapy_source | Working | soapysdr | OPT_BUILD_SOAPY_SOURCE | ✅ | ✅ | ✅ |
| spyserver_source | Working | - | OPT_BUILD_SPYSERVER_SOURCE | ✅ | ✅ | ✅ |
| usrp_source | Beta | libuhd | OPT_BUILD_USRP_SOURCE | ⛔ | | ⛔ |
| usrp_source | Beta | libuhd | OPT_BUILD_USRP_SOURCE | ⛔ | | ⛔ |
## Sinks

View File

@ -18,7 +18,7 @@ else ()
endif ()
if(WIN32)
target_link_libraries(hermes_source PRIVATE wsock32 ws2_32)
target_link_libraries(hermes_source PRIVATE wsock32 ws2_32 iphlpapi)
endif()
# Install directives

View File

@ -20,11 +20,15 @@ namespace hermes {
}
void Client::start() {
sendMetisControl((MetisControl)(METIS_CTRL_IQ | METIS_CTRL_NO_WD));
for (int i = 0; i < HERMES_METIS_REPEAT; i++) {
sendMetisControl((MetisControl)(METIS_CTRL_IQ | METIS_CTRL_NO_WD));
}
}
void Client::stop() {
sendMetisControl(METIS_CTRL_NONE);
for (int i = 0; i < HERMES_METIS_REPEAT; i++) {
sendMetisControl(METIS_CTRL_NONE);
}
}
void Client::setSamplerate(HermesLiteSamplerate samplerate) {
@ -32,13 +36,44 @@ namespace hermes {
}
void Client::setFrequency(double freq) {
this->freq = freq;
writeReg(HL_REG_TX1_NCO_FREQ, freq);
autoeFilters(freq);
}
void Client::setGain(int gain) {
writeReg(HL_REG_RX_LNA, gain | (1 << 6));
}
void Client::autoeFilters(double freq) {
uint8_t filt = (freq >= 3000000.0) ? (1 << 6) : 0;
if (freq <= 2000000.0) {
filt |= (1 << 0);
}
else if (freq <= 4000000.0) {
filt |= (1 << 1);
}
else if (freq <= 7300000.0) {
filt |= (1 << 2);
}
else if (freq <= 14350000.0) {
filt |= (1 << 3);
}
else if (freq <= 21450000.0) {
filt |= (1 << 4);
}
else if (freq <= 29700000.0) {
filt |= (1 << 5);
}
// Write only if the config actually changed
if (filt != lastFilt) {
lastFilt = filt;
writeI2C(I2C_PORT_2, 0x20, 0x0A, filt);
}
}
void Client::sendMetisUSB(uint8_t endpoint, void* frame0, void* frame1) {
// Build packet
uint32_t seq = usbSeq++;
@ -79,6 +114,8 @@ namespace hermes {
sendMetisUSB(2, frame);
// TODO: Wait for response
return 0;
}
@ -96,6 +133,15 @@ namespace hermes {
sendMetisUSB(2, frame);
}
void Client::writeI2C(I2CPort port, uint8_t addr, uint8_t reg, uint8_t data) {
uint32_t wdata = data;
wdata |= reg << 8;
wdata |= (addr & 0x7F) << 16;
wdata |= 1 << 23;
wdata |= 0x06 << 24;
writeReg(HL_REG_I2C_1 + port, wdata);
}
void Client::worker() {
uint8_t rbuf[2048];
MetisUSBPacket* pkt = (MetisUSBPacket*)rbuf;
@ -147,7 +193,7 @@ namespace hermes {
}
std::vector<Info> discover() {
auto sock = net::openudp("192.168.0.255", 1024);
auto sock = net::openudp("0.0.0.0", 1024);
// Build discovery packet
uint8_t discoveryPkt[64];
@ -155,18 +201,23 @@ namespace hermes {
*(uint16_t*)&discoveryPkt[0] = htons(HERMES_METIS_SIGNATURE);
discoveryPkt[2] = METIS_PKT_DISCOVER;
// Get interface list
auto ifaces = net::listInterfaces();
// Send the packet 5 times to make sure it's received
for (int i = 0; i < HERMES_DISCOVER_REPEAT; i++) {
sock->send(discoveryPkt, sizeof(discoveryPkt));
for (const auto& [name, iface] : ifaces) {
net::Address baddr(iface.broadcast, 1024);
for (int i = 0; i < HERMES_METIS_REPEAT; i++) {
sock->send(discoveryPkt, sizeof(discoveryPkt), &baddr);
}
}
std::vector<Info> devices;
while (true) {
// Wait for a response
net::Address addr;
uint8_t resp[1024];
int len = sock->recv(resp, sizeof(resp), false, HERMES_DISCOVER_TIMEOUT, &addr);
int len = sock->recv(resp, sizeof(resp), false, HERMES_METIS_TIMEOUT, &addr);
// Give up if timeout or error
if (len <= 0) { break; }

View File

@ -7,8 +7,8 @@
#include <string>
#include <thread>
#define HERMES_DISCOVER_REPEAT 5
#define HERMES_DISCOVER_TIMEOUT 1000
#define HERMES_METIS_REPEAT 5
#define HERMES_METIS_TIMEOUT 1000
#define HERMES_METIS_SIGNATURE 0xEFFE
#define HERMES_HPSDR_USB_SYNC 0x7F
@ -80,6 +80,11 @@ namespace hermes {
HL_SAMP_RATE_384KHZ = 3
};
enum I2CPort {
I2C_PORT_1 = 0,
I2C_PORT_2
};
#pragma pack(push, 1)
struct HPSDRUSBHeader {
uint8_t sync[3];
@ -130,6 +135,7 @@ namespace hermes {
void setSamplerate(HermesLiteSamplerate samplerate);
void setFrequency(double freq);
void setGain(int gain);
void autoeFilters(double freq);
dsp::stream<dsp::complex_t> out;
@ -140,13 +146,19 @@ namespace hermes {
uint32_t readReg(uint8_t addr);
void writeReg(uint8_t addr, uint32_t val);
void writeI2C(I2CPort port, uint8_t addr, uint8_t reg, uint8_t data);
void worker();
bool open = true;
double freq = 0;
std::thread workerThread;
std::shared_ptr<net::Socket> sock;
uint32_t usbSeq = 0;
uint8_t lastFilt = 0;
};

View File

@ -48,15 +48,6 @@ public:
handler.stopHandler = stop;
handler.tuneHandler = tune;
handler.stream = &stream;
// TODO: Move the refresh and first select to the select event instead
refresh();
// Select device
config.acquire();
selectedMac = config.conf["device"];
config.release();
selectMac(selectedMac);
sigpath::sourceManager.registerSource("Hermes", &handler);
}
@ -132,6 +123,20 @@ private:
static void menuSelected(void* ctx) {
HermesSourceModule* _this = (HermesSourceModule*)ctx;
if (_this->firstSelect) {
_this->firstSelect = false;
// Refresh
_this->refresh();
// Select device
config.acquire();
_this->selectedMac = config.conf["device"];
config.release();
_this->selectMac(_this->selectedMac);
}
core::setInputSampleRate(_this->sampleRate);
spdlog::info("HermesSourceModule '{0}': Menu Select!", _this->name);
}
@ -257,6 +262,8 @@ private:
int srId = 0;
int gain = 0;
bool firstSelect = true;
std::shared_ptr<hermes::Client> dev;
};

View File

@ -1,5 +1,6 @@
#include "net.h"
#include <string.h>
#include <codecvt>
#ifdef _WIN32
#define WOULD_BLOCK (WSAGetLastError() == WSAEWOULDBLOCK)
@ -246,6 +247,60 @@ namespace net {
// === Creation functions ===
std::map<std::string, InterfaceInfo> listInterfaces() {
// Init library if needed
init();
std::map<std::string, InterfaceInfo> ifaces;
#ifdef _WIN32
// Pre-allocate buffer
ULONG size = sizeof(IP_ADAPTER_ADDRESSES);
PIP_ADAPTER_ADDRESSES addresses = (PIP_ADAPTER_ADDRESSES)malloc(size);
// Reallocate to real size
if (GetAdaptersAddresses(AF_INET, 0, NULL, addresses, &size) == ERROR_BUFFER_OVERFLOW) {
addresses = (PIP_ADAPTER_ADDRESSES)realloc(addresses, size);
if (GetAdaptersAddresses(AF_INET, 0, NULL, addresses, &size)) {
throw std::exception("Could not list network interfaces");
}
}
// Save data
std::wstring_convert<std::codecvt_utf8<wchar_t>> utfConv;
for (auto iface = addresses; iface; iface = iface->Next) {
InterfaceInfo info;
auto ip = iface->FirstUnicastAddress;
if (!ip || ip->Address.lpSockaddr->sa_family != AF_INET) { continue; }
info.address = ntohl(*(uint32_t*)&ip->Address.lpSockaddr->sa_data[2]);
info.netmask = ~((1 << (32 - ip->OnLinkPrefixLength)) - 1);
info.broadcast = info.address | (~info.netmask);
ifaces[utfConv.to_bytes(iface->FriendlyName)] = info;
}
// Free tables
free(addresses);
#else
// Get iface list
struct ifaddrs* addresses = NULL;
getifaddrs(&addresses);
// Save data
for (auto iface = addresses; iface; iface = iface->ifa_next) {
if (iface->ifa_addr->sa_family != AF_INET) { continue; }
InterfaceInfo info;
info.address = ntohl(*(uint32_t*)&iface->ifa_addr->sa_data[2]);
info.netmask = ntohl(*(uint32_t*)&iface->ifa_netmask->sa_data[2]);
info.broadcast = info.address | (~info.netmask);
ifaces[iface->ifa_name] = info;
}
// Free iface list
freeifaddrs(addresses);
#endif
return ifaces;
}
std::shared_ptr<Listener> listen(const Address& addr) {
// Init library if needed
init();

View File

@ -2,10 +2,12 @@
#include <stdint.h>
#include <mutex>
#include <memory>
#include <map>
#ifdef _WIN32
#include <WinSock2.h>
#include <WS2tcpip.h>
#include <iphlpapi.h>
#else
#include <unistd.h>
#include <strings.h>
@ -16,6 +18,7 @@
#include <signal.h>
#include <poll.h>
#include <fcntl.h>
#include <ifaddrs.h>
#endif
namespace net {
@ -30,6 +33,12 @@ namespace net {
class Socket;
class Listener;
struct InterfaceInfo {
IP_t address;
IP_t netmask;
IP_t broadcast;
};
class Address {
friend Socket;
friend Listener;
@ -198,6 +207,12 @@ namespace net {
};
/**
* Get a list of the network interface.
* @return List of network interfaces and their addresses.
*/
std::map<std::string, InterfaceInfo> listInterfaces();
/**
* Create TCP listener.
* @param addr Address to listen on.

View File

@ -115,11 +115,9 @@ private:
if (!_this->client) { return; }
}
// TODO: Set configuration here
if (_this->client) {
_this->client->setFrequency(_this->freq);
_this->client->start();
}
// Set configuration
_this->client->setFrequency(_this->freq);
_this->client->start();
_this->running = true;
spdlog::info("SDRPPServerSourceModule '{0}': Start!", _this->name);

View File

@ -30,8 +30,6 @@ public:
this->name = name;
sampleRate = 8000000.0;
// TODO: REMOVE
samplerates.define(8000000, "8MHz", 8000000.0);
handler.ctx = this;
handler.selectHandler = menuSelected;
@ -42,15 +40,6 @@ public:
handler.tuneHandler = tune;
handler.stream = &stream;
// List devices
refresh();
// Select device
config.acquire();
selectedSer = config.conf["device"];
config.release();
select(selectedSer);
sigpath::sourceManager.registerSource("USRP", &handler);
}
@ -212,6 +201,20 @@ private:
static void menuSelected(void* ctx) {
USRPSourceModule* _this = (USRPSourceModule*)ctx;
if (_this->firstSelect) {
_this->firstSelect = false;
// List devices
_this->refresh();
// Select device
config.acquire();
_this->selectedSer = config.conf["device"];
config.release();
_this->select(_this->selectedSer);
}
core::setInputSampleRate(_this->sampleRate);
spdlog::info("USRPSourceModule '{0}': Menu Select!", _this->name);
}
@ -406,6 +409,8 @@ private:
uhd::usrp::multi_usrp::sptr dev;
uhd::rx_streamer::sptr streamer;
bool firstSelect = true;
std::thread workerThread;
};