예제 #1
0
파일: gen_mux.c 프로젝트: a4a881d4/aloe
int initialize() {
	sample_t d_type;

	if (param_get_int_name("data_type",&data_type)) {
		moderror("Error getting parameter data_type\n");
		return -1;
	}

	if (type_param_2_type(data_type,&d_type)) {
		moderror_msg("Invalid data_type parameter %d\n",data_type);
		return -1;
	}
	input_sample_sz = type_size(d_type);
	output_sample_sz = input_sample_sz;

	if (param_get_int_name("nof_inputs",&nof_inputs)) {
		moderror("Error getting parameter nof_inputs\n");
		return -1;
	}
	nof_input_itf = nof_inputs;
	if (nof_inputs > NOF_INPUT_ITF) {
		moderror_msg("Only %d interfaces are supported. nof_inputs=%d\n",NOF_INPUT_ITF,nof_inputs);
		return -1;
	}
	memset(input_padding_pre,0,sizeof(int)*nof_inputs);
	return 0;
}
예제 #2
0
int initialize() {

	input_len=0;
	param_get_int_name("input_len",&input_len);

	sss_pos_in_frame=960-2*137;
	param_get_int_name("sss_pos_in_frame",&sss_pos_in_frame);

	sss_pos_in_symbol=33;
	param_get_int_name("sss_pos_in_symbol",&sss_pos_in_symbol);

	correlation_threshold=3000;
	param_get_int_name("correlation_threshold",&correlation_threshold);

	N_id_2=0;
	param_get_int_name("N_id_2",&N_id_2);

	dft_plan(SSS_DFT_LEN,COMPLEX_2_COMPLEX,FORWARD,&plan);
	plan.options = DFT_MIRROR_POS | DFT_DC_OFFSET;

	generate_sss_all_tables(&sss_tables,N_id_2);
	convert_tables(&sss_tables);

#ifdef _COMPILE_ALOE
	sf_pm_idx = oesr_get_variable_idx(ctx, "ctrl","subframe_rx");
	if (sf_pm_idx < 0) {
		moderror("Error getting remote parameter subframe_rx\n");
	}
	moddebug("Remote subframe_rx parameter is a at %d\n",sf_pm_idx);
#endif

	first=1;
	return 0;
}
예제 #3
0
/** @ingroup gen_convcoderr
 * \param padding (Optional) Default 0. Number of zero bits to add to the output after encoding the data.
 * \param constraint_length
 * \param tail_bit 1 for tail-bitting, 0 for none
 * \param rate
 * \param generator_i polynomy of the i-th generator
 */
int initialize() {
	int i;
	char tmp[64];

	padding_id = param_id("padding");
	if (!padding_id) {
		padding = 0;
		moddebug("Parameter padding not configured. Setting to %d\n",padding);
	}
	if (param_get_int_name("constraint_length",&constraint_length)) {
		moderror("Parameter constraint_length not specified\n");
		return -1;
	}
	if (param_get_int_name("tail_bit",&tail_bit)) {
		moderror("Parameter tail_bit not specified\n");
		return -1;
	}
	if (param_get_int_name("rate",&rate)) {
		moderror("Parameter rate not specified\n");
		return -1;
	}
	if (rate<0 || rate > MAX_RATE) {
		moderror_msg("Invalid rate %d\n",rate);
		return -1;
	}
	for (i=0;i<rate;i++) {
		snprintf(tmp,64,"generator_%d",i);
		if (param_get_int_name(tmp,&g[i])) {
			moderror_msg("Parameter %s not specified\n",tmp);
			return -1;
		}
	}

	return 0;
}
예제 #4
0
/**
 * @ingroup dac_source
 *
 * \param rate Sets DA converter sampling rateuency
 */
int initialize() {
	var_t pm;
	pm = oesr_var_param_get(ctx, "board");
	if (!pm) {
		moderror("Parameter board undefined\n");
		return -1;
	}

	if (oesr_var_param_get_value(ctx, pm, board, 128) == -1) {
		moderror("Error getting board value\n");
		return -1;
	}
	pm = oesr_var_param_get(ctx, "args");
	if (pm) {
		if (oesr_var_param_get_value(ctx, pm, args, 128) == -1) {
			moderror("Error getting board value\n");
			return -1;
		}
	} else {
		bzero(args,128);
	}

	blocking=0;
	param_get_int_name("blocking",&blocking);

	wait_packets=0;
	param_get_int_name("wait_packets",&wait_packets);

	nsamples_id = param_id("nsamples");
	if (!nsamples_id) {
		moderror("Parameter nsamples not found\n");
		return -1;
	}

	rate_id = param_id("rate");
	if (!rate_id) {
		moderror("Parameter rate not found\n");
		return -1;
	}
	freq_id = param_id("freq");
	if (!freq_id) {
		moderror("Parameter freq not found\n");
		return -1;
	}
	gain_id = param_id("gain");

	dac = rtdal_dac_open(board,args);
	if (!dac) {
		moderror_msg("Initiating DAC %s (args=%s)\n",board,args);
		return -1;
	}
	if (process_params()) {
		moderror("Setting parameters\n");
		return -1;
	}
	return 0;
}
예제 #5
0
/**
 * @ingroup dac_sink
 *
 * \param rate Sets DA converter sampling rateuency
 */
