Ejemplo n.º 1
0
int modinfo_main(int argc UNUSED_PARAM, char **argv)
{
	struct modinfo_env env;
	char name[MODULE_NAME_LEN];
	struct utsname uts;
	parser_t *parser;
	char *colon, *tokens[2];
	unsigned opts;
	unsigned i;

	env.field = NULL;
	opt_complementary = "-1"; /* minimum one param */
	opts = getopt32(argv, "fdalvpF:0", &env.field);
	env.tags = opts & OPT_TAGS ? opts & OPT_TAGS : OPT_TAGS;
	argv += optind;

	uname(&uts);
	parser = config_open2(
		xasprintf("%s/%s/%s", CONFIG_DEFAULT_MODULES_DIR, uts.release, CONFIG_DEFAULT_DEPMOD_FILE),
		fopen_for_read
	);
	if (!parser) {
		parser = config_open2(
			xasprintf("%s/%s", CONFIG_DEFAULT_MODULES_DIR, CONFIG_DEFAULT_DEPMOD_FILE),
			xfopen_for_read
		);
	}

	while (config_read(parser, tokens, 2, 1, "# \t", PARSE_NORMAL)) {
		colon = last_char_is(tokens[0], ':');
		if (colon == NULL)
			continue;
		*colon = '\0';
		filename2modname(tokens[0], name);
		for (i = 0; argv[i]; i++) {
			if (fnmatch(argv[i], name, 0) == 0) {
				modinfo(tokens[0], uts.release, &env);
				argv[i] = (char *) "";
			}
		}
	}
	if (ENABLE_FEATURE_CLEAN_UP)
		config_close(parser);

	for (i = 0; argv[i]; i++) {
		if (argv[i][0]) {
			modinfo(argv[i], uts.release, &env);
		}
	}

	return 0;
}
Ejemplo n.º 2
0
/**@ingroup gen_dft
 * \param direction Direction of the dft: 0 computes a dft and 1 computes an idft (default is 0)
 * \param mirror 0 computes a normal dft, 1 swaps the two halfes of the input signal before computing
 * the dft (used in LTE) (default is 0)
 * \param psd Set to 1 to compute the power spectral density (untested) (default is 0)
 * \param out_db Set to 1 to produce the output results in dB (untested) (default is 0)
 * \param dft_size Number of DFT points. This parameter is mandatory.
 */
int initialize() {
	int tmp;
	int i;

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

	if (param_get_int(param_id("direction"),&direction) != 1) {
		modinfo("Parameter direction not defined. Setting to FORWARD\n");
		direction = 0;
	}

	options = 0;
	if (param_get_int(param_id("mirror"),&tmp) != 1) {
		modinfo("Parameter mirror not defined. Disabling. \n");
	} else {
		if (tmp) options |= DFT_MIRROR;
	}
	if (param_get_int(param_id("psd"),&tmp) != 1) {
		modinfo("Parameter psd not defined. Disabling. \n");
	} else {
		if (tmp) options |= DFT_PSD;
	}
	if (param_get_int(param_id("out_db"),&tmp) != 1) {
		modinfo("Parameter out_db not defined. Disabling. \n");
	} else {
		if (tmp) options |= DFT_OUT_DB;
	}
	if (param_get_int(param_id("normalize"),&tmp) != 1) {
		modinfo("Parameter normalize not defined. Disabling. \n");
	} else {
		if (tmp) options |= DFT_NORMALIZE;
	}

	dft_size_id = param_id("dft_size");
	if (!dft_size_id) {
		moderror("Parameter dft_size not defined\n");
		return -1;
	}

	if (dft_plan_multi_c2c(precomputed_dft_len, (!direction)?FORWARD:BACKWARD, NOF_PRECOMPUTED_DFT,
			plans)) {
		moderror("Precomputing plans\n");
		return -1;
	}
	for (i=0;i<NOF_PRECOMPUTED_DFT;i++) {
		plans[i].options = options;
	}

	return 0;
}
Ejemplo n.º 3
0
/**@ingroup gen_remcyclic
 *
 * \param dft_size Size of the OFDM symbol (in samples). This parameter is mandatory.
 * \param cyclic_prefix_sz Size of the cyclic prefix to add to each received symbol (in samples)
 * This parameter is mandatory.
 * \param first_cyclic_prefix_sz Size of the cyclic prefix to add to the first received symbol
 * (in samples). Optional parameter, default is cyclic_prefix_sz
 */
