From e16d4de7ef43ba74f93b337ba3ea4046b287365c Mon Sep 17 00:00:00 2001
From: Petr Zejdl <petr.zejdl@cern.ch>
Date: Mon, 23 May 2022 12:17:20 +0200
Subject: [PATCH] Revert "Add script to build RPM"

---
 etc/scdaq/scdaq.conf                   |  92 -----------
 scripts/reset-firmware.sh              |   2 +-
 scripts/run.sh                         |   2 +-
 scripts/scdaqrpm.sh                    | 216 -------------------------
 scripts/vivado/reset.sh                |   4 +-
 scripts/vivado/reset_scouting-proc.tcl |   6 +-
 scripts/vivado/reset_server.sh         |   4 +-
 scripts/vivado/reset_server.tcl        |   6 +-
 src/scdaq.cc                           |  10 +-
 src/scdaq.conf                         |   1 +
 10 files changed, 16 insertions(+), 327 deletions(-)
 delete mode 100644 etc/scdaq/scdaq.conf
 delete mode 100755 scripts/scdaqrpm.sh
 create mode 120000 src/scdaq.conf

diff --git a/etc/scdaq/scdaq.conf b/etc/scdaq/scdaq.conf
deleted file mode 100644
index 214df555..00000000
--- a/etc/scdaq/scdaq.conf
+++ /dev/null
@@ -1,92 +0,0 @@
-################################################################################
-##
-## Input settings
-##
-################################################################################
-
-# Input settings, allowed values are:
-#   "wzdma"     for DMA driver from Wojciech M. Zabolotny
-#   "dma"       for XILINX DMA driver
-#   "filedma"   for reading from file and simulating DMA
-#
-input:wzdma
-
-## Settings for DMA input
-
-# DMA device
-dma_dev:/dev/xdma0_c2h_0
-
-# Max received packet size in bytes (buffer to reserve)
-dma_packet_buffer_size:1048576
-
-# Number of packet buffers to allocate
-dma_number_of_packet_buffers:1000
-
-# Print report each N packets, use 0 to disable
-packets_per_report:200000
-
-
-## Extra settings for "filedma" input
-
-#input_file:/dev/shm/testdata.bin
-input_file:testdata.bin
-
-
-################################################################################
-##
-## Stream processor settings
-##
-################################################################################
-
-enable_stream_processor:yes
-
-# Define processing type (unpacking), allowed values are:
-#   "PASS_THROUGH"
-#   "GMT"
-#
-# Note: When changing the processing type, change also "output_filename_prefix"
-# in the file output section.
-#
-processor_type:PASS_THROUGH
-
-# Enable software zero-supression
-doZS:no
-
-
-################################################################################
-##
-## File output settings
-##
-################################################################################
-
-output_filename_prefix:scout_pass_through
-
-output_filename_base:/fff/BU0/ramdisk/scdaq
-max_file_size:8589934592
-
-# Always write data to a file regardless of the run status, useful for debugging
-output_force_write:no
-
-
-################################################################################
-##
-## Elastics processor settings (obsolete)
-##
-################################################################################
-
-enable_elastic_processor:no
-
-port:8000
-elastic_url:http://something.somewhere
-pt_cut:7
-quality_cut:12
-
-
-################################################################################
-##
-## SCDAQ Generic Settings
-##
-################################################################################
-
-# Pipeline settings
-threads:8
diff --git a/scripts/reset-firmware.sh b/scripts/reset-firmware.sh
index 1a9c5c25..2522fcda 100755
--- a/scripts/reset-firmware.sh
+++ b/scripts/reset-firmware.sh
@@ -1,2 +1,2 @@
 #!/bin/sh
-echo "reset" | nc localhost 12345
+echo "reset" | nc scoutsrv-s1d12-38-01 12345
diff --git a/scripts/run.sh b/scripts/run.sh
index 2500761d..0d6feab4 100755
--- a/scripts/run.sh
+++ b/scripts/run.sh
@@ -14,7 +14,7 @@ umask 000 # Files and folders we create should be world accessible
 while true 
 do
     echo "Starting scdaq..."
-    /opt/scdaq/bin/scdaq /etc/scdaq/scdaq.conf 2>&1 | logger --tag scdaq --id -p user.debug
+    ./scdaq 2>&1 | logger --tag scdaq --id -p user.debug
     echo "Resetting the board..."
     ../scripts/reset-firmware.sh
     echo "Clearing caches..."