int initialize() {
	var_t pm;
	pm = oesr_var_param_get(ctx, "board");
	if (!pm) {
		moderror("Parameter board undefined\n");
		return -1;
	}

	if (oesr_var_param_get_value(ctx, pm, board, 128) == -1) {
		moderror("Error getting board value\n");
		return -1;
	}
	pm = oesr_var_param_get(ctx, "args");
	if (pm) {
		if (oesr_var_param_get_value(ctx, pm, args, 128) == -1) {
			moderror("Error getting board value\n");
			return -1;
		}
	} else {
		bzero(args,128);
	}

	check_blen=0;
	param_get_int_name("check_blen",&check_blen);
	enable_dac=1;
	param_get_int_name("enable_dac",&enable_dac);

	rate_id = param_id("rate");
	if (!rate_id) {
		moderror("Parameter rate not found\n");
		return -1;
	}
	freq_id = param_id("freq");
	if (!freq_id) {
		moderror("Parameter freq not found\n");
		return -1;
	}
	gain_id = param_id("gain");
	amp_id = param_id("amplitude");

	blocking=0;
	param_get_int_name("blocking",&blocking);

	if (!enable_dac) {
		modinfo("Warning: DAC is disabled\n");
	}

	dac = rtdal_dac_open(board,args);
	return process_params();
}
예제 #6
0
파일: file_source.c 프로젝트: alring/aloe
/**
 * @ingroup file_source
 *
 * \param data_type If specified, reads formated data in text mode:
 * 0 for float, 1 for _Complex float and 2 for _Complex short
 * \param block_length Number of samples to read per timeslot, or bytes
 * \param file_name Name of the *.mat file to save the signal
 */
int initialize() {
	char name[64];
	var_t pm;
	int i;

	if (param_get_int_name("data_type", &data_type)) {
		data_type=-1;
	}

	switch(data_type) {
	case 0:
		output_sample_sz = sizeof(float);
		break;
	case 1:
		output_sample_sz = sizeof(_Complex float);
		break;
	case 2:
		output_sample_sz = sizeof(_Complex short);
		break;
	case -1:
		output_sample_sz=sizeof(char);
	}

	if (param_get_int_name("block_length", &block_length)) {
		moderror("Parameter block_length not specified\n");
		return -1;
	}

#ifdef _COMPILE_ALOE
	pm = oesr_var_param_get(ctx, "file_name");
	if (!pm) {
		moderror("Parameter file_name undefined\n");
		return -1;
	}

	if (oesr_var_param_get_value(ctx, pm, name, 64) == -1) {
		moderror("Error getting file_name value\n");
		return -1;
	}
#endif

	modinfo_msg("Opening file %s for reading\n",name);
	fd = rtdal_datafile_open(name,"r");
	if (!fd) {
		moderror_msg("Error opening file %s\n",name);
		return -1;
	}

	return 0;
}
예제 #7
0
파일: udp_sink.c 프로젝트: alring/aloe
/**
 * @ingroup udp_sink
 *
 * \param address IP address to connect
 * \param port	Port to connect
 */
int initialize() {
	char address[64];
	var_t pm;
	int i;
	int port;

	blen_id = param_id("nof_pkts");

	if (param_get_int_name("port",&port)) {
		moderror("Port undefined\n");
		return -1;
	}

#ifdef _COMPILE_ALOE
	pm = oesr_var_param_get(ctx, "address");
	if (!pm) {
		moderror("Parameter file_name undefined\n");
		return -1;
	}

	if (oesr_var_param_get_value(ctx, pm, address, 64) == -1) {
		moderror("Error getting file_name value\n");
		return -1;
	}
#endif

	fd = create_client_upd(address,port,&servaddr);
	if (fd == -1) {
		moderror("Creating socket\n");
		return -1;
	}
	modinfo_msg("sock=%d\n",fd);

	return 0;
}
예제 #8
0
/**
 * @ingroup lte_dci_pack
 * \param direction 0 for dci packing, 1 for dci unpacking
 * \returns This function returns 0 on success or -1 on error
 */