int initialize() {

	dft_size_id = param_id("dft_size");
	if (!dft_size_id) {
		/*moderror("Parameter dft_size undefined\n");
		return -1;*/
		modinfo("Parameter dft_size not defined. Assuming "
		"dft_size = number of input samples on interface 0 - cyclic_prefix_sz.\n");
	}

	cyclic_prefix_sz_id = param_id("cyclic_prefix_sz");
	if (!cyclic_prefix_sz_id) {
		moderror("Parameter cyclic_prefix_sz undefined\n");
		return -1;
	}

	first_cyclic_prefix_sz_id = param_id("first_cyclic_prefix_sz");

	if (NOF_INPUT_ITF != NOF_OUTPUT_ITF) {
		moderror_msg("Fatal error, the number of input interfaces (%d) must be equal to the "
				"number of output interfaces (%d)\n",NOF_INPUT_ITF,NOF_OUTPUT_ITF);
		return -1;
	}

	return 0;
}
Ejemplo n.º 4
0
Archivo: plp.c Proyecto: a4a881d4/aloe
int plp_init(const char *driver, const char *_title, int _is_complex) {
	int i;

	if (2*NOF_INPUT_ITF > 1) {
		modinfo("Multiple signals are currently displayed in the same plot\n");
	}

	plsdev(driver);
	plinit();
	pladv(0);

	title = _title;
	is_complex = _is_complex;

	for (i=0;i<2*NOF_INPUT_ITF;i++) {
		legends[i] = (const char*) "";
	}

	for (i=0;i<INPUT_MAX_SAMPLES;i++) {
		t[i] = i;
	}

	setup_legend();

	xlabel = xlabel_def;
	ylabel = ylabel_def;

	plscol0a( 14, 0, 0, 0, 1);

	reset_axis();
	return 0;
}
Ejemplo n.º 5
0
int process_params() {
	float _rate,_gain,_freq;
	if (param_get_float(rate_id,&_rate) != 1) {
		modinfo("Getting parameter rate\n");
		return -1;
	}
	if (_rate != rate) {
		rate = _rate;
		_rate = rtdal_dac_set_tx_srate(dac,rate);
		modinfo_msg("Set TX sampling rate %g MHz\n", _rate/1000000);
	}

	if (param_get_float(freq_id,&_freq) != 1) {
		modinfo("Getting parameter freq\n");
		return -1;
	}
	if (_freq != freq) {
		freq = _freq;
		_freq = rtdal_dac_set_tx_freq(dac,freq);
		modinfo_msg("Set TX freq %g MHz\n",_freq/1000000);
	}

	if (gain_id) {
		if (param_get_float(gain_id,&_gain) != 1) {
			modinfo("Getting parameter gain\n");
			return -1;
		}
	} else {
		_gain = 0.0;
	}
	if (_gain != gain) {
		gain = _gain;
		_gain = rtdal_dac_set_tx_gain(dac,gain);
		modinfo_msg("Set TX gain %g dB (%g)\n",_gain,gain);
	}
	if (amp_id) {
		if (param_get_float(amp_id,&amplitude) != 1) {
			modinfo("Getting parameter amplitude\n");
			return -1;
		}
	} else {
		amplitude = 1.0;
	}
	return 0;
}
Ejemplo n.º 6
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;
}
Ejemplo n.º 7
0
int init_interfaces(void *ctx) {
	int i;
	int has_ctrl=0;

	if (oesr_itf_nofinputs(ctx) > nof_input_itf) {
		/* try to create control interface */
		ctrl_in = oesr_itf_create(ctx, 0, ITF_READ, CTRL_IN_BUFFER);
		if (ctrl_in == NULL) {
			if (oesr_error_code(ctx) == OESR_ERROR_NOTREADY) {
				return 0;
			}
		} else {
			modinfo("Created control port\n");
			has_ctrl=1;
		}
	}

	moddebug("configuring %d inputs and %d outputs %d %d %d\n",nof_input_itf,nof_output_itf,inputs[0],input_max_samples,input_sample_sz);
	for (i=0;i<nof_input_itf;i++) {
		if (inputs[i] == NULL) {
			inputs[i] = oesr_itf_create(ctx, has_ctrl+i, ITF_READ, input_max_samples*input_sample_sz);
			if (inputs[i] == NULL) {
				if (oesr_error_code(ctx) == OESR_ERROR_NOTREADY) {
					return 0;
				} else {
					oesr_perror("creating input interface\n");
					return -1;
				}
			} else {
				moddebug("input_%d=0x%x\n",i,inputs[i]);
			}
		}
	}

	for (i=0;i<nof_output_itf;i++) {
		if (outputs[i] == NULL) {
			outputs[i] = oesr_itf_create(ctx, i, ITF_WRITE, output_max_samples*output_sample_sz);
			if (outputs[i] == 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;
				}
			} else {
				moddebug("output_%d=0x%x\n",i,outputs[i]);
			}
		}
	}

	return 1;
}
Ejemplo n.º 8
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();
}
Ejemplo n.º 9
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;
}
Ejemplo n.º 10
0
/**
 * @ingroup Zero padding/unpadding
 * This module has two operational modes.
 * Zero-padding mode (direction = 0): Pads pre_padding and post_padding zeros
 * to each of the nof_packets data packets
 * Sample-unpadding mode (direction != 0): Eliminates pre_padding and
 * post_padding samples from each of the nof_packets data packets
 *
 * \param data_type Specify data type: 0 for _Complex float, 1 for real, 2 for
 * char (default: 0)
 * \param direction Padding if 0 and unpadding otherwise (default: 0)
 * \param pre_padding Number of samples to be added to/ eliminated from the
 * beginning of the packet
 * \param post_padding Number of samples to be added to/ eliminated from the
 * end of the packet
 * \param nof_packets Number of data packets that the input stream contains
 *
 * \returns This function returns 0 on success or -1 on error
 */
