1#!/usr/bin/env bash
2# Copyright 2023 Nordic Semiconductor ASA
3# SPDX-License-Identifier: Apache-2.0
4
5source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
6
7dut_exe="bs_${BOARD_TS}_$(guess_test_long_name)_dut_prj_conf"
8tester_exe="bs_${BOARD_TS}_$(guess_test_long_name)_tester_prj_conf"
9
10simulation_id="misc_disconnect"
11verbosity_level=2
12sim_length_us=10e6
13
14cd ${BSIM_OUT_PATH}/bin
15
16Execute ./bs_2G4_phy_v1 \
17    -v=${verbosity_level} -s="${simulation_id}" -D=2 -sim_length=${sim_length_us} $@
18
19Execute "./$tester_exe" \
20    -v=${verbosity_level} -s="${simulation_id}" -d=1 -testid=tester -RealEncryption=0 -rs=100
21
22Execute "./$dut_exe" \
23    -v=${verbosity_level} -s="${simulation_id}" -d=0 -testid=dut -RealEncryption=0
24
25# wait_for_background_jobs, but doesn't exit on error
26exit_code=0
27for process_id in $_process_ids; do
28wait $process_id || let "exit_code=$?"
29done
30
31# Make pcaps
32for j in {0..1}; do
33    i=$(printf '%02i' $j)
34
35    ${BSIM_OUT_PATH}/components/ext_2G4_phy_v1/dump_post_process/csv2pcap -o \
36    ${BSIM_OUT_PATH}/results/${simulation_id}/Trace_$i.Tx.pcap \
37    ${BSIM_OUT_PATH}/results/${simulation_id}/d_2G4_$i.Tx.csv
38
39    ${BSIM_OUT_PATH}/components/ext_2G4_phy_v1/dump_post_process/csv2pcap -o \
40    ${BSIM_OUT_PATH}/results/${simulation_id}/Trace_$i.Rx.pcap \
41    ${BSIM_OUT_PATH}/results/${simulation_id}/d_2G4_$i.Rx.csv
42
43    echo "${BSIM_OUT_PATH}/results/${simulation_id}/Trace_$i.Tx.pcap"
44    echo "${BSIM_OUT_PATH}/results/${simulation_id}/Trace_$i.Rx.pcap"
45done
46
47exit $exit_code
48