int initialize() {

	if (param_get_int_name("direction",&direction)) {
		moderror("Getting parameter direction\n");
		return -1;
	}

	if (!direction) {
		nof_input_itf = 0;
		nof_output_itf = 1;
	} else {
		nof_input_itf = 1;
		nof_output_itf = 1;
	}
#ifdef _COMPILE_ALOE
	mcs_rx = oesr_get_variable_idx(ctx, "ctrl","mcs_rx");
	nof_rbg_rx = oesr_get_variable_idx(ctx, "ctrl","nof_rbg_rx");
	rbg_mask_rx = oesr_get_variable_idx(ctx, "ctrl","rbg_mask_rx");
	if (mcs_rx < 0 || nof_rbg_rx < 0 || rbg_mask_rx < 0) {
		moderror("Error getting remote parameters\n");
	}
	modinfo_msg("remote params: mcs_rx=%d, nof_rbg_rx=%d, rbg_mask_rx=%d\n",mcs_rx,nof_rbg_rx,rbg_mask_rx);
#endif
	return 0;
}
예제 #9
0
int initialize() {

	/* Initialization Parameters */
	if (param_get_int_name("cache_seq_nbits", &binsource.init.cache_seq_nbits)) {
		binsource.init.cache_seq_nbits = 2;
	}
	if (param_get_int_name("seed", &binsource.init.seed)) {
		binsource.init.seed = 0;
	}

	/* Input Control Parameters */
	nbits_id = param_id("nbits");

	/* Initialization function */
	return binsource_initialize(&binsource);
}
예제 #10
0
파일: source.c 프로젝트: alring/aloe
/**@ingroup source
 *
 * The available generators are defined in generators.h
 * \param block_length Number of items (bits or samples) to generate
 * \param generator Integer indicating the generator (see generators.h)
 *
 */
int initialize() {
	int size;
	int block_length;

	blen_id = param_id("block_length");
	if (!blen_id) {
		moderror("Parameter block_length not found\n");
		return -1;
	}

	if (param_get_int(blen_id,&block_length) != 1) {
		moderror("Getting integer parameter block_length\n");
		return -1;
	}

	period=1;
	param_get_int_name("period",&period);
	period_cnt=period;

	generator_init_random();

	moddebug("Parameter block_length is %d\n",block_length);

	gen_id = param_id("generator");
	if (!gen_id) {
		moderror("Parameter type not found\n");
		return -1;
	}

	last_type = -1;

	return 0;
}
예제 #11
0
/**
 * @ingroup Lte Rate Matching of convolutionally encoded information
 * Applied for PDCCH
 * Initialization function
 *
 * \param direction Transmitter mode if 0 and receiver mode otherwise
 * \param E Number of output bits of rate matching in transmitter mode
 * \param S Number of output bits of rate matching in receiver mode
 *
 * \returns This function returns 0 on success or -1 on error
 */
int initialize() {

	if (param_get_int_name("direction", &direction)) {
		moderror_msg("Parameter 'direction' not specified. Assuming "
		  "transmission mode (%d).\n", 0);
		direction = 0;
	}
	if (direction) {
		/* Reception mode */
		S_id = param_id("S");
		if (!S_id) {
			moderror("Parameter S not found\n");
			return -1;
		}

		input_sample_sz=sizeof(float);
		output_sample_sz=sizeof(float);
	} else {
		/* Transmission mode */
		E_id = param_id("E");
		if (!E_id) {
			moderror("Parameter E not found\n");
			return -1;
		}
		input_sample_sz=sizeof(char);
		output_sample_sz=sizeof(char);
	}
	return 0;
}
예제 #12
0
파일: dac_sink.c 프로젝트: a4a881d4/aloe
/**
 * @ingroup dac_sink
 *
 * \param freq_samp Sets DA converter sampling frequency
 */
int initialize() {
	buffer = rtdal_uhd_buffer(1);
	freq_id = param_id("freq_samp");
	if (!freq_id) {
		moderror("Parameter freq_samp not found\n");
		return -1;
	}
	gain_id = param_id("gain");

	if (param_get_int_name("data_type", &data_type)) {
		data_type = 1;
	}
	switch(data_type) {
	case 0:
		input_sample_sz = sizeof(float);
		break;
	case 1:
		input_sample_sz = sizeof(_Complex float);
		break;
	case 2:
		input_sample_sz = sizeof(_Complex short);
		break;
	}

	return 0;
}
예제 #13
0
/**
 * @ingroup lte_ratematching
 *  Rate adapter for LTE DL/UL. Code rate is out_len/in_len
 *
 *  There are two ways to configure this module:
 *    - Automatic: Choose tslot_idx, modulation and fft_size to let the module
 *    automatically determine the required output length at each slot, according to the
 *    LTE slotting
 *    - Manual: Set out_len variable to the desired output length.
 *
 *  Automatic mode is selected when parameter out_len is not defined.
 *
 * \param tslot_idx In automatic mode, indicates the tslot index
 * \param mcs In automatic mode, indicates the Modulation and Coding Scheme (MCS)
 * \param nrb In automatic mode, indicates the Number of allocated Resource Blocs
 * \param fft_size In automatic mode, indicates the length of the fft
 * \param cp_is_long In automatic mode, non-null selects long cyclic prefix
 * \param lteslots_x_timeslot In automatic mode, number of lte slots per execution time slot
 * \param out_len Output length
 * \param rv_idx Document this parameter
 * \param direction 0 for the transmitter, 1 for the receiver
 *
 * \returns This function returns 0 on success or -1 on error
 */