int initialize() {
	int data_type;

	if (param_get_int(param_id("data_type"),&data_type) != 1) {
		modinfo("Parameter data_type undefined. Using complex data type\n");
		data_type = DATA_TYPE_COMPLEX;
	}

	input_sample_sz = get_input_sample_sz(data_type);
	output_sample_sz = input_sample_sz;
	moddebug("Chosen data type %d sample_sz=%d\n",data_type, input_sample_sz);

	if (param_get_int(param_id("direction"),&direction) != 1) {
		modinfo("Parameter direction undefined. Assuming padding mode.\n");
		direction = 0;
	}

	pre_padding_id = param_id("pre_padding");
	if (!pre_padding_id) {
		modinfo("Parameter pre_padding undefined. Adding 0 bits.\n");
		pre_padding = 0;
	}

	post_padding_id = param_id("post_padding");
	if (!post_padding_id) {
		modinfo("Parameter post_padding undefined. Adding 0 bits.\n");
		post_padding = 0;
	}

	nof_packets_id = param_id("nof_packets");
	if (!nof_packets_id) {
		modinfo("Parameter nof_packets undefined. Assuming 1 packet.\n");
		nof_packets = 1;
	}

	return 0;
}
Ejemplo n.º 11
0
/**@ingroup gen_modulator
 *
 * \param modulation Choose between 0: BPŜK, 1: QPSK, 2: QAM16 or 3: QAM64. Default is BPSK.
 */
