Esempio n. 1
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;
}
Esempio n. 2
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();
}
Esempio n. 3
0
/**
 * @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;
}
Esempio n. 4
0
/**
 * @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;
}
Esempio n. 5
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;
}
Esempio n. 6
0
int init_local_variables(void *ctx) {
	int i;

	i=0;
	while(local_params_db[i].name && i<MAX_VARIABLES) {
		local_variables[i] = oesr_var_param_get(ctx,(char*) local_params_db[i].name);
		if (!local_variables[i]) {
			moderror_msg("Parameter %s not found\n",local_params_db[i].name);
			return -1;
		}
		i++;
	}
	if (i==MAX_VARIABLES) {
		modinfo_msg("Caution: Only %d variables where parsed. "
				"Increase MAX_VARIABLES in oesr/include/ctrl_skeleton.h",i);
	}
	return i;
}
Esempio n. 7
0
pmid_t param_id(char *name) {
	return (pmid_t) oesr_var_param_get(ctx,name);
}