int initialize() {
	int size;

	out_len_id = param_id("out_len");
	if (!out_len_id) {
		tslot_idx_id = param_id("tslot_idx");
		tslot_idx = 0;

		if (!(fft_size_id = param_id("fft_size"))) {
			moderror("In automatic mode, parameter fft_size must be specified\n");
		}

		if (!(mcs_id = param_id("mcs"))) {
			moderror("In automatic mode, parameter mcs must be specified\n");
		}
		if (!(nrb_id = param_id("nrb"))) {
			moderror("In automatic mode, parameter nrb must be specified\n");
		}
		if (!(cp_long_id = param_id("cp_is_long"))) {
			moderror("In automatic mode, parameter cp_is_long must be specified\n");
		}
		if (param_get_int_name("lteslots_x_timeslot",&lteslots_x_timeslot)) {
			moderror("In automatic mode, parameter lteslots_x_timeslot must be specified\n");
		}
	}

	rvidx_id = param_id("rvidx");

	if (param_get_int_name("direction",&direction)) {
		moderror("Error getting parameter direction\n");
		return -1;
	}

	if (direction) {
		input_sample_sz=sizeof(float);
		output_sample_sz=sizeof(float);
	} else {
		input_sample_sz=sizeof(char);
		output_sample_sz=sizeof(char);
	}

	tslot_idx=0;

	return 0;
}
예제 #14
0
int send_dci(char *output) {
	struct dci_format1 dci; /* Only format1 is currently supported */
	int len;
	int i;
	int rbg_mask,enable;

	memset(&dci,0,sizeof(struct dci_format1));
	enable=0;
	param_get_int_name("enable",&enable);
	if (!enable) {
		return 0;
	}
	if (param_get_int_name("mcs",&dci.mcs)) {
		modinfo("could not get parameter mcs\n");
	}
	if (param_get_int_name("nof_rbg",&dci.nof_rbg)) {
		modinfo("could not get parameter nof_rbg\n");
	}
	rbg_mask=0;
	if (param_get_int_name("rbg_mask",&rbg_mask)) {
		modinfo("could not get parameter rbg_mask\n");
	}
	for (i=0;i<MAX_RBG_SET;i++) {
		if (rbg_mask & (0x1<<i)) {
			dci.rbg_mask[i] = 1;
		} else {
			dci.rbg_mask[i] = 0;
		}
	}
	dci.ra_type = NA; /* means type0 because nrb<10 */
	dci.harq_pnum_len = 3;
	dci.carrier_indicator_len=2; /* this is to make it divisible by 3 */

	len = dci_format1_pack(output,&dci);
	if (len < 0) {
		moderror("Building DCI Format 1 packet\n");
		return -1;
	}

#ifdef _COMPILE_ALOE
	moddebug("ts=%d transmitted mcs=%d, nof_rbg=%d, rbgmask=0x%x\n",oesr_tstamp(ctx),dci.mcs,dci.nof_rbg,rbg_mask);
#endif
	return len;
}
예제 #15
0
파일: gen_crc.c 프로젝트: a4a881d4/aloe
int initialize() {
	int tslen;

	if (param_get_int_name("direction",&mode)) {
		mode = MODE_ADD;
	}

	if (param_get_int_name("print_nof_pkts",&print_nof_pkts)) {
		print_nof_pkts = 0;
	} else {
		print_nof_pkts_cnt = 0;
	}

	long_crc_id = param_id("long_crc");
	if (param_get_int(long_crc_id,&long_crc) != 1) {
		modinfo_msg("Parameter long_crc not configured. Set to %d\n",
				DEFAULT_LONG_CRC);
		long_crc = DEFAULT_LONG_CRC;
		long_crc_id = NULL;
	}

	poly_id = param_id("poly");
	if (param_get_int(poly_id,&poly) != 1) {
		poly = DEFAULT_POLY;
		poly_id = NULL;
	}


#ifdef _COMPILE_ALOE
	tslen = oesr_tslot_length(ctx);
	if (tslen > EXEC_MIN_INTERVAL_MS*1000) {
		interval_ts = 1;
	} else {
		interval_ts = (EXEC_MIN_INTERVAL_MS*1000)/tslen;
		modinfo_msg("Timeslot is %d usec, refresh interval set to %d tslots\n",tslen,interval_ts);
	}
#endif
	total_errors=0;
	total_pkts=0;
	tscnt=0;
	return 0;
}
예제 #16
0
int initialize() {
	int i;
	sample_t d_type;
	char pname[64];

	if (param_get_int_name("data_type",&data_type)) {
		moderror("Error getting parameter data_type\n");
		return -1;
	}

	if (type_param_2_type(data_type,&d_type)) {
		moderror_msg("Invalid data_type parameter %d\n",data_type);
		return -1;
	}

	input_sample_sz = type_size(d_type);
	output_sample_sz = input_sample_sz;

	if (param_get_int_name("nof_outputs",&nof_outputs)) {
		moderror("Error getting parameter nof_outputs\n");
		return -1;
	}
	if (nof_outputs > NOF_OUTPUT_ITF) {
		moderror_msg("Only %d interfaces are supported. nof_input_itf=%d\n",NOF_OUTPUT_ITF,nof_outputs);
		return -1;
	}
	memset(special_output_length,0,sizeof(int)*nof_outputs);
	nof_special_outputs = 0;
	for (i=0;i<nof_outputs;i++) {
		snprintf(pname,64,"out_len_%d",i);
		if (!param_get_int_name(pname,&special_output_length[i])) {
			nof_special_outputs++;
		}
	}
	sum_special_output_lengths = sum_i(special_output_length,nof_outputs);
	nof_output_itf = nof_outputs;
	memset(output_padding_pre,0,sizeof(int)*nof_outputs);
	memset(output_padding_post,0,sizeof(int)*nof_outputs);

	return 0;
}
예제 #17
0
/**
 * @ingroup lte_resource_mapper
 *
 *	See lte_ctrl_tx for grid params.
 *
 * \param nof_channels Number of channels to extract
 * \param channel_id_n Id of the n-th channel to extract (configured in channel_setup.h)
 * \param (optional) subframe_idx, if not provided, subframe_idx is counted automatically starting at zero
 *
 * \returns This function returns 0 on success or -1 on error
 */
