diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..90b8d13 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "code/ssdv"] + path = code/ssdv + url = https://github.com/fsphil/ssdv.git diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index ccf782d..25b6de7 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -17,6 +17,7 @@ message ( "CMAKE_INSTALL_PREFIX: " ${CMAKE_INSTALL_PREFIX} ) add_subdirectory("Decoder") add_subdirectory("IQSource") +add_subdirectory("ssdv_build") add_subdirectory("websocketServer") option( fltkGUI "fltkGUI" OFF ) diff --git a/code/Decoder/CMakeLists.txt b/code/Decoder/CMakeLists.txt index af7c242..e185fd7 100755 --- a/code/Decoder/CMakeLists.txt +++ b/code/Decoder/CMakeLists.txt @@ -31,6 +31,7 @@ set ( Decoder_src sentence_extract.h sentence_extract.cpp SpectrumInfo.h SymbolExtractor.h + ssdv_wrapper.cpp ) SET( CMAKE_CXX_FLAGS " -O3 " ) @@ -50,6 +51,7 @@ endif() add_library( Decoder ${Decoder_src}) target_link_libraries( Decoder + ssdv_lib #${SoapySDR_LIBRARIES} ${FFTW3f_LIBRARIES} ${PlatformSpecificLinking} ) diff --git a/code/Decoder/Decoder.h b/code/Decoder/Decoder.h index e69fea7..5da9835 100644 --- a/code/Decoder/Decoder.h +++ b/code/Decoder/Decoder.h @@ -42,6 +42,7 @@ #include "SpectrumInfo.h" #include "print_habhub_sentence.h" #include "CRC.h" +#include "ssdv_wrapper.h" namespace habdec { @@ -178,6 +179,9 @@ private: std::string last_sentence_; // result of rtty // size_t last_sentence_len_ = 0; // optimization for regexp run + // SSDV + SSDV_wraper_t ssdv_; + // threading mutable std::mutex process_mutex_; // mutex for main processing @@ -555,14 +559,19 @@ void habdec::Decoder::process() return; - auto decoded_chars = rtty_.get(); - rtty_char_stream_.insert( rtty_char_stream_.end(), decoded_chars.begin(), decoded_chars.end() ); - chr_callback_stream_.insert( chr_callback_stream_.end(), decoded_chars.begin(), decoded_chars.end() ); + vector raw_chars = rtty_.get(); + ssdv_.push(raw_chars); + vector printable_chars; + copy_if( raw_chars.begin(), raw_chars.end(), back_inserter(printable_chars), + [](char c){return isprint(c) || c == '\n';} + ); + rtty_char_stream_.insert( rtty_char_stream_.end(), printable_chars.begin(), printable_chars.end() ); + chr_callback_stream_.insert( chr_callback_stream_.end(), printable_chars.begin(), printable_chars.end() ); if(live_print_) { - for( auto c : decoded_chars ) + for( auto c : printable_chars ) cout<::operator()() using namespace std; - size_t decoded_chars = 0; + size_t n_decoded_chars = 0; size_t last_decoded_bit_index = 0; for(size_t i=0; i::operator()() ++i; } - if( isprint(c) || c == '\n' ) + // if( isprint(c) || c == '\n' ) { chars_.push_back(c); - ++decoded_chars; + ++n_decoded_chars; } i += nstops_; @@ -133,7 +133,7 @@ size_t RTTY::operator()() if(last_decoded_bit_index) bits_.erase( bits_.begin(), bits_.begin() + last_decoded_bit_index + 1 ); - return decoded_chars; + return n_decoded_chars; } diff --git a/code/Decoder/ssdv_wrapper.cpp b/code/Decoder/ssdv_wrapper.cpp new file mode 100644 index 0000000..872499f --- /dev/null +++ b/code/Decoder/ssdv_wrapper.cpp @@ -0,0 +1,167 @@ +/* + + Copyright 2018 Michal Fratczak + + This file is part of habdec. + + habdec is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + habdec is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with habdec. If not, see . +*/ + +#include "ssdv_wrapper.h" +#include +#include +#include +#include +#include +#include "../ssdv/ssdv.h" + +void print_hex(const std::vector& v) +{ + for(auto c : v) std::cout<<"0x"<& i_chars) +{ + using namespace std; + + const size_t jpeg_data_sz_ = 1024 * 1024 * 3; + + // copy to buff_ + { + const size_t buff_end = buff_.size(); + buff_.resize( buff_.size() + i_chars.size() ); + memcpy( buff_.data() + buff_end, i_chars.data(), i_chars.size() ); + } + + if(buff_.size() < SSDV_PKT_SIZE) + return false; + + // scan input for packet sync bytes: 0x55 [0x66|0x67] 0x0 0x0 0xb3 0xeb + const uint8_t _fec[6] = {0x55, 0x66, 0x0, 0x0, 0xb3, 0xeb}; + const uint8_t _nofec[6] = {0x55, 0x67, 0x0, 0x0, 0xb3, 0xeb}; + if(packet_begin_ == -1) + { + for(int i=0; i0) + { + buff_.erase( buff_.begin(), buff_.begin()+packet_begin_ ); + packet_begin_ = 0; + } + + // packet incomplete + if( buff_.size() < SSDV_PKT_SIZE ) + return false; + + // print_hex(buff_); + + int errors = 0; + const int is_packet = ssdv_dec_is_packet( buff_.data(), &errors ); + if( is_packet != 0 ) // not a packet + { + buff_.erase( buff_.begin(), buff_.begin()+SSDV_PKT_SIZE ); + packet_begin_ = -1; + return false; + } + + ssdv_packet_info_t packet_header; + ssdv_dec_header( &packet_header, buff_.data() ); + + cout<<"SSDV Packet " + <. +*/ + +#pragma once + +#include +#include +#include "../ssdv/ssdv.h" + +namespace habdec +{ + +class SSDV_wraper_t +{ + +public: + SSDV_wraper_t(); + ~SSDV_wraper_t(); + bool push(const std::vector& i_chars); + +private: + uint8_t* jpeg; + ssdv_t ssdv; + + std::vector buff_; + int packet_begin_ = -1; +}; + +} \ No newline at end of file diff --git a/code/ssdv b/code/ssdv new file mode 160000 index 0000000..035f920 --- /dev/null +++ b/code/ssdv @@ -0,0 +1 @@ +Subproject commit 035f920f5c96880bfd89d4469428b934e830c7c9 diff --git a/code/ssdv_build/CMakeLists.txt b/code/ssdv_build/CMakeLists.txt new file mode 100644 index 0000000..e000d23 --- /dev/null +++ b/code/ssdv_build/CMakeLists.txt @@ -0,0 +1,23 @@ + +set ( ssdv_lib_src + ${PROJECT_SOURCE_DIR}/ssdv/rs8.c + ${PROJECT_SOURCE_DIR}/ssdv/ssdv.c +) + +set_source_files_properties ( ${ssdv_lib_src} LANGUAGE "C" ) + +add_library( ssdv_lib ${ssdv_lib_src} ) + + + + + +set ( ssdv_exe_src + ${PROJECT_SOURCE_DIR}/ssdv/rs8.c + ${PROJECT_SOURCE_DIR}/ssdv/ssdv.c + ${PROJECT_SOURCE_DIR}/ssdv/main.c +) + +set_source_files_properties ( ${ssdv_exe_src} LANGUAGE "C" ) + +add_executable( ssdv ${ssdv_exe_src} )