Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ include_directories(${SPT3G_DIR}/core/src)
include_directories(${SO3G_DIR}/include)
include_directories(/usr/include/python3.10)
include_directories(${PROJECT_SOURCE_DIR}/include/) # rfsoc-streamer/include
include_directories(/opt/venv/lib/python3.10/site-packages/numpy/core/include)

# Create rfsoc python library
set(SRC_FILES ${PROJECT_SOURCE_DIR}/src/RfsocBuilder.cxx ${PROJECT_SOURCE_DIR}/src/RfsocTransmitter.cxx ${PROJECT_SOURCE_DIR}/src/python.cpp)
Expand Down
91 changes: 91 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
FROM ubuntu:22.04

# Installing needed packages
RUN apt-get update && apt-get install -y gcc \
g++ make git python3-dev python3-pip \
python3.10-venv libboost-all-dev \
libopenblas-openmp-dev libflac-dev \
bzip2 libbz2-dev libgsl-dev

# Workaround for build issue with so3g needing specifically the 'python' executable
RUN ln -s /usr/bin/python3.10 /usr/bin/python

# Make sure files belong to ocs user and group
RUN groupadd -g 9000 ocs && \
useradd -m -l -u 9000 -g 9000 ocs

# Setting up virtual environment
RUN python3 -m venv /opt/venv/
ENV PATH="/opt/venv/bin:$PATH"
RUN python3 -m pip install -U pip
# Installing cmake here instead of with apt-get
# to avoid version issues later with so3g's
# requirements.txt file installing cmake with pip
RUN python3 -m pip install cmake

# Guaranteeing that there will be a common build directory for socs/spt3g
WORKDIR /usr/local/so3g
WORKDIR /usr/local/src

ENV SO3G_DIR=/usr/local/src/so3g
ENV SPT3G_DIR=/usr/local/src/spt3g_software
ENV SPT3G_SOFTWARE_PATH=/usr/local/src/spt3g_software
ENV RFSOC_DIR=/usr/local/src/rfsoc-streamer
ENV LD_LIBRARY_PATH=/usr/local/so3g/lib:/usr/local/so3g/so3g
ENV STREAM_CONFIG_DIR=/config
ENV SPT3G_SOFTWARE_BUILD_PATH=${SPT3G_DIR}/build
ENV SO3G_BUILD_PATH=/usr/local/so3g/lib

# Clone all repos
RUN git clone https://github.com/CMB-S4/spt3g_software.git
RUN git clone https://github.com/simonsobs/so3g.git
#RUN git clone https://github.com/ccatobs/rfsoc-streamer.git
COPY . /usr/local/src/rfsoc-streamer

# Install spt3g
WORKDIR /usr/local/src/spt3g_software/build

RUN cmake \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_COMPILER="gcc" \
-DCMAKE_CXX_COMPILER="g++" \
-DCMAKE_C_FLAGS="-O3 -g -fPIC" \
-DCMAKE_CXX_FLAGS="-O3 -g -fPIC -std=c++11" \
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
-DPython_EXECUTABLE:FILEPATH=$(which python3) \
-DCMAKE_INSTALL_PREFIX="/usr/local/so3g" \
..

RUN make -j 4
RUN make install

# Install so3g
WORKDIR /usr/local/src/so3g
RUN pip install -r requirements.txt
WORKDIR /usr/local/src/so3g/build

RUN cmake \
-DCMAKE_PREFIX_PATH='/usr/local/src/spt3g_software/build' \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
-DPYTHON_INSTALL_DEST="/usr/local/so3g" \
-DCMAKE_INSTALL_PREFIX="/usr/local/so3g" \
..

RUN make -j 4
RUN make install

# Install rfsoc-streamer
WORKDIR /usr/local/src/rfsoc-streamer
RUN cmake .
RUN make

# There is no PYTHONPATH to start, so no need to append it to the end here
ENV PYTHONPATH="${RFSOC_DIR}/lib:${RFSOC_DIR}/python:$SPT3G_SOFTWARE_BUILD_PATH:$SO3G_BUILD_PATH"
ENV PATH="/usr/local/so3g/bin:${PATH}"

RUN pip install dumb-init

# The command to run stream.py will be in the docker-compose.yml file
# for more granular user control
ENTRYPOINT ["dumb-init", /bin/bash]
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ cmake \
-DCMAKE_INSTALL_PREFIX="${HOME}/so3g" \
..

make
make -j 4
make install
#
cd ~/git/so3g
Expand All @@ -76,7 +76,7 @@ cmake \
-DCMAKE_INSTALL_PREFIX="${HOME}/so3g" \
..

make
make -j 4
make install
#
```
Expand All @@ -93,15 +93,15 @@ cd ~/git/rfsoc-streamer
cmake . # this will create multiple cmake-related files and a Makefile
make # or "VERBOSE=1 make" if you want more information printed out during make

python test/stream.py
python scripts/stream.py

# run this for a little while, then terminate with Ctrl-C
# this should produce one more g3 files under ~/data/g3, with timestamp information distinguishing files

# if you want to either write to a different directory,
# or receive packets from a different IP address,
# or change the file_dur (file duration before rotating),
# modify the code in test/stream.py and re-run the python code
# modify the code in scripts/stream.py and re-run the python code
```

### Pure C++ version
Expand All @@ -111,7 +111,7 @@ cd ~/git/rfsoc-streamer
cd src
make

cd ../test
cd ../scripts
make

./stream_min_example
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions test/stream_config.yaml → scripts/stream_config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
g3_dir: /home/streamer/data/g3/ # path to top level detector file directory
file_rotation_time: 600 #60*10 # time before rotating files in seconds
g3_dir: /data/g3/ # path to top level detector file directory in Docker container
file_rotation_time: 600 # time before rotating files in seconds

# Board and drone specific settings for all active RFSoCs
# stream IDs must have format rfsoc##_drone# - this is parsed to use in filenames
Expand Down
File renamed without changes.
5 changes: 1 addition & 4 deletions src/RfsocTransmitter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
#include <sys/socket.h>
#include <arpa/inet.h>

#define RECEIVE_IP "192.168.3.40" // The receiving computer IP
//#define CONNECT_IP "192.168.3.58" // The drone IP address from which to receive packets
// The ports are currently hardcoded - the IP addresses differ for different drones
#define RECEIVE_PORT 4096
#define CONNECT_PORT 4096

Expand All @@ -47,7 +46,6 @@ void RfsocTransmitter::dataTransmit(RfsocPacketPtr rp){
builder_->AsyncDatum(ts.time, rfsoc_sample);
}

// borrowing from Ben's code - just listening for anything on network that arrives at BROADCAST_IP
int RfsocTransmitter::SetupUDPSocket()
{
struct sockaddr_in rx_addr;
Expand Down Expand Up @@ -119,7 +117,6 @@ int RfsocTransmitter::Stop()
return (0);
}

//Adapted to use Ben's code, but could go back to DfMuxCollectors's recvfrom
void RfsocTransmitter::Listen(RfsocTransmitter *transmitter)
{
ssize_t len;
Expand Down