int initialize() {
	int i;
	char tmp[64];
	int max_out_port;

	max_out_port = read_channels();

	grid.fft_size = 128;
	grid.nof_prb = 6;
	grid.nof_osymb_x_subf = 14;
	grid.nof_ports = 1;
	grid.cell_id = 0;
	grid.cfi = -1;
	grid.nof_pdsch = 0;
	grid.nof_pdcch = 0;

	subframe_idx_id = param_id("subframe_idx");
	if (!subframe_idx_id) {
		subframe_idx = 0;
	}

	if (param_get_int_name("nof_channels",&nof_channels)) {
		nof_channels = 1;
	}
	if (nof_channels > MAX_CHANNELS) {
		moderror_msg("Maximum allowed channels is %d (%d)\n",nof_channels,MAX_CHANNELS);
		return -1;
	}
	for (i=0;i<nof_channels;i++) {
		snprintf(tmp,64,"channel_id_%d",i);
		if (param_get_int_name(tmp,&channel_ids[i])) {
			channel_ids[i] = i;
		}
	}

	nof_output_itf = max_out_port+1;
	nof_input_itf = 1;


	return 0;
}
예제 #18
0
/**
 * @ingroup gen_hard_demod
 * Initializes parameters.
 *
 * Modulation types: BPSK, QPSK, QAM16, QAM64.
 *
 * \param modulation Modulation index (1: BPSK, 2: QPSK, 4: QAM16, 6: QAM64).
 * Default: 1 (BPSK).
 *
 * \returns This function returns 0 on success or -1 on error
 */
int initialize() {

	/* obtains a handler for fast access to the parameter */
	modulation_id = param_id("modulation");

	param_get_int_name("in_real",&in_real);
	if (in_real == 1) {
		input_sample_sz=sizeof(float);
	}

	return 0;
}
예제 #19
0
int recv_dci(char *input, char *output, int len) {
	struct dci_format1 dci; /* Only format1 is currently supported */
	int rbg_mask = 0;
	int i;

	if (len == 0) {
		return 0;
	} else {
		memset(&dci,0,sizeof(struct dci_format1));
		dci.harq_pnum_len = 3;
		dci.carrier_indicator_len=2;
		if (param_get_int_name("nof_rbg",&dci.nof_rbg)) {
			modinfo("could not get parameter nof_rbg\n");
		}
		if (dci_format1_unpack(input,len,&dci)<0) {
			moderror("Reading DCI Format 1 packet\n");
			return -1;
		}
		for (i=0;i<MAX_RBG_SET;i++) {
			rbg_mask |= (dci.rbg_mask[i] & 0x1) << (i);
		}
	}

#ifdef _COMPILE_ALOE
	len = 0;
	int n;
	n = param_remote_set_ptr(&output[len], mcs_rx, &dci.mcs, sizeof(int));
	if (n == -1) {
		moderror("Setting parameter mcs\n");
		return -1;
	}
	len += n;
	n = param_remote_set_ptr(&output[len], nof_rbg_rx, &dci.nof_rbg, sizeof(int));
	if (n == -1) {
		moderror("Setting parameter nof_rbg\n");
		return -1;
	}
	len += n;
	n = param_remote_set_ptr(&output[len], rbg_mask_rx, &rbg_mask, sizeof(int));
	if (n == -1) {
		moderror("Setting parameter rbg_mask\n");
		return -1;
	}
	len += n;
	set_output_samples(0,len);
	modinfo_msg("received mcs=%d, nof_rbg=%d, rbgmask=0x%x\n",dci.mcs,dci.nof_rbg,rbg_mask);
#endif

	return len;
}
예제 #20
0
파일: base.c 프로젝트: KrishnaAdapa/aloe
int lte_grid_init_params(struct lte_grid_config *config) {
	int n=0;

	if (!param_get_int_name("nof_prb",&config->nof_prb)) {
		n++;
	}
	config->fft_size = fft_size(config->nof_prb);
	if (config->fft_size==-1) {
		return 0;
	}
	if (!param_get_int_name("debug",&config->debug)) {
		n++;
	} else {
		config->debug=0;
	}
	if (!param_get_int_name("verbose",&config->verbose)) {
		n++;
	}
	if (!param_get_int_name("nof_osymb_x_subf",&config->nof_osymb_x_subf)) {
		n++;
	}
	if (!param_get_int_name("nof_ports",&config->nof_ports)) {
		n++;
	}
	if (!param_get_int_name("cfi",&config->cfi)) {
		n++;
	}
	if (!param_get_int_name("cell_id",&config->cell_id)) {
		n++;
	}
	config->nof_re_symb = config->nof_prb*NOF_RE_X_OSYMB;
	config->pre_guard = (config->fft_size-config->nof_re_symb)/2;
	config->post_guard = config->pre_guard;
	config->nof_rs_x_symb = 2*config->nof_prb;

	if (config->nof_prb<6 || config->nof_prb>110) {
		printf("Number of PRB must be between 0 and 110 (nof_prb=%d)\n",config->nof_prb);
		return -1;
	}
	if (config->cfi == -1) {
		config->nof_control_symbols = 0;
	} else {
		if (config->nof_prb<=10) {
			config->nof_control_symbols = config->cfi+1;
		} else {
			config->nof_control_symbols = config->cfi;
		}
	}
	return n+1;
}
예제 #21
0
/**
 * @ingroup file_sink
 *
 * \param data_type If specified, formats data in text mode:
 * 0 for float, 1 for _Complex float and 2 for _Complex short
 * \param file_name Name of the *.mat file to save the signal
 */
