From 32b54f4eb4aa767aa9e2beda3fbdf3789d0499af Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Wed, 12 Feb 2020 06:02:06 +0100 Subject: [PATCH] fix build chain --- .dockerignore | 3 +- .gitignore | 3 +- Dockerfile | 29 ++- build/CMakeLists.txt | 166 ++++++++++++++++++ build/blocks/ccsds_ldpc_decoder.xml | 85 +++++++++ build/blocks/ccsds_ldpc_encoder.xml | 85 +++++++++ build/blocks/ccsds_message_info.xml | 48 +++++ build/blocks/ccsds_output_counter_cc.xml | 35 ++++ build/blocks/ccsds_randomiser_softbits.xml | 56 ++++++ build/blocks/ccsds_send_nanolink.xml | 17 ++ build/blocks/ccsds_soft_to_hard_message.xml | 17 ++ build/blocks/ccsds_softbit_msg_sink_f.xml | 29 +++ build/blocks/ccsds_softbit_msg_source_f.xml | 29 +++ build/blocks/ccsds_udp_source_rate_idle_b.xml | 100 +++++++++++ build/fakeserver/server.py | 64 +++++++ build/run.sh | 7 + docker-compose.yml | 12 -- scripts/build.sh | 5 +- scripts/buildx.sh | 9 + scripts/run.sh | 3 + 20 files changed, 781 insertions(+), 21 deletions(-) create mode 100644 build/CMakeLists.txt create mode 100644 build/blocks/ccsds_ldpc_decoder.xml create mode 100644 build/blocks/ccsds_ldpc_encoder.xml create mode 100644 build/blocks/ccsds_message_info.xml create mode 100644 build/blocks/ccsds_output_counter_cc.xml create mode 100644 build/blocks/ccsds_randomiser_softbits.xml create mode 100644 build/blocks/ccsds_send_nanolink.xml create mode 100644 build/blocks/ccsds_soft_to_hard_message.xml create mode 100644 build/blocks/ccsds_softbit_msg_sink_f.xml create mode 100644 build/blocks/ccsds_softbit_msg_source_f.xml create mode 100644 build/blocks/ccsds_udp_source_rate_idle_b.xml create mode 100644 build/fakeserver/server.py create mode 100644 build/run.sh delete mode 100644 docker-compose.yml create mode 100644 scripts/buildx.sh create mode 100644 scripts/run.sh diff --git a/.dockerignore b/.dockerignore index af27a2f..95ee77f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,3 @@ scripts/ -config/ \ No newline at end of file +config/ +data/ \ No newline at end of file diff --git a/.gitignore b/.gitignore index 2eea525..f1ac045 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.env \ No newline at end of file +.env +data/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 8fd4bce..9fbb137 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -# Secure temp download stage +# Private temp download stage FROM ubuntu:18.04 as intermediate ENV DEBIAN_FRONTEND=noninteractive TZ=Europe/Berlin @@ -23,8 +23,11 @@ ARG PROP_DIR_SDR ARG PROP_DIR_DECODER WORKDIR /app RUN git clone https://github.com/MOVE-II/move2radio.git && \ + cd move2radio && git checkout 6fcbae73359b0618312d222148aba07799a43a47 && git reset --hard && cd .. && \ git clone git@${PROP_SERVER}:${PROP_DIR_SDR}/ldpc.git move2radio-prop/ldpc && \ - git clone git@${PROP_SERVER}:${PROP_DIR_SDR}/gr-ccsds.git move2radio-prop/gr-ccsds + cd move2radio-prop/ldpc && git checkout 940e8f96ccae831c7d3ad6b9497710696cd7f324 && git reset --hard && cd ../.. && \ + git clone git@${PROP_SERVER}:${PROP_DIR_SDR}/gr-ccsds.git move2radio-prop/gr-ccsds && \ + cd move2radio-prop/gr-ccsds && git checkout 5777e4176fe381327fe6cf55b7ec0dfe3c63b3f6 && git reset --hard && cd ../.. # Build stage FROM ubuntu:18.04 @@ -32,7 +35,10 @@ ENV DEBIAN_FRONTEND=noninteractive TZ=Europe/Berlin # Setup build deps RUN apt-get update && \ - apt-get -y install build-essential git cmake python2.7 python-pip wget autoconf unzip libtool-bin pkgconf && \ + apt-get -y install build-essential git cmake autoconf unzip libtool-bin pkgconf libssl-dev \ + python2.7 python-pip python-mako socat libcppunit-dev swig uuid-dev \ + python-mako python-numpy python-wxgtk3.0 python-sphinx python-cheetah libzmq3-dev \ + libcomedi-dev libqt4-opengl-dev python-qt4 libqwt-dev libsdl1.2-dev python-gtk2 python-lxml python-sip-dev && \ rm -rf /var/lib/apt/lists/* # Copy sources from download stage @@ -40,8 +46,19 @@ COPY --from=intermediate /app /app # Build sources WORKDIR /app/move2radio +COPY build/CMakeLists.txt /app/move2radio/CMakeLists.txt RUN mkdir build && cd build && \ - cmake -DAPPIMAGE=OFF -DLDPC_OFFLINE=ON -DGR_CCSDS_OFFLINE=ON -DOFFLINE_DEPENDENCY_PATH=/app/move2radio-prop .. && \ - make build_gr_ccsds + cmake -DAPPIMAGE=OFF -DCONDA_ENV=OFF -DLDPC_OFFLINE=ON -DGR_CCSDS_OFFLINE=ON -DOFFLINE_DEPENDENCY_PATH=/app/move2radio-prop .. && \ + make move2radio -ENTRYPOINT ["/bin/bash"] \ No newline at end of file +# Install binaries +COPY build/blocks/* /app/move2radio/build/prefix/usr/share/gnuradio/grc/blocks/ +RUN chmod 644 /app/move2radio/build/prefix/usr/share/gnuradio/grc/blocks/*.xml && \ + cp -a build/prefix/usr/. /usr/ && \ + ldconfig + +# Entrypoint +COPY build/fakeserver/* /app/fakeserver/ +COPY build/run.sh /app/run.sh +RUN chmod +x /app/run.sh +ENTRYPOINT ["/app/run.sh"] \ No newline at end of file diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt new file mode 100644 index 0000000..6bb81ce --- /dev/null +++ b/build/CMakeLists.txt @@ -0,0 +1,166 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 3.0) +PROJECT(move2radio + LANGUAGES C + DESCRIPTION "Portable Version of the MOVE-II groundstation") + +INCLUDE(ExternalProject) + +IF(UNIX AND NOT APPLE) + SET(LINUX TRUE) +ENDIF() + +INCLUDE(cmake/options.cmake) +INCLUDE(cmake/system_deps.cmake) + +INCLUDE(cmake/build_autotools.cmake) +INCLUDE(cmake/build_cmake.cmake) +INCLUDE(cmake/build_meson.cmake) + +SET(DEPS_PATH "${CMAKE_CURRENT_BINARY_DIR}/deps") +SET(BUILD_PATH "${CMAKE_CURRENT_BINARY_DIR}/build") +SET(PREFIX_PATH "${CMAKE_CURRENT_BINARY_DIR}/prefix") +FILE(MAKE_DIRECTORY ${DEPS_PATH}/src) + +SET(ENV{PKG_CONFIG_PATH} ${PREFIX_PATH}/usr/lib/pkgconfig) +SET(PKG_CONFIG_PATH ENV{PKG_CONFIG_PATH}) +## Custom target deps makes sure all sources are there +ADD_CUSTOM_TARGET(deps) +IF(NOT ${NO_DOWNLOAD}) + ADD_CUSTOM_TARGET(download) + ADD_DEPENDENCIES(deps download) +ENDIF() + +## move2deps.cmake contains all sources +INCLUDE(cmake/dependency.cmake) +INCLUDE(cmake/move2deps.cmake) + +ADD_CUSTOM_TARGET(delete_prefix + ${CMAKE_COMMAND} -E remove_directory ${PREFIX_PATH}) +ADD_CUSTOM_TARGET(prefix + ${CMAKE_COMMAND} -E make_directory ${PREFIX_PATH}/usr/share + COMMAND echo \"CFLAGS=-I${PREFIX_PATH}/usr/include\\nLDFLAGS=\\\"-L${PREFIX_PATH}/usr/lib -Wl,-rpath=${PREFIX_PATH}/usr/lib\\\"\\n\" > ${PREFIX_PATH}/config.site + COMMAND rm -f ${PREFIX_PATH}/usr/lib/libuuid.* + COMMAND find / -not -path \"${CMAKE_CURRENT_BINARY_DIR}/*\" -name \"libuuid*.so*\" -exec ln -sf {} ${PREFIX_PATH}/usr/lib/libuuid.so \\\\; 2>/dev/null || [ -e ${PREFIX_PATH}/usr/lib/libuuid.so ]) + +### Anaconda deploys a portable python + pygtk,numpy,pyqt ### +INCLUDE(cmake/anaconda.cmake) + +INCLUDE(ProcessorCount) +PROCESSORCOUNT(N) +FIND_PROGRAM(MAKE make) +FIND_PROGRAM(MESON meson) +FIND_PROGRAM(NINJA ninja) + +### Build all sources ### + +# Boost and ldpc Build is more complicated. Moved to own file +INCLUDE(cmake/boost.cmake) +INCLUDE(cmake/ldpc.cmake) + +MOVEII_BUILD_AUTOTOOLS(fftw EXTRA_OPTIONS --enable-threads --enable-float) +MOVEII_BUILD_AUTOTOOLS(gsl) +MOVEII_BUILD_AUTOTOOLS(libiconv) +MOVEII_BUILD_AUTOTOOLS(rtl-sdr) +MOVEII_BUILD_AUTOTOOLS(gmp) +MOVEII_BUILD_AUTOTOOLS(rxvt-unicode EXTRA_OPTIONS --disable-perl --enable-xft CONFIG_SITE ON) +MOVEII_BUILD_AUTOTOOLS(ntl NO_DEFAULT ON SOURCE_SUFFIX "/src" COPY_SOURCE ON + EXTRA_OPTIONS NTL_GMP_LIP=on SHARED=on NATIVE=off DEF_PREFIX=${PREFIX_PATH}/usr) +MOVEII_BUILD_AUTOTOOLS(ncurses) +MOVEII_BUILD_CMAKE(airspy) +MOVEII_BUILD_CMAKE(gr-osmosdr) +MOVEII_BUILD_CMAKE(curl EXTRA_OPTIONS -DCMAKE_USE_OPENSSL=ON) +MOVEII_BUILD_CMAKE(curlpp) +MOVEII_BUILD_CMAKE(gr-ccsds) +MOVEII_BUILD_CMAKE(gr-iqbal) +MOVEII_BUILD_CMAKE(libosmosdr) +MOVEII_BUILD_CMAKE(bladerf EXTRA_OPTIONS -DINSTALL_UDEV_RULES=OFF) +MOVEII_BUILD_CMAKE(libmirisdr) +MOVEII_BUILD_CMAKE(soapysdr) +MOVEII_BUILD_CMAKE(hackrf SOURCE_SUFFIX "/host/") +MOVEII_BUILD_CMAKE(gr-fcdproplus) +MOVEII_BUILD_CMAKE(freesrp) +MOVEII_BUILD_CMAKE(libuhd EXTRA_OPTIONS -DENABLE_E100=ON -DENABLE_E300=ON -DENABLE_EXAMPLES=OFF -DENABLE_TESTS=OFF -DENABLE_UTILS=OFF SOURCE_SUFFIX "/host") + +MOVEII_BUILD_CMAKE(gnuradio EXTRA_OPTIONS + -DENABLE_INTERNAL_VOLK=ON + -DENABLE_DEFAULT=OFF + -DENABLE_VOLK=ON + -DENABLE_GNURADIO_RUNTIME=ON + -DENABLE_PYTHON=ON + -DENABLE_GR_AUDIO=ON + -DENABLE_GR_BLOCKS=ON + -DENABLE_GR_FILTER=ON + -DENABLE_GR_FFT=ON + -DENABLE_GR_UHD=OFF + -DENABLE_GR_FCD=OFF + -DENABLE_GR_ANALOG=ON + -DENABLE_GR_WAVELET=ON + -DENABLE_GRC=ON + -DENABLE_GR_QTGUI=ON + -DENABLE_GR_DIGITAL=ON) +ADD_DEPENDENCIES(build_gnuradio build_boost build_gsl build_fftw build_libiconv) + +MOVEII_BUILD_AUTOTOOLS(fec NO_AUTORECONF ON NO_INSTALL ON) +## fec is to dumb to properly install: +ADD_CUSTOM_COMMAND(OUTPUT ${PREFIX_PATH}/usr/lib/libfec.so + COMMAND ${CMAKE_COMMAND} -E copy ${FEC_SOURCE}/fec.h ${PREFIX_PATH}/usr/include/fec.h + COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_PATH}/fec/libfec.a ${PREFIX_PATH}/usr/lib/libfec.a + COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_PATH}/fec/libfec.so ${PREFIX_PATH}/usr/lib/libfec.so + DEPENDS build_fec + ) +ADD_CUSTOM_TARGET(install_fec + DEPENDS ${PREFIX_PATH}/usr/lib/libfec.so) + +## Get the dependencies between the sources right: +ADD_DEPENDENCIES(build_gr_osmosdr build_gnuradio) +ADD_DEPENDENCIES(build_ntl build_gmp) +ADD_DEPENDENCIES(build_curlpp build_curl) +ADD_DEPENDENCIES(install_fec prefix) +ADD_DEPENDENCIES(build_gr_ccsds install_fec build_gnuradio build_ldpc build_curlpp) +ADD_DEPENDENCIES(build_gr_fcdproplus build_gnuradio) + +ADD_CUSTOM_TARGET(move2radio) + +ADD_DEPENDENCIES(move2radio build_gr_ccsds build_gr_osmosdr) +ADD_DEPENDENCIES(build_libuhd build_boost build_ncurses) + +ADD_DEPENDENCIES(build_hackrf build_fftw) +ADD_DEPENDENCIES(build_freesrp build_boost) +ADD_DEPENDENCIES(build_rxvt_unicode build_ncurses) + + + +IF(APPIMAGE) + ADD_EXECUTABLE(AppRun AppDir/AppRun.c) + SET(APPDIR ${CMAKE_CURRENT_BINARY_DIR}/AppDir) + FILE(MAKE_DIRECTORY ${APPDIR}) + IF(EXISTS ${APPDIR}) + FILE(REMOVE_RECURSE ${APPDIR}) + ENDIF() + ADD_CUSTOM_COMMAND(OUTPUT ${APPDIR}/AppRun + COMMAND cp -r ${PREFIX_PATH} ${APPDIR} + COMMAND ${CMAKE_COMMAND} -E remove_directory ${APPDIR}/usr/include + COMMAND ${CMAKE_COMMAND} -E remove_directory ${APPDIR}/usr/pkgs + COMMAND ${CMAKE_COMMAND} -E remove_directory ${APPDIR}/usr/ssl + COMMAND rm -rf ${APPDIR}/usr/lib/libuuid.so* + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/AppDir ${APPDIR} + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/AppRun ${APPDIR}/AppRun + DEPENDS AppRun move2radio build_rxvt_unicode) + + ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/squashfs-root/AppRun + COMMAND chmod +x ${DEPS_PATH}/src/appimagetool-x86_64.AppImage + COMMAND ${DEPS_PATH}/src/appimagetool-x86_64.AppImage --appimage-extract + DEPENDS appimagetool) + + ADD_CUSTOM_TARGET(appimagetool_extract + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/squashfs-root/AppRun) + + ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Gnuradio_Companion-x86_64.AppImage + COMMAND env ARCH=x86_64 ${CMAKE_CURRENT_BINARY_DIR}/squashfs-root/AppRun ${APPDIR} + DEPENDS appimagetool_extract ${APPDIR}/AppRun) + + ADD_CUSTOM_TARGET(appimage_build + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Gnuradio_Companion-x86_64.AppImage) + + ADD_DEPENDENCIES(appimage appimage_build) +ENDIF() diff --git a/build/blocks/ccsds_ldpc_decoder.xml b/build/blocks/ccsds_ldpc_decoder.xml new file mode 100644 index 0000000..6e2bf48 --- /dev/null +++ b/build/blocks/ccsds_ldpc_decoder.xml @@ -0,0 +1,85 @@ + + + LDPC Decoder (CCSDS) + ccsds_ldpc_decoder + CCSDS/Channelcoding + import ccsds + ccsds.ldpc_decoder($par_file, $systype.fcn, $puncttype.fcn, $num_punct, tuple($punct_pos)) + + + Paritycheck matrix + par_file + file_open + + + Systematic + systype + ccsds.LDPC_SYS_FRONT + enum + + + + + + Puncturing position + puncttype + ccsds.LDPC_PUNCT_NONE + enum + + + + + + + Number of punctures + num_punct + 0 + int + + + Custom puncturing positions + punct_pos + [] + int_vector + + + $num_punct >= 0 + + + in + message + + + + out + message + + diff --git a/build/blocks/ccsds_ldpc_encoder.xml b/build/blocks/ccsds_ldpc_encoder.xml new file mode 100644 index 0000000..7a1a484 --- /dev/null +++ b/build/blocks/ccsds_ldpc_encoder.xml @@ -0,0 +1,85 @@ + + + LDPC Encoder (CCSDS) + ccsds_ldpc_encoder + CCSDS/Channelcoding + import ccsds + ccsds.ldpc_encoder($gen_file, $systype.fcn, $puncttype.fcn, $num_punct, tuple($punct_pos)) + + + Generator matrix + gen_file + file_open + + + Systematic + systype + ccsds.LDPC_SYS_FRONT + enum + + + + + + Puncturing position + puncttype + ccsds.LDPC_PUNCT_NONE + enum + + + + + + + Number of punctures + num_punct + 0 + int + + + Custom puncturing positions + punct_pos + [] + int_vector + + + $num_punct >= 0 + + + in + message + + + + out + message + + diff --git a/build/blocks/ccsds_message_info.xml b/build/blocks/ccsds_message_info.xml new file mode 100644 index 0000000..a2f739e --- /dev/null +++ b/build/blocks/ccsds_message_info.xml @@ -0,0 +1,48 @@ + + + message_info + ccsds_message_info + [ccsds] + import ccsds + ccsds.message_info($prefix, $mode) + + Prefix + prefix + "Message info: " + + + Mode + mode + 10 + enum + + + + + + in + message + + +Print out messages with a timestamp. + +Prefix: String that will be written before the data line(s) + +Modes: + - Silent: Do not write anything + - Compact: Write one line summary of the message + - Full: Write full content of the message + + diff --git a/build/blocks/ccsds_output_counter_cc.xml b/build/blocks/ccsds_output_counter_cc.xml new file mode 100644 index 0000000..d583412 --- /dev/null +++ b/build/blocks/ccsds_output_counter_cc.xml @@ -0,0 +1,35 @@ + + + Output rate counter + ccsds_output_counter_cc + [ccsds] + import ccsds + ccsds.output_counter_cc($block_length) + + Block size + block_length + 1024 + int + + + in + complex + + + in_cpy + complex + 1 + + + out + message + 1 + + +Copies the input complex intput to the (optional) output. + +Counts the number of copied samples and emits a "block_out" message everytime 'Block size' samples have been copied. + +This block is intendet to enable limiting the number of samples queueing up before a transmitter. So far the only block capable of using this messages is the udp_source_rate_idle block. + + diff --git a/build/blocks/ccsds_randomiser_softbits.xml b/build/blocks/ccsds_randomiser_softbits.xml new file mode 100644 index 0000000..39efbd2 --- /dev/null +++ b/build/blocks/ccsds_randomiser_softbits.xml @@ -0,0 +1,56 @@ + + + Pseudo (De)randomiser with Softbits (CCSDS) + ccsds_randomiser_softbits + CCSDS/Telemetry + import ccsds + ccsds.randomiser_softbits($poly,$seed) + + Generating Polynimoal + poly + 0x95 + int + + + Seed + seed + 0xFF + int + + $poly >= 0 + $poly < 256 + $seed >= 0 + $seed < 256 + + in + message + + + out + message + + +Pseudo (De)randomiser +Combines the input frame with a pseudo random sequence by XOR operation. A one +in the PRN sequence will invert the softbit, a zero will copy it untouched. The +pseudo random sequence is generated by an 8-bit linear feedback shift register +(LFSR) as defined in ECSS. + +The pseudo random sequence can be modified by the generating polygon as well as +shifted by choosing a different initial seed state. + +poly: Polynomial that defines the network of the 8 shift registers. The MSB +encodes whether the last shift register (which is used for the output) should be +used to generate the new input while the LSB encodes whether the first shift +register (that holds the input bit of the last step should be used to generate +the output. Or in ECSS definition: The MSB holds the coefficient for x^0 up to +the LSB which holds coefficient x^7. x^8 is not encoded as it is always set (due +to the fact that this is a maximum length 8 bit shift register). The default +value is 0x95 which corresponds to the randomiser defined in ECSS with the +polynomial representation x^8+x^7+x^5+x^3+x^0. + +seed: Initial state of the shift registers. MSB corresponds to the last register +(which will be the output on the next step). Default to all ones as defined in +ECSS. + + diff --git a/build/blocks/ccsds_send_nanolink.xml b/build/blocks/ccsds_send_nanolink.xml new file mode 100644 index 0000000..023d272 --- /dev/null +++ b/build/blocks/ccsds_send_nanolink.xml @@ -0,0 +1,17 @@ + + + Send Nanolink Frames to REST + ccsds_send_nanolink + [ccsds] + import ccsds + ccsds.send_nanolink($url) + + Url + url + "localhost:8082" + + + in + message + + diff --git a/build/blocks/ccsds_soft_to_hard_message.xml b/build/blocks/ccsds_soft_to_hard_message.xml new file mode 100644 index 0000000..edcc9a1 --- /dev/null +++ b/build/blocks/ccsds_soft_to_hard_message.xml @@ -0,0 +1,17 @@ + + + Softbit PDU to Hardbyte PDU + ccsds_soft_to_hard_message + [ccsds]/Conversion + import ccsds + ccsds.soft_to_hard_message() + + in + message + + + out + message + + Convert PDU with softbit payload to PDU with hardbits (compacted to bytes) payload. + diff --git a/build/blocks/ccsds_softbit_msg_sink_f.xml b/build/blocks/ccsds_softbit_msg_sink_f.xml new file mode 100644 index 0000000..90fa469 --- /dev/null +++ b/build/blocks/ccsds_softbit_msg_sink_f.xml @@ -0,0 +1,29 @@ + + + Softbit Message Sink + ccsds_softbit_msg_sink_f + CCSDS/Conversion + import ccsds + ccsds.softbit_msg_sink_f($frame_len) + + Frame length + frame_len + 40 + int + + + in + float + + + out + message + + +Softbit message sink + +Copies portions of Frame length softbits from the input stream to a softbit message. + +Frame length: Length of a frame in (soft)bits. + + diff --git a/build/blocks/ccsds_softbit_msg_source_f.xml b/build/blocks/ccsds_softbit_msg_source_f.xml new file mode 100644 index 0000000..af40094 --- /dev/null +++ b/build/blocks/ccsds_softbit_msg_source_f.xml @@ -0,0 +1,29 @@ + + + Softbit Message Source + ccsds_softbit_msg_source_f + CCSDS/Conversion + import ccsds + ccsds.softbit_msg_source_f($frame_len) + + Frame length + frame_len + 40 + int + + + in + message + + + out + float + + +Softbit message source + +Copies the floats contained in the incomming Softbit messages to the output stream. + +Frame length: Length of a frame in (soft)bits. + + diff --git a/build/blocks/ccsds_udp_source_rate_idle_b.xml b/build/blocks/ccsds_udp_source_rate_idle_b.xml new file mode 100644 index 0000000..fb2f88d --- /dev/null +++ b/build/blocks/ccsds_udp_source_rate_idle_b.xml @@ -0,0 +1,100 @@ + + + Rate controled UDP source with idle frames + ccsds_udp_source_rate_idle_b + [ccsds] + 1 + import ccsds + ccsds.udp_source_rate_idle_b($host_recv, $port_recv, $host_ctl, $port_ctl, $max_frame_length, $block_len, $num_blocks_floating, $idle_pattern) + + Hostname (data) + host_recv + 'localhost' + string + + + Port (data) + port_recv + int + + + Hostname (control) + host_ctl + 'localhost' + string + + + Port (control) + port_ctl + int + + + Max Frame length (Bytes) + max_frame_length + 1024 + int + + + Block size (Bytes) + block_len + 1024 + int + + + Num. blocks floating + num_blocks_floating + 10 + int + + + Idle pattern + idle_pattern + [0x00, 0xFF,]*12 + raw + + $port_recv > 0 + $port_ctl > 0 + $max_frame_length > 0 + $block_len > 0 + $num_blocks_floating > 0 + + in + message + + + out + byte + + +UDP source with rate control and idle pattern insertion + +This block will keep 'Num. blocks floating' blocks of 'Block size' bytes in the downstream processing. It receives "block_out" messages from a downstream block to be notified once a block has left the processing chain at that block and a new one should be inserted by the source. + +It receives datagrams of a maximum size of 'Max Frame length' Bytes over the UDP socket listening to the data hostname and port and buffers them internally. If the internal buffer holds more data than what could be send out in 1 block, it sends a control datagram with the 's' Byte (encoded in ASCII) to the control hostname and port. Once the buffer contains less data than required to fill a complete block, it will send a 'g' Byte (encoded in ASCII) to the control hostname and port. + +If a new block has to be send out and there is not enough data in the internal buffer to complete the block, (multiple) copies of the idle patterns are inserted at the back of the buffer. + +If an element in the buffer does not completely fit into the current block to be send it is split, such that the rest of the element is send as first item of the next block. + +The only block so far that provides the "block_out" message is the output_counter block. + + +'Hostname (data)' and 'Port (data)': + Hostname and port for the UDP socket on which the data arrives and is stored in the internal buffer. The block will bind to this socket (UDP Server). + +'Hostname (control)' and 'Port (control)': + Target hostname and port for the control datagrams 's' and 'g'. The block will only send to this socket, but not bind to it (UDP Client). + +'Max Frame length': + Maximum frame (datagram) length in Bytes that can be received over the data socket. This value is only used for buffer allocation. + +'Block size': + Number of bytes that constitute one data block. The value entered here must correspond to the block size parameter of the downstream block that provides the "block_out" messages or the flowgrapg between the two blocks will fill up, or run empty over time. + +'Num. blocks floating': + Number of data blocks that should be in the flowgraph at the same time. + +'Idle pattern': + Python vector of Bytes that form the idle pattern. Everytime a new data block has to be send out and there is not enough data in the internal buffer to fill this data block, one or multiple copies of the idle pattern are added to the end of the internal buffer in order to be able to complete the data block transmission. If transmitted, the idle pattern is always transmitted completely. + + diff --git a/build/fakeserver/server.py b/build/fakeserver/server.py new file mode 100644 index 0000000..8e4dcf4 --- /dev/null +++ b/build/fakeserver/server.py @@ -0,0 +1,64 @@ +from sys import argv +from http.server import BaseHTTPRequestHandler, HTTPServer +import logging +import json + +class FakeServer(BaseHTTPRequestHandler): + def _set_response(self, code=200): + self.send_response(code) + self.send_header('Content-type', 'application/json') + self.end_headers() + + def do_GET(self): + logging.info("GET request, Path: %s\n", str(self.path)) + + code = 404 + reponse = '{}' + if self.path == "/session": + code = 200 + response = '{"session":"15700771d1262b8e"}' + + self._set_response(code=code) + self.wfile.write(response.encode('utf-8')) + + def do_POST(self): + content_length = int(self.headers['Content-Length']) + post_data = self.rfile.read(content_length) + + logging.info("POST request, Path: %s\nBody:\n%s\n", + str(self.path), post_data.decode('utf-8')) + + code = 404 + response = '{}' + + if self.path == '/nanolink': + data = json.loads(post_data.decode('utf-8')) + logging.info("DATA: " + data['nanolink_frame']) + global frames + frames.write(data['nanolink_frame'] + '\n') + frames.flush() + code = 200 + + self._set_response(code=code) + self.wfile.write(response.encode('utf-8')) + +def run(server_class=HTTPServer, handler_class=FakeServer, port=8000): + logging.basicConfig(level=logging.INFO) + server_address = ('', port) + httpd = server_class(server_address, handler_class) + logging.info('Starting httpd...\n') + try: + httpd.serve_forever() + except KeyboardInterrupt: + pass + httpd.server_close() + logging.info('Stopping httpd...\n') + +if __name__ == '__main__': + file = '/app/data/output/frames.txt' + if len(argv) > 1: + file = argv[1] + + with open(file, "a") as frames: + frames.write('\n') + run() \ No newline at end of file diff --git a/build/run.sh b/build/run.sh new file mode 100644 index 0000000..f6592c9 --- /dev/null +++ b/build/run.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +mkdir -p /app/data/output +touch /app/data/output/frames.txt +python3 /app/fakeserver/server.py & + +gnuradio-companion \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index be4300d..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,12 +0,0 @@ -version: '3' - -services: - move2: - build: - context: . - args: - - PROP_SERVER - - PROP_SERVER_USER - - PROP_SERVER_KEY - - PROP_DIR_SDR - - PROP_DIR_DECODER \ No newline at end of file diff --git a/scripts/build.sh b/scripts/build.sh index 7f830d0..8d92868 100644 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -3,4 +3,7 @@ cd "${0%/*}/.." source ./config/config.sh export PROP_SERVER_KEY=$(cat ./config/id_rsa) -docker-compose build \ No newline at end of file + +docker build \ + --build-arg PROP_SERVER --build-arg PROP_SERVER_USER --build-arg PROP_SERVER_KEY \ + --build-arg PROP_DIR_SDR --build-arg PROP_DIR_DECODER -t move2docker-dev . \ No newline at end of file diff --git a/scripts/buildx.sh b/scripts/buildx.sh new file mode 100644 index 0000000..7471108 --- /dev/null +++ b/scripts/buildx.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +cd "${0%/*}/.." +source ./config/config.sh +export PROP_SERVER_KEY=$(cat ./config/id_rsa) + +docker buildx build --platform linux/arm/v7 \ + --build-arg PROP_SERVER --build-arg PROP_SERVER_USER --build-arg PROP_SERVER_KEY \ + --build-arg PROP_DIR_SDR --build-arg PROP_DIR_DECODER -t move2docker:latest . \ No newline at end of file diff --git a/scripts/run.sh b/scripts/run.sh new file mode 100644 index 0000000..fc3e3c7 --- /dev/null +++ b/scripts/run.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker run -it --rm -v ./data:/app/data:rw --env DISPLAY=host.docker.internal:0.0 move2docker-dev \ No newline at end of file