diff --git a/scripts/scdaqrpm.sh b/scripts/scdaqrpm.sh
deleted file mode 100755
index 2596b77d..00000000
--- a/scripts/scdaqrpm.sh
+++ /dev/null
@@ -1,216 +0,0 @@
-#!/bin/bash -e
-BUILD_ARCH=x86_64
-SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-RHEL_MAJOR=`cat /etc/redhat-release | cut -d' ' -f4 | cut -d'.' -f1`
-
-echo "Checking if necessary build packages are installed..."
-if [ "$RHEL_MAJOR" = "7" ]; then
-  if ! rpm -q rpm-build; then
-    echo "\nPlease install missing packages.";
-    exit 1;
-  fi
-else
-  if ! rpm -q gcc redhat-rpm-config rpm-build zlib-devel; then
-    echo "";
-    echo "Please install missing packages.";
-    exit 1;
-  fi
-fi
-echo "..Build dependencies OK"
-echo ""
-
-cd $SCRIPTDIR/..
-BASEDIR=$PWD
-PARAMCACHE="paramcache"
-NLINES=1
-ASK="1"
-
-if [ -n "$1" ]; then
-  if [ "$1" = "--batch" ]; then
-  ASK="0"
-  fi
-
-  if [ "$1" = "-b" ]; then
-  ASK="0"
-  fi
-
-  if [ $ASK = "0" ]; then #check $2 if found
-    if [ -n "$2" ]; then
-            PARAMCACHE=${2##*/}
-    fi
-  fi
-  if [ $ASK = "1" ]; then #take $1 
-    PARAMCACHE=${1##*/}
-  fi
-fi
-
-echo "Using cache file $PARAMCACHE"
-
-if [ -f $SCRIPTDIR/$PARAMCACHE ];
-then
-  readarray lines < $SCRIPTDIR/$PARAMCACHE
-  for (( i=0; i < ${NLINES}; i++ ))
-  do
-    lines[$i]=`echo -n ${lines[$i]} | tr -d "\n"`
-  done
-else
-  for (( i=0; i < ${NLINES}; i++ ))
-  do
-    lines[$i]=""
-  done
-fi
-
-if [ $ASK = "1" ]; then
-
-echo "This is the scdaq build script. It will now ask for several configuration parameters."
-echo "Use -b cmdline parameter to build from cache without waiting for input"
-echo "   ... press any key to continue ..."
-read readin
-
-echo "Dummy parameter, this will be used to modify/obtain build parameters from cache (press enter for \"${lines[0]}\"):"
-readin=""
-read readin
-if [ ${#readin} != "0" ]; then
-lines[0]=$readin
-fi
-
-fi #ask
-
-#update cache file
-if [ -f $SCRIPTDIR/$PARAMCACHE ];
-then
-    rm -rf -f $SCRIPTDIR/$PARAMCACHE
-fi
-for (( i=0; i < ${NLINES}; i++ ))
-do
-  echo ${lines[$i]} >> $SCRIPTDIR/$PARAMCACHE
-done
-
-PACKAGENAME="scdaq"
-
-# set the RPM build architecture
-#BUILD_ARCH=$(uname -i)      # "i386" for SLC4, "x86_64" for SLC5
-
-cd $SCRIPTDIR/..
-BASEDIR=$PWD
-
-# create a build area
-echo "removing old build area"
-rm -rf /tmp/$PACKAGENAME-build-tmp
-echo "creating new build area"
-mkdir  /tmp/$PACKAGENAME-build-tmp
-cd     /tmp/$PACKAGENAME-build-tmp
-#mkdir BUILD
-#mkdir RPMS
-TOPDIR=$PWD
-echo "working in $PWD"
-#ls
-
-
-# we are done here, write the specs and make the fu***** rpm
-cat > scoutdaq.spec << EOF
-Name: $PACKAGENAME$pkgsuffix
-Version: 0.1.0
-Release: 0%{?dist}
-Summary: scouting daq
-License: gpl
-Group: DAQ
-Packager: meschi
-Source: none
-%define _tmppath $TOPDIR/scdaq-build
-BuildRoot: %{_tmppath}
-BuildArch: $BUILD_ARCH
-AutoReqProv: no
-Provides:/opt/scdaq
-
-Requires: tbb boost-thread libcurl
-Obsoletes: scdaq
-
-%description
-scouting daq 
-
-%prep
-
-echo "PIPPPPPPPPO"
-echo $RPM_SOURCE_DIR
-echo "PIPPOOOOOOOOO"
-echo $BASEDIR
-cp -R $BASEDIR/src SOURCES/
-
-%build
-echo $RPM_SOURCE_DIR
-cd SOURCES
-pwd
-make
-
-%install
-echo $RPM_SOURCE_DIR
-rm -rf \$RPM_BUILD_ROOT
-mkdir -p \$RPM_BUILD_ROOT
-%__install -d "%{buildroot}/var/cache/scdaq"
-%__install -d "%{buildroot}/var/log/scdaq"
-%__install -d "%{buildroot}/var/log/scdaq/pid"
-%__install -d "%{buildroot}/opt/scdaq"
-%__install -d "%{buildroot}/opt/scdaq/init.d"
-%__install -d "%{buildroot}/opt/scdaq/bin"
-
-
-cd \$RPM_BUILD_ROOT
-echo "Creating directories"
-mkdir -p opt/scdaq
-mkdir -p etc/scdaq
-mkdir -p etc/logrotate.d
-mkdir -p usr/lib/systemd/system
-#mkdir -p %{buildroot}/usr/lib/systemd/system 
-mkdir -p etc/init.d
-#mkdir -p %{buildroot}/opt/scdaq/init.d
-
-echo "Copying files to their destination"
-cp $BASEDIR/init.d/runSCdaq.service      usr/lib/systemd/system/runSCdaq.service
-cp $BASEDIR/init.d/scoutboardResetServer.service usr/lib/systemd/system/scoutboardResetServer.service
-cp -R $BASEDIR/*                    opt/scdaq
-echo "PIPPOOOOOOOOOOO"
-pwd
-cp $TOPDIR/RPMBUILD/BUILD/SOURCES/scdaq opt/scdaq/bin/
-cp -R $BASEDIR/etc/scdaq/scdaq.conf        etc/scdaq/
-#cp -R $BASEDIR/etc/logrotate.d/scdaq etc/logrotate.d/
-#rm -rf opt/hltd/init.d
-
-#touch opt/scdaq/scratch/new-version
-
-echo "Deleting unnecessary files"
-rm -rf opt/hltd/{bin,rpm,lib}
-rm -rf opt/hltd/scripts/paramcache*
-rm -rf opt/hltd/scripts/*rpm.sh
-#rm -rf opt/hltd/scripts/postinstall.sh
-
-
-%post
-#/opt/scdaq/postinstall.sh
-systemctl daemon-reload
-
-%files
-%dir %attr(777, -, -) /var/cache/scdaq
-%dir %attr(777, -, -) /var/log/scdaq
-%dir %attr(777, -, -) /var/log/scdaq/pid
-%defattr(-, root, root, -)
-/opt/scdaq/
-%config /etc/scdaq/scdaq.conf
-#/etc/logrotate.d/scdaq
-%attr( 644 ,root, root) /usr/lib/systemd/system/runSCdaq.service
-%attr( 644 ,root, root) /usr/lib/systemd/system/scoutboardResetServer.service
-#%attr( 755 ,root, root) /opt/scdaq/init.d/
-#%attr( 755 ,root, root) /opt/scdaq/init.d/
-
-
-%preun
-if [ \$1 == 0 ]; then
-  /usr/bin/systemctl stop runSCdaq || true
-  /usr/bin/systemctl disable runSCdaq || true
-  /usr/bin/systemctl stop scoutboardResetServer || true
-  /usr/bin/systemctl disable scoutboardResetServer || true
-fi
-EOF
-mkdir -p RPMBUILD/{RPMS/{noarch},SPECS,BUILD,SOURCES,SRPMS}
-rpmbuild --define "_topdir `pwd`/RPMBUILD" -bb scoutdaq.spec
-#rm -rf patch-cmssw-tmp
diff --git a/scripts/vivado/reset.sh b/scripts/vivado/reset.sh
index 207f824c..4cbe46cc 100755
--- a/scripts/vivado/reset.sh
+++ b/scripts/vivado/reset.sh
@@ -1,3 +1,3 @@
 #!/bin/sh
-source /opt/Xilinx/Vivado_Lab/2018.3/settings64.sh
-vivado_lab -mode batch -source reset_scouting-proc.tcl
+source /opt/Xilinx/Vivado/2018.2/settings64.sh
+vivado -mode batch -source reset_scouting-proc.tcl
diff --git a/scripts/vivado/reset_scouting-proc.tcl b/scripts/vivado/reset_scouting-proc.tcl
index d6fb7607..7873053e 100644
--- a/scripts/vivado/reset_scouting-proc.tcl
+++ b/scripts/vivado/reset_scouting-proc.tcl
@@ -3,9 +3,9 @@ connect_hw_server -url localhost:3121
 current_hw_target [get_hw_targets */xilinx_tcf/Xilinx/1234-tulA]
 set_property PARAM.FREQUENCY 15000000 [get_hw_targets */xilinx_tcf/Xilinx/1234-tulA]
 open_hw_target
-set_property PROGRAM.FILE {/home/scouter/bitfiles/currently_used/scouting_build.bit} [get_hw_devices xcku115_0]
-set_property PROBES.FILE {/home/scouter/bitfiles/currently_used/scouting_build.ltx} [get_hw_devices xcku115_0]
-set_property FULL_PROBES.FILE {/home/scouter/bitfiles/currently_used/scouting_build.ltx} [get_hw_devices xcku115_0]
+set_property PROGRAM.FILE {/home/scouter/bitfiles/eight_links_zs/top.bit} [get_hw_devices xcku115_0]
+set_property PROBES.FILE {/home/scouter/bitfiles/eight_links_zs/top.ltx} [get_hw_devices xcku115_0]
+set_property FULL_PROBES.FILE {/home/scouter/bitfiles/eight_links_zs/top.ltx} [get_hw_devices xcku115_0]
 current_hw_device [get_hw_devices xcku115_0]
 refresh_hw_device [lindex [get_hw_devices xcku115_0] 0]
 
diff --git a/scripts/vivado/reset_server.sh b/scripts/vivado/reset_server.sh
index 0ef4eb69..7ef8fb8a 100755
--- a/scripts/vivado/reset_server.sh
+++ b/scripts/vivado/reset_server.sh
@@ -1,3 +1,3 @@
 #!/bin/sh
-source /opt/Xilinx/Vivado_Lab/2018.3/settings64.sh
-vivado_lab -mode batch -source reset_server.tcl
+source /opt/Xilinx/Vivado/2018.2/settings64.sh
+vivado -mode batch -source reset_server.tcl
diff --git a/scripts/vivado/reset_server.tcl b/scripts/vivado/reset_server.tcl
index e6f5ae0f..f31dce91 100644
--- a/scripts/vivado/reset_server.tcl
+++ b/scripts/vivado/reset_server.tcl
@@ -7,9 +7,9 @@ proc init_hw {} {
     current_hw_target [get_hw_targets */xilinx_tcf/Xilinx/1234-tulA]
     set_property PARAM.FREQUENCY 15000000 [get_hw_targets */xilinx_tcf/Xilinx/1234-tulA]
     open_hw_target
-    set_property PROGRAM.FILE {/home/scouter/bitfiles/currently_used/scouting_build.bit} [get_hw_devices xcku115_0]
-    set_property PROBES.FILE {/home/scouter/bitfiles/currently_used/scouting_build.ltx} [get_hw_devices xcku115_0]
-    set_property FULL_PROBES.FILE {/home/scouter/bitfiles/currently_used/scouting_build.ltx} [get_hw_devices xcku115_0]
+    set_property PROGRAM.FILE {/home/scouter/bitfiles/use_with_vivado_2018.2/eight_links_zs_lids_from_protocol/top.bit} [get_hw_devices xcku115_0]
+    set_property PROBES.FILE {/home/scouter/bitfiles/use_with_vivado_2018.2/eight_links_zs_lids_from_protocol/top.ltx} [get_hw_devices xcku115_0]
+    set_property FULL_PROBES.FILE {/home/scouter/bitfiles/use_with_vivado_2018.2/eight_links_zs_lids_from_protocol/top.ltx} [get_hw_devices xcku115_0]
     current_hw_device [get_hw_devices xcku115_0]
     refresh_hw_device [lindex [get_hw_devices xcku115_0] 0]
 }
diff --git a/src/scdaq.cc b/src/scdaq.cc
index a71fd834..f3fb4d93 100644
--- a/src/scdaq.cc
+++ b/src/scdaq.cc
@@ -100,16 +100,12 @@ int run_pipeline(int nbThreads, ctrl &control, config &conf) {
 int main(int argc, char *argv[]) {
   (void)(argc);
   (void)(argv);
-  if (argc < 2) {
-    LOG(ERROR) << "missing argument [conffile] in scdaq invocation";
-    exit(-1);
-  }
-  LOG(DEBUG) << "scdaq started with argument" << argv[1];
+  LOG(DEBUG) << "here 0";
 
   try {
-    config conf(argv[1]);
+    config conf("scdaq.conf");
     conf.print();
-    LOG(DEBUG) << "configuration loaded";
+    LOG(DEBUG) << "here 1";
     ctrl control;
     //    tbb::tick_count mainStartTime = tbb::tick_count::now();
 
diff --git a/src/scdaq.conf b/src/scdaq.conf
new file mode 120000
index 00000000..2553a92e
--- /dev/null
+++ b/src/scdaq.conf
@@ -0,0 +1 @@
+scdaq-calo.conf
\ No newline at end of file
-- 
GitLab