1 /*
2  * Copyright 2018 Oticon A/S
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 #include <limits.h>
7 #include "bs_cmd_line_typical.h"
8 #include "bs_tracing.h"
9 
10 /**
11  * For most devices,
12  * (devices for which the args_struct starts with a BS_BASIC_DEVICE_*_OPTIONS_ARG_STRUCT)
13  * we need to check that the parameters below have been set
14  *
15  * Never call this function unless the device args structure starts with BS_BASIC_DEVICE_OPTIONS_FIELDS
16  */
bs_args_typical_dev_post_check(bs_basic_dev_args_t * a,bs_args_struct_t args_struct[],char * default_phy)17 void bs_args_typical_dev_post_check(bs_basic_dev_args_t *a, bs_args_struct_t args_struct[], char *default_phy) {
18   if (a->device_nbr == UINT_MAX) {
19     bs_args_print_switches_help(args_struct);
20     bs_trace_error_line("The command line option <device number> needs to be set\n");
21   }
22   if (a->global_device_nbr == UINT_MAX) {
23     a->global_device_nbr = a->device_nbr;
24     bs_trace_set_prefix_dev(a->global_device_nbr);
25   }
26   if (!a->s_id) {
27     bs_args_print_switches_help(args_struct);
28     bs_trace_error_line("The command line option <simulation ID> needs to be set\n");
29   }
30   if (!a->p_id) {
31     a->p_id = default_phy;
32   }
33 }
34 
35 /**
36  * For devices for which the args_struct starts with a BS_BASIC_DEVICE_*_OPTIONS_ARG_STRUCT,
37  * this function sets their defaults properly
38  *
39  * Never call this function unless the device args structure starts with BS_BASIC_DEVICE_OPTIONS_FIELDS
40  */
bs_args_typical_dev_set_defaults(bs_basic_dev_args_t * a,bs_args_struct_t args_struct[])41 void bs_args_typical_dev_set_defaults(bs_basic_dev_args_t *a, bs_args_struct_t args_struct[]) {
42   bs_args_set_defaults(args_struct);
43   a->verb         = 2;
44   bs_trace_set_level(a->verb);
45   a->rseed        = 0xFFFF;
46   a->start_offset = 0;
47 }
48