1 /*
2 * Copyright 2018 Oticon A/S
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6 #include "channel_NtNcable_args.h"
7 #include "bs_tracing.h"
8 #include "bs_oswrap.h"
9 #include "bs_cmd_line_typical.h"
10
11 static char library_name[] = "Channel N to N cable";
12
component_print_post_help()13 void component_print_post_help() {
14 fprintf(stdout,"This is a non realistic channel,\n"
15 "It will mix all N inputs together and pass them to all N outputs with a given\n"
16 "attenuation. If attenuation is set to 0, the full Tx power will go to all\n"
17 "inputs\n\n");
18 }
19
20 ch_NtN_args_t *args_g;
21
cmd_att_found(char * argv,int offset)22 void cmd_att_found(char * argv, int offset) {
23 if ((args_g->attenuation < -100) || (args_g->attenuation > 100)) {
24 bs_trace_error("channel: cmdarg: attenuation can only be between -100 and 100dB (%lf)\n", args_g->attenuation);
25 }
26 }
27
28 /**
29 * Check the arguments provided in the command line: set args based on it
30 * or defaults, and check they are correct
31 */
channel_NtNcable_argparse(int argc,char * argv[],ch_NtN_args_t * args)32 void channel_NtNcable_argparse(int argc, char *argv[], ch_NtN_args_t *args) {
33 args_g = args;
34 bs_args_struct_t args_struct[] = {
35 /*manual,mandatory,switch,option, name , type, destination, callback, , description*/
36 { false , false , false, "at", "attenuation", 'f', (void*)&args->attenuation, cmd_att_found, "attenuation in dB, used in all NxN paths (can be be <0) Default: 60dB"},
37 ARG_TABLE_ENDMARKER
38 };
39
40 args->attenuation = 60;
41
42 char trace_prefix[50]; //it will not be used as soon as we get out of this function
43 snprintf(trace_prefix,50, "channel: (NtNcable) ");
44
45 bs_args_override_exe_name(library_name);
46 bs_args_set_trace_prefix(trace_prefix);
47 bs_args_parse_all_cmd_line(argc, argv, args_struct);
48 }
49