int initialize() {
	char name[64];

	if (param_get_int_name("data_type", &data_type)) {
		data_type=-1;
	}

	switch(data_type) {
	case 0:
		input_sample_sz = sizeof(float);
		break;
	case 1:
		input_sample_sz = sizeof(_Complex float);
		break;
	case 2:
		input_sample_sz = sizeof(_Complex short);
		break;
	case -1:
		input_sample_sz=sizeof(char);
	}

#ifdef _COMPILE_ALOE
	var_t pm;
	pm = oesr_var_param_get(ctx, "file_name");
	if (!pm) {
		moderror("Parameter file_name undefined\n");
		return -1;
	}

	if (oesr_var_param_get_value(ctx, pm, name, 64) == -1) {
		moderror("Error getting file_name value\n");
		return -1;
	}
#endif

	modinfo_msg("Opening file %s for writing\n",name);
	fd = rtdal_datafile_open(name,"w");
	if (!fd) {
		moderror_msg("Error opening file %s\n",name);
		return -1;
	}

	last_rcv_samples = 0;

	return 0;
}
예제 #22
0
int init_remote_itf(void *ctx, int nof_itf) {
	int i,j;
	int port,delay;
	char tmp[64];

	for (i=0;i<nof_itf;i++) {
		port = outputs[i].module_idx-oesr_module_id(ctx)+nof_output_data_itf;
		if (port < 0) {
			moderror_msg("Can't sent to a module back in the chain (module_idx=%d)\n",outputs[i].module_idx);
			return -1;
		}

		/* check if a parameter sets a different delay */
		for (j=0;j<nof_remote_variables;j++) {
			if (remote_variables[j].module_idx == outputs[i].module_idx) {
				break;
			}
		}
		if (j < nof_remote_variables) {
			snprintf(tmp,64,"delay_%s",remote_params_db[j].module_name);
			if (!param_get_int_name(tmp,&delay)) {
				moddebug("Setting a delay of %d slots to port %d, module %s\n",delay,port,
					remote_params_db[j].module_name);
				if (oesr_itf_delay_set(ctx,port,ITF_WRITE,delay)) {
					moderror_msg("Setting delay to port %d\n",port);
					return -1;
				}
			}
		}

		/* now create the variable */
		outputs[i].itf = oesr_itf_create(ctx, port,
				ITF_WRITE, sizeof(struct ctrl_in_pkt));
		if (outputs[i].itf == NULL) {
			if (oesr_error_code(ctx) == OESR_ERROR_NOTFOUND) {
				modinfo_msg("Caution output port %d not connected,\n",i);
			} else {
				moderror_msg("Error creating output port %d\n",i);
				oesr_perror("oesr_itf_create\n");
				return -1;
			}
		}
	}

	return 0;
}
예제 #23
0
/**
 * @ingroup template
 *  Document here the module's initialization parameters
 *
 * The documentation should explain which are the possible parameters, what they do and if they are
 * mandatory or optional (indicating the default value in such case).
 *
 * \param gain Document paramater gain
 * \param block_length Document parameter block_length
 *
 * \returns This function returns 0 on success or -1 on error
 */
