Example #1
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;
}
Example #2
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;
}