int initialize() {

	modulation_id = param_id("modulation");
	if (!modulation_id) {
		modinfo("Parameter modulation not configured. Setting to BPSK\n");
		modulation = BPSK;
	}

	set_BPSKtable();
	set_QPSKtable();
	set_16QAMtable();
	set_64QAMtable();

	return 0;
}
Ejemplo n.º 12
0
int work(void **inp, void **out) {
	int i, j, k;
	int rcv_samples, nof_ffts;
	int df, fs;
	int e;
	int dft_size;
	input_t *input;
	output_t *output;
	dft_plan_t *plan;
	
 
	if (param_get_int(dft_size_id,&dft_size) != 1) {
		dft_size = get_input_samples(0);
		moddebug("Parameter dft_size not defined. Assuming %d"
		" (number of input samples on interface 0).\n", dft_size);
		/*moderror("Getting parameter dft_size\n");
		return -1;*/
	}

	if (dft_size == 0) {
		modinfo("dft_size = 0. Returning.\n");
		return 0;
	} else {
		moddebug("dft_size = %d.\n", dft_size);
	}
	
/*	if (param_get_int(param_id("dft_size"),&dft_size) != 1) {
		
		moddebug("Parameter dft_size not defined. Assuming %d"
			" (number of input samples on interface 0).\n", dft_size);
	}
*/
	plan = find_plan(dft_size);
	if (!plan) {
		if ((plan = generate_new_plan(dft_size)) == NULL) {
			moderror("Generating plan.\n");
			return -1;
		}
	}
	
	if (param_get_int(df_id, &df) != 1) {
		df = 0;
	}
	if (df != 0) {
		if (param_get_int(fs_id, &fs) != 1) {
			moderror("Parameter fs not defined.\n");
			return -1;
		}
		if (fs <= 0) {
			moderror("Sampling rate fs must be larger than 0.\n");
			return -1;
		}
		if ((df != previous_df) || (fs != previous_fs) || (dft_size != previous_dft_size)) {
			e = process_shift_params(df, fs, dft_size);
			if (e < 0) {
				return -1;
			}
			previous_df = df;
			previous_fs = fs;
			previous_dft_size = dft_size;
		}
	}

	for (i=0;i<NOF_INPUT_ITF;i++) {
		input = inp[i];
		output = out[i];
		rcv_samples = get_input_samples(i);
		moddebug("%d samples received on interface %d.\n",rcv_samples, i);
		if (rcv_samples == 0) {
			moddebug("%d samples to process. Returning.\n", rcv_samples);
			continue;
		}
		moddebug("Processing %d samples...\n",rcv_samples);

		if (rcv_samples % dft_size) {
			moderror_msg("Number of input samples (%d) not integer multiple"
			" of dft_size (%d) on interface %d\n",rcv_samples,dft_size,i);
			return -1;
		}
		if (get_input_samples(0)>0) {
			modinfo_msg("received %d samples\n",get_input_samples(0));
		}

		nof_ffts = rcv_samples/dft_size;

		for (j=0;j<nof_ffts;j++) {
			if ((df != 0) && (direction == FORWARD)) { /* Rx: shift before FFT */
				for (k=0;k<dft_size;k++) {
					input[j*dft_size+k] *= shift[k*shift_increment];
				}
			}

			dft_run_c2c(plan, &input[j*dft_size], &output[j*dft_size]);

			if ((df !=0) && (direction == BACKWARD)) { /* Tx: shift after IFFT */
				for (k=0;k<dft_size;k++) {
					output[j*dft_size+k] *= shift[k*shift_increment];
				}
			}
		}

		set_output_samples(i,dft_size*nof_ffts);
		moddebug("%d samples sent to output interface %d.\n",dft_size*nof_ffts,i);
	}

	return 0;
}
Ejemplo n.º 13
0
/**@ingroup gen_dft
 * \param direction Direction of the dft: 0 computes a dft and 1 computes an idft (default is 0)
 * \param mirror 0 computes a normal dft, 1 swaps the two halfes of the input signal before computing
 * the dft (used in LTE) (default is 0)
 * \param dc_offset Set a null to the 0 subcarrier
 * \param psd Set to 1 to compute the power spectral density (untested) (default is 0)
 * \param out_db Set to 1 to produce the output results in dB (untested) (default is 0)
 * \param dft_size Number of DFT points. This parameter is mandatory.
 * \param df Frequency shift (choose a positive value for upconversion and a negative value for 
 * downconversion) (default is 0--no frequency shift)
 * \param fs Sampling rate. This parameter is mandatory if df!=0.
 */