int initialize() {

	/* obtains a handler for fast access to the parameter */
	gain_id = param_id("gain");
	/* In this case, we are obtaining the parameter value directly */
	if (param_get_int_name("block_length", &block_length)) {
		block_length = 0;
	}
	/* use this function to print formatted messages */modinfo_msg("Parameter block_length is %d\n",block_length);

	/* Verify control parameters */
	if (block_length > input_max_samples || block_length < 0) {
		moderror_msg("Invalid block length %d\n", block_length);
		return -1;
	}

	/* here you may do some other initialization stuff */

	return 0;
}
예제 #24
0
파일: channel.c 프로젝트: KrishnaAdapa/aloe
/**
 * @ingroup channel
 *
 * \param variance Gaussian noise variance
 * \param gain Channel gain
 *
 * \returns This function returns 0 on success or -1 on error
 */
int initialize() {

	gain_re_id = param_id("gain_re");
	gain_im_id = param_id("gain_im");
	variance_id = param_id("variance");
	scale_id = param_id("noise_scale");

	if (!param_get_float_name("snr_min",&snr_min)
			&& !param_get_float_name("snr_max",&snr_max)
			&& !param_get_float_name("snr_step",&snr_step)
			&& !param_get_int_name("num_realizations",&num_realizations)) {
		auto_mode=1;
		snr_current=snr_min;
		cnt_realizations=0;
	} else {
		auto_mode=0;
	}

	return 0;
}
예제 #25
0
int Init(void *_ctx) {
	ctx = _ctx;

	switch(ctrl_init()) {
	case -1:
		return -1;
	case 0:
		return 0;
	}

	init_memory();

	ctrl_in = NULL;
	if (!init_ctrl_input(ctx)) {
		return 0;
	}

	nof_output_data_itf = 0;
	param_get_int_name("nof_output_data_itf",&nof_output_data_itf);

	if (init_remote_variables(ctx) == -1) {
		return -1;
	}

	nof_remote_itf = scan_remote_itf(ctx,nof_remote_variables);
	if (nof_remote_itf == -1) {
		return -1;
	}

	nof_local_variables = init_local_variables(ctx);
	if (nof_local_variables == -1) {
		return -1;
	}

	if (init_remote_itf(ctx,nof_remote_itf)) {
		return -1;
	}

	return 1;
}
예제 #26
0
파일: test_generate.c 프로젝트: alring/aloe
/**
 *  Generates input signal. VERY IMPORTANT to fi
--------------------------------------
Avg. processing time 0.011118 msec/frame
*** Plotting signal ***
*** Plotting signal ***

Press ENTER to continue...
 *  ll length vector with the number of
 * samples that have been generated.
 * @param inp Input interface buffers. Data from other interfaces is stacked in the buffer.
 * Use in(ptr,idx) to access the address.
 *
 * @param lengths Save on n-th position the number of samples generated for the n-th interface
 */
int generate_input_signal(void *in, int *lengths)
{
	int k;
	complex_t realchannel [2048];
	input_t *input = in;
	int block_length;
	int err, i, j;
	int nofdm;
	int	Ndlrb;		// Number of PRBs in a downlink ofdm symbol
	int Ncp;		// Cyclic prefix type (1 for normal CP, 0 for extended CP)

	/* Obtain the configuration parameters */
	i = 0;
	while (prms[i].var != NULL){
		if (param_get_int_name((char*) prms[i].name, prms[i].var)) {
			*prms[i].var = prms[i].value;
			modinfo_msg("Test: Parameter %s not defined, setting default %d\n", prms[i].name, *prms[i].var);
		} else {
			modinfo_msg("Test: Parameter %s is %d\n", prms[i].name, *prms[i].var);
		}
		i++;
	}
	modinfo_msg("Test: Parameters have been loaded!\n", NULL);

	/* Generate secondary parameters */
	// Downlink Resource Blocks (RBs)
	if (fftsize == 128){
		Ndlrb = 6;
	} else if (fftsize == 256){
		Ndlrb = 12;
	} else if (fftsize == 512){
		Ndlrb = 25;
	} else if (fftsize == 1024){
		Ndlrb = 50;
	} else if (fftsize == 1536){
		Ndlrb = 75;
	} else if (fftsize == 2048){
		Ndlrb = 100;
	} else {
		moderror("The fft size exceeds the maximum (2048)\n");
	}

	// Number of OFDM symbols per processing TS
	nofdm = Ndlsym*20/fseg;

	block_length=nofdm*fftsize;
	param_get_int_name("block_length",&block_length);

	// Get the Frame configuration for cyclic prefix
	switch (Ndlsym){
		case 7:
			Ncp = 1;
			break;
		case 6:
			Ncp = 0;
			break;
		default:
			moderror_msg("Bad parameter Ndlsym, only valid 6 and 7 (default)\n", NULL);
			break;
	}

	/* Generate RS and map them */
	err = setRefSignals (	Ndlrb,		// Number of PRBs in a downlink ofdm symbol
					Nid,		// Cell identifier number
					Ncp,		// Cyclic prefix
					Ndlsym,		// Number of ODFDM symbols in a downlink slot
					p, 			// Antenna Port (0, 1, 2, 3)
					rs,			// ReferenceNSUBC signals pointer
					rspos,		// Reference signals positions
					fseg		// Frame segmentation that is received each processing TS
				);
	if (err<0) {	// Check if any error occur
		moderror_msg("Bad parameters input in RS initialization (error %d)\n", err);
	} /*else {
		nrs = err/fseg;
	}*/
#define GUARD	((fftsize-12*Ndlrb)/2)

	/* Generate testing channel */
	for (i=0; i<fftsize; i++){
			/*arg = 2*PI*((float)(i%fftsize)/(float)fftsize);
			cosf(arg)+I*sinf(arg);*/
			realchannel[i] = -1.0+1.0*I;
	}
	modinfo_msg("Test: testing channel has been generated.\n", NULL);

	/* Generate test frame */
	k = j = 0;
	for (i = 0; i < block_length; i++){
		/* If reference symbol is allocated */
		if (i == rspos[k]){
			input[i] = rs[k]*realchannel [i%fftsize];
			k++; j++;
		/* If traffic symbol is allocated */
		} else if (i%fftsize>GUARD && i%fftsize<(fftsize-GUARD)){
			input[i] = realchannel [i%fftsize];
		}
		/* If nothing */
		else
			input[i] = 0;
	}

	/** HERE INDICATE THE LENGTH OF THE SIGNAL */
	lengths[0] = block_length;

	modinfo_msg("Test: testing frame size %d has been generated.\n", lengths[0]);

	return 0;
}
예제 #27
0
파일: plp_sink.c 프로젝트: a4a881d4/aloe
/**
 * @ingroup plp_sink
 *
 *  Initializes the plplot driver if mode is SCOPE or PSD. If the mode is PSD, it
 * also initializes computes the fftw3 plan for the selected dft_size.
 *
 * \param is_complex 0: The input data for all interfaces is real;
 * 1: The input data for all interfaces is complex. This parameter is mandatory.
 * \param mode 0: Do nothing; 1: Print to stdout the received samples; 2: SCOPE mode, plots the
 * received signal using plplot; 3: PSD mode, plots the power spectral density of the received signal.
 * Default is 0 (silent)
 * \param fft_size Size of the DFT to compute the PSD. Default is 128.
 */
