diff --git a/cmake_targets/tools/run_enb_ue_virt_s1 b/cmake_targets/tools/run_enb_ue_virt_s1 index 343bb46120addc9493fc8cfda110399aea568bfc..b23b99a87cde38304b3b289e8007409e93065439 100755 --- a/cmake_targets/tools/run_enb_ue_virt_s1 +++ b/cmake_targets/tools/run_enb_ue_virt_s1 @@ -72,14 +72,92 @@ function is_tun_interface() echo "$my_bool" } -# $1 is enb_config file + +function help() +{ + echo_error " " + echo_error "Usage: start_enb_ue_virt_s1 [OPTION]..." + echo_error "Run the eNB and/or UE executable with no hardware." + echo_error " " + echo_error "Options:" + echo_error "Mandatory arguments to long options are mandatory for short options too." + echo_error " -c, -C, --config-file eNB_config_file eNB config file, (see $OPENAIR_DIR/targets/PROJECTS/GENERIC-LTE-EPC/CONF)" + echo_error " -g, --gdb Run with GDB." + echo_error " -h, --help Print this help." + echo_error " -K, --itti-dump-file filename ITTI dump file containing all ITTI events occuring during EPC runtime.(can omit file name if last argument)" + echo_error " -V, --vcd Dump timings of processing in a GTKWave compliant file format." + echo_error " -x, --xforms Run XFORMS scope windows." +} + + + function main() { + + local -i run_gdb=0 + local exe_arguments="" + local CONFIG_FILE_ENB=$OPENAIR_DIR/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.generic.oaisim.local_mme.conf + + until [ -z "$1" ] + do + case "$1" in + -c | -C | --config-file) + CONFIG_FILE_ENB=$2 + # may be relative path + if [ -f $(dirname $(readlink -f $0))/$CONFIG_FILE ]; then + CONFIG_FILE_ENB=$(dirname $(readlink -f $0))/$CONFIG_FILE + echo "setting config file to: $CONFIG_FILE" + CONFIG_FILE_ACCESS_OK=1 + else + # may be absolute path + if [ -f $CONFIG_FILE_ENB ]; then + echo "setting config file to: $CONFIG_FILE_ENB" + else + echo_fatal "config file $CONFIG_FILE_ENB not found" + fi + fi + exe_arguments="$exe_arguments --enb-conf $CONFIG_FILE_ENB" + shift 2; + ;; + -g | --gdb) + run_gdb=1 + echo "setting GDB flag to: $GDB" + shift; + ;; + -h | --help) + help + shift; + exit 0 + ;; + -K | --itti-dump-file) + ITTI_DUMP_FILE=$2 + # can omit file name if last arg on the line + if [ "x$ITTI_DUMP_FILE" = "x" ]; then + ITTI_DUMP_FILE="/tmp/itti_enb_ue_s1.log" + shift 1; + else + shift 2; + fi + echo "setting ITTI dump file to: $ITTI_DUMP_FILE" + exe_arguments="$exe_arguments -K $ITTI_DUMP_FILE" + ;; + + -V | --vcd) + "setting gtk-wave output" + exe_arguments="$exe_arguments -V /tmp/oai_gtk_wave.vcd" + shift ; + ;; + *) + echo "Unknown option $1" + help + exit 0 + ;; + esac + done + set_openair_env cecho "OPENAIR_DIR = $OPENAIR_DIR" $green - local CONFIG_FILE_ENB=$OPENAIR_DIR/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.generic.oaisim.local_mme.conf - ####################################################### # SOURCE CONFIG FILE @@ -135,12 +213,19 @@ function main() $SUDO ip rule add fwmark 5 table lte $SUDO ip route add default dev oip1 table lte - - gdb --args $OPENAIR_DIR/targets/bin/oaisim \ - -u1 -l9 \ - -K itti_enb_ue_s1.log \ - --enb-conf $OPENAIR_DIR/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.generic.oaisim.local_mme.conf | tee stdout_enb_ue_s1.log - + exe_arguments="$exe_arguments -u1 -l9" + + if [ $run_gdb -eq 0 ]; then + exec $OPENAIR_DIR/targets/bin/oaisim $exe_arguments + else + touch ~/.gdb_enb_ue_s1 + chmod 777 ~/.gdb_enb_ue_s1 + echo "file $OPENAIR_DIR/targets/bin/oaisim" > ~/.gdb_enb_ue_s1 + echo "set args $exe_arguments" >> ~/.gdb_enb_ue_s1 + echo "run" >> ~/.gdb_enb_ue_s1 + cat ~/.gdb_enb_ue_s1 + gdb -n -x ~/.gdb_enb_ue_s1 2>&1 + fi } main "$@"