Skip to content

Commit

Permalink
add fobossdr_source module and fix network sink crash when the given …
Browse files Browse the repository at this point in the history
…hostname is invalid
  • Loading branch information
AlexandreRouma committed Sep 11, 2024
1 parent 79dd5bd commit c2f0e75
Show file tree
Hide file tree
Showing 6 changed files with 419 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ option(OPT_BUILD_AUDIO_SOURCE "Build Audio Source Module (Dependencies: rtaudio)
option(OPT_BUILD_BADGESDR_SOURCE "Build BadgeSDR Source Module (Dependencies: libusb)" OFF)
option(OPT_BUILD_BLADERF_SOURCE "Build BladeRF Source Module (Dependencies: libbladeRF)" OFF)
option(OPT_BUILD_FILE_SOURCE "Wav file source" ON)
option(OPT_BUILD_FOBOSSDR_SOURCE "Build FobosSDR Source Module (Dependencies: libfobos)" OFF)
option(OPT_BUILD_HACKRF_SOURCE "Build HackRF Source Module (Dependencies: libhackrf)" ON)
option(OPT_BUILD_HAROGIC_SOURCE "Build Harogic Source Module (Dependencies: htra_api)" OFF)
option(OPT_BUILD_HERMES_SOURCE "Build Hermes Source Module (no dependencies required)" ON)
Expand Down Expand Up @@ -143,6 +144,10 @@ if (OPT_BUILD_FILE_SOURCE)
add_subdirectory("source_modules/file_source")
endif (OPT_BUILD_FILE_SOURCE)

if (OPT_BUILD_FOBOSSDR_SOURCE)
add_subdirectory("source_modules/fobossdr_source")
endif (OPT_BUILD_FOBOSSDR_SOURCE)

if (OPT_BUILD_HACKRF_SOURCE)
add_subdirectory("source_modules/hackrf_source")
endif (OPT_BUILD_HACKRF_SOURCE)
Expand Down
6 changes: 3 additions & 3 deletions decoder_modules/ryfi_decoder/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ SDRPP_MOD_INFO{
/* Max instances */ -1
};

#define INPUT_BANDWIDTH 138e3
#define INPUT_SAMPLE_RATE 250e3
#define INPUT_BAUDRATE 125e3
#define INPUT_BANDWIDTH 600e3
#define INPUT_SAMPLE_RATE 1000e3
#define INPUT_BAUDRATE 500e3

#define SYMBOL_DIAG_RATE 30
#define SYMBOL_DIAG_COUNT 1024
Expand Down
5 changes: 4 additions & 1 deletion decoder_modules/ryfi_decoder/src/ryfi/receiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ namespace ryfi {
uint8_t* pktBuffer = new uint8_t[Packet::MAX_CONTENT_SIZE];
int pktExpected = 0;
int pktRead = 0;
int valid = 0;

while (true) {
// Read a frame
Expand All @@ -80,6 +81,7 @@ namespace ryfi {

// Deserialize the frame
Frame::deserialize(rs.out.readBuf, frame);
valid++;

// Flush the stream
rs.out.flush();
Expand All @@ -93,11 +95,12 @@ namespace ryfi {
// If the frames aren't consecutive
int frameRead = 0;
if (frame.counter != expectedCounter) {
flog::warn("Lost at least {} frames", ((int)frame.counter - (int)expectedCounter + 0x10000) % 0x10000);
flog::warn("Lost at least {} frames after {} valid frames", ((int)frame.counter - (int)expectedCounter + 0x10000) % 0x10000, valid);

// Cancel the partial packet if there was one
pktExpected = 0;
pktRead = 0;
valid = 1;

// If this frame is not an idle frame or continuation frame
if (frame.firstPacket != PKT_OFFS_NONE) {
Expand Down
17 changes: 11 additions & 6 deletions sink_modules/network_sink/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,19 @@ class NetworkSink : SinkManager::Sink {
}

void startServer() {
if (modeId == SINK_MODE_TCP) {
listener = net::listen(hostname, port);
if (listener) {
listener->acceptAsync(clientHandler, this);
try {
if (modeId == SINK_MODE_TCP) {
listener = net::listen(hostname, port);
if (listener) {
listener->acceptAsync(clientHandler, this);
}
}
else {
conn = net::openUDP("0.0.0.0", port, hostname, port, false);
}
}
else {
conn = net::openUDP("0.0.0.0", port, hostname, port, false);
catch (const std::exception& e) {
flog::error("Failed to open socket: {}", e.what());
}
}

Expand Down
15 changes: 15 additions & 0 deletions source_modules/fobossdr_source/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.13)
project(fobossdr_source)

file(GLOB SRC "src/*.cpp")

include(${SDRPP_MODULE_CMAKE})

if (MSVC)
# Lib path
target_link_directories(fobossdr_source PRIVATE "C:/Program Files/libfobos/lib/")
target_include_directories(fobossdr_source PRIVATE "C:/Program Files/libfobos/include/")
target_link_libraries(fobossdr_source PRIVATE fobos)
else (MSVC)
# TODO
endif ()
Loading

0 comments on commit c2f0e75

Please sign in to comment.