int initialize() {
	int i;
	int mode;
	int tslen;
	int data_type;

	last_rcv_samples=0;

	memset(plans,0,sizeof(dft_plan_t)*NOF_PRECOMPUTED_DFT);
	memset(extra_plans,0,sizeof(dft_plan_t)*MAX_EXTRA_PLANS);

	setup_legends();

	if (param_get_int_name("data_type", &data_type)) {
		data_type = 0;
	}
	switch(data_type) {
	case 0:
		is_complex = 0;
		break;
	case 1:
		is_complex = 1;
		break;
	case 2:
		moderror("Only data_type 0 or 1 is supported\n");
		return -1;
	}

	if (param_get_int_name("print_not_received",&print_not_received)!=1) {
		print_not_received = 0;
	}
	modinfo_msg("print_not_received=%d\n",print_not_received);

	mode_id = param_id("mode");
	if (mode_id == NULL) {
		modinfo("Mode is not configured, using default mode 'silent'\n");
	} else {
		if (param_get_int(mode_id,&mode) != 1) {
			moderror("Error getting parameter mode\n");
			return -1;
		}
		if (mode == MODE_SCOPE || mode == MODE_PSD) {
			modinfo("Initiating plplot...\n");
			if (plp_init(PL_DRIVER,"",is_complex)) {
				return -1;
			}
			plp_initiated = 1;
			reset_axis();
			modinfo("-- Warning --: plplot crashes at stop. Restart ALOE after stopping the waveform.\n");
		}
	}

	if (mode == MODE_PSD) {
		fft_size=0;
		param_get_int_name("fft_size",&fft_size);
		if (is_complex) {
			if (dft_plan_multi_c2r(precomputed_dft_len, FORWARD, NOF_PRECOMPUTED_DFT, plans)) {
				moderror("Precomputing plans\n");
				return -1;
			}
		} else {
			if (dft_plan_multi_r2r(precomputed_dft_len, FORWARD, NOF_PRECOMPUTED_DFT, plans)) {
				moderror("Precomputing plans\n");
				return -1;
			}
		}
		for (i=0;i<NOF_PRECOMPUTED_DFT;i++) {
			plans[i].options = DFT_PSD | DFT_OUT_DB | DFT_NORMALIZE;
		}
		fft_initiated = 1;
	}


#ifdef _COMPILE_ALOE
	tslen = oesr_tslot_length(ctx);
	if (tslen > EXEC_MIN_INTERVAL_MS*1000) {
		interval_ts = 1;
	} else {
		interval_ts = (EXEC_MIN_INTERVAL_MS*1000)/tslen;
		modinfo_msg("Timeslot is %d usec, refresh interval set to %d tslots\n",tslen,interval_ts);
	}
	last_tstamp = 0;
#endif

	return 0;
}