int initialize() {
	int tmp;
	int i;

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

	if (param_get_int(param_id("direction"),&direction) != 1) {
		modinfo("Parameter direction not defined. Setting to FORWARD\n");
		direction = 0;
	}

	options = 0;
	if (param_get_int(param_id("mirror"),&tmp) != 1) {
		modinfo("Parameter mirror not defined. Disabling. \n");
	} else {
		if (tmp == 1) {
			options |= DFT_MIRROR_PRE;
		} else if (tmp == 2) {
			options |= DFT_MIRROR_POS;
		}
	}
	if (param_get_int(param_id("psd"),&tmp) != 1) {
		modinfo("Parameter psd not defined. Disabling. \n");
	} else {
		if (tmp) options |= DFT_PSD;
	}
	if (param_get_int(param_id("out_db"),&tmp) != 1) {
		modinfo("Parameter out_db not defined. Disabling. \n");
	} else {
		if (tmp) options |= DFT_OUT_DB;
	}
	if (param_get_int(param_id("dc_offset"),&tmp) != 1) {
		modinfo("Parameter dc_offset not defined. Disabling. \n");
	} else {
		if (tmp) options |= DFT_DC_OFFSET;
	}
	if (param_get_int(param_id("normalize"),&tmp) != 1) {
		modinfo("Parameter normalize not defined. Disabling. \n");
	} else {
		if (tmp) options |= DFT_NORMALIZE;
	}

	dft_size_id = param_id("dft_size");
	if (!dft_size_id) {
/*		moderror("Parameter dft_size not defined\n");
		return -1;*/
		modinfo("Parameter dft_size not defined. Assuming "
			"dft_size = number of input samples on interface 0.\n");
	}
		

	if (dft_plan_multi_c2c(precomputed_dft_len, (!direction)?FORWARD:BACKWARD, NOF_PRECOMPUTED_DFT,
			plans)) {
		moderror("Precomputing plans\n");
		return -1;
	}
	for (i=0;i<NOF_PRECOMPUTED_DFT;i++) {
		plans[i].options = options;
	}

	df_id = param_id("df");
	fs_id = param_id("fs");
	precalculate_shift_vectors(precomputed_shift_1536, precomputed_shift_reg);

	/* assume 1.4 MHz LTE UL Tx (fs = 1.92 MHz, 128 IFFT, df = 7.5 kHz) */
	shift = precomputed_shift_reg;
	previous_df = df_lte;
	previous_fs = 1920000;
	previous_dft_size = 128;
	shift_increment = 16;

	return 0;
}
Ejemplo n.º 14
0
int initframe_alignment(int numsamples, int FFTsize, _Complex float *in, _Complex float *correl,\
		_Complex float *coeff0, _Complex float *coeff1, _Complex float *coeff2,
		synchctrl_t *subframCtrl){

	int i,j,k;
	int corrdtect=0, pointer;	/** Point to the max value in correlation sequence*/
	p2MAX_t corrINFO;

	//Detect the first PSS
	memset(&corrINFO, 0, sizeof(p2MAX_t));
	if(subframCtrl->synchstate==SYNCH_INIT){
		modinfo("////////////////////////////////////SYNCH_INIT\n");
		corrdtect=synchro(numsamples, FFTsize, in, correl, coeff0, coeff1, coeff2, &corrINFO);
		modinfo_msg("SYNCHRO OUTPUT: corrdtect = %d\n",corrdtect);
		if(corrdtect == 0) {		//NO Correl Max found
			subframCtrl->synchstate=SYNCH_INIT;
			return 0;
		}
		if(corrdtect == -1){
			subframCtrl->synchstate=SYNCH_ERROR;
			moderror_msg("Synchronization error synchState=%d\n", subframCtrl->synchstate);
			return -1;
		}
		if(corrdtect == 1){
			subframCtrl->synchstate=SYNCH_TRACK;
			subframCtrl->p2_OFDMPSS = corrINFO.pMAX-FFTsize; //Pointer to the FFT symbol, after CP
			subframCtrl->PSSseq = corrINFO.seqNumber;
			subframCtrl->nofsubframe = 0;
			subframCtrl->nofslot = 0;
			//modinfo_msg("p2_OFDMPSS=%d\n", subframCtrl->p2_OFDMPSS);
			return 1;
		}
		moderror_msg("Invalid value for corrdtect=%d \n", corrdtect);
		return 0;
	}
	if(subframCtrl->synchstate==SYNCH_TRACK && (subframCtrl->nofsubframe == 0 || subframCtrl->nofsubframe == 5)){

		modinfo("////////////////////////////////////SYNCH_TRACK\n");
		corrdtect=synchro(numsamples, FFTsize, in/*+pointer*/, correl, coeff0, coeff1, coeff2, &corrINFO);
		modinfo_msg("SYNCHRO OUTPUT: corrdtect = %d\n",corrdtect);
		if(corrdtect == 0) {		//NO Correl Max found
			subframCtrl->synchstate=SYNCH_INIT;
			return 0;
		}
		if(corrdtect == -1){
			subframCtrl->synchstate=SYNCH_ERROR;
			moderror_msg("Synchronization error synchState=%d\n", subframCtrl->synchstate);
			return -1;
		}
		if(corrdtect == 1){
			subframCtrl->synchstate=SYNCH_TRACK;
			subframCtrl->p2_OFDMPSS = /*pointer+*/corrINFO.pMAX-FFTsize;
			subframCtrl->nofsubframe = 0;
			subframCtrl->nofslot = 0;
			modinfo_msg("p2_OFDMPSS=%d\n", subframCtrl->p2_OFDMPSS);
			return 1;
		}
		moderror_msg("Invalid value for corrdtect=%d \n", corrdtect);
		return 0;
	}
	return 0;
}
Ejemplo n.º 15
0
/**@ingroup gen_remcyclic
 *
 * For each interface, the number of received samples must be multiple of the OFDM symbol size,
 * otherwise the module produces and error and stops the waveform.
 *
 * It removes a cyclic prefix to each OFDM symbol received from each interface.
 */
int work(void **inp, void **out) {
	int i, j;
	int dft_size, cyclic_prefix_sz, first_cyclic_prefix_sz;
	int k, nof_ofdm_symbols_per_slot, rcv_samples;
	int cpy;
	int cnt;
	input_t *input;
	output_t *output;

	if (param_get_int(cyclic_prefix_sz_id, &cyclic_prefix_sz) != 1) {
		moderror("getting parameter cyclic_prefix_sz\n");
		return -1;
	}
	if (first_cyclic_prefix_sz_id) {
		if (param_get_int(first_cyclic_prefix_sz_id, &first_cyclic_prefix_sz) != 1) {
			moderror("getting parameter first_cyclic_prefix_sz\n");
			return -1;
		}
	} else {
		first_cyclic_prefix_sz = cyclic_prefix_sz;
	}

	if (param_get_int(dft_size_id, &dft_size) != 1) {
		/*moderror("getting parameter dft_size\n");
		return -1;*/
		dft_size = get_input_samples(0)-cyclic_prefix_sz;
		moddebug("Parameter dft_size not defined. Assuming %d"
		" (number of input samples on interface 0 - cyclic_prefix_sz)."
		"\n", dft_size);
	}

	if (dft_size <= 0) {
		modinfo("dft_size <= 0. Returning.\n");
		return 0;
	} else {
		moddebug("dft_size = %d.\n", dft_size);
	}

	if (first_cyclic_prefix_sz > dft_size || cyclic_prefix_sz > dft_size) {
		moderror_msg("Error with parameters dft_size=%d, cyclic_prefix_sz=%d, "
				"first_cyclic_prefix_sz=%d\n",dft_size,cyclic_prefix_sz,first_cyclic_prefix_sz);
		return -1;
	}

	if (first_cyclic_prefix_sz == cyclic_prefix_sz) {
		nof_ofdm_symbols_per_slot = 6;
	} else {
		nof_ofdm_symbols_per_slot = 7;
	}

	for (i=0;i<NOF_INPUT_ITF;i++) {
		cnt=0;
		input = inp[i];
		output = out[i];
		rcv_samples = get_input_samples(i);
		moddebug("rcv_len=%d samples \n",rcv_samples);

		if (rcv_samples > 0) {
			j = 0;
			k = 0;
			while (cnt < rcv_samples) {
				if (j == k*nof_ofdm_symbols_per_slot) {
					cpy = first_cyclic_prefix_sz;
					k++;
				} else {
					cpy = cyclic_prefix_sz;
				}
				memcpy(output,&input[cpy],sizeof(input_t)*dft_size);
				input += dft_size+cpy;
				output += dft_size;
				cnt += dft_size+cpy;
				j++;
			}
			if (rcv_samples != cnt) {
				moderror_msg("Number of input samples (%d) should be "
				"equal to %d on interface %d\n",rcv_samples,cnt,i);
				return -1;
			}
			set_output_samples(i, j*dft_size);
		}
	}
	return 0;
}
Ejemplo n.º 16
0
/**@ingroup gen_cyclic
 *
 * For each interface, the number of received samples must be multiple of the OFDM symbol size,
 * otherwise the module produces and error and stops the waveform.
 *
 * It adds a cyclic prefix to each OFDM symbol received from each interface.
 */
int work(void **inp, void **out) {
	int i, j;
	int nof_ofdm_symb;
	int dft_size, cyclic_prefix_sz, first_cyclic_prefix_sz;
	int k, nof_ofdm_symbols_per_slot,rcv_samples;
	int cnt;
	int cpy;
	div_t symbols;
	input_t *input;
	output_t *output;

	if (param_get_int(dft_size_id, &dft_size) != 1) {
		/*moderror("getting parameter dft_size\n");
		return -1;*/
		dft_size = get_input_samples(0);
		moddebug("Parameter dft_size not defined. Assuming %d"
		" (number of input samples on interface 0).\n", dft_size);
	}

	if (dft_size == 0) {
		modinfo("dft_size = 0. Returning.\n");
		return 0;
	} else {
		moddebug("dft_size = %d.\n", dft_size);
	}

	if (param_get_int(cyclic_prefix_sz_id, &cyclic_prefix_sz) != 1) {
		moderror("getting parameter cyclic_prefix_sz\n");
		return -1;
	}
	if (first_cyclic_prefix_sz_id) {
		if (param_get_int(first_cyclic_prefix_sz_id, &first_cyclic_prefix_sz) != 1) {
			moderror("getting parameter first_cyclic_prefix_sz\n");
			return -1;
		}
	} else {
		first_cyclic_prefix_sz = cyclic_prefix_sz;
	}
	if (first_cyclic_prefix_sz > dft_size || cyclic_prefix_sz > dft_size) {
		moderror_msg("Error with parameters dft_size=%d, cyclic_prefix_sz=%d, "
				"first_cyclic_prefix_sz=%d\n",dft_size,cyclic_prefix_sz,first_cyclic_prefix_sz);
		return -1;
	}

	if (first_cyclic_prefix_sz == cyclic_prefix_sz) {
		nof_ofdm_symbols_per_slot = 6;
	} else {
		nof_ofdm_symbols_per_slot = 7;
	}

	for (i=0;i<NOF_INPUT_ITF;i++) {
		input = inp[i];
		output = out[i];
		rcv_samples = get_input_samples(i);
		moddebug("rcv_len=%d samples \n",rcv_samples);

		symbols = div(rcv_samples,dft_size);

		if (symbols.rem) {
			moderror_msg("Number of input samples (%d) must be "
			"integer multiple of dft_size (%d) on interface "
			"%d\n",rcv_samples,dft_size,i);
			return -1;
		}

		nof_ofdm_symb = symbols.quot;

		if (nof_ofdm_symb) {
			k = 0;
			cnt = 0;
			for (j=0;j<nof_ofdm_symb;j++) {
				if (j == k*nof_ofdm_symbols_per_slot) {
					cpy = first_cyclic_prefix_sz;
					k++;
				} else {
					cpy = cyclic_prefix_sz;
				}
				memcpy(output, &input[dft_size-cpy], sizeof(input_t)*cpy);
				memcpy(&output[cpy], input, sizeof(input_t)*dft_size);
				input += dft_size;
				output += dft_size+cpy;
				cnt += dft_size+cpy;
			}

			set_output_samples(i, cnt);
		}
	}
	return 0;
}
Ejemplo n.º 17
0
/**
 * @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;
}