/** * @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; }
/** * @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(); }
int param_get(pmid_t id, void *ptr, int max_size, param_type_t *type) { if (type) { *type = (param_type_t) oesr_var_param_type(ctx,(var_t) id); } int n = oesr_var_param_get_value(ctx, (var_t) id, ptr, max_size); return n; }
/** * @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; }
int local_parameters_update(void *ctx) { int i; for (i=0;i<nof_local_variables;i++) { if (oesr_var_param_get_value(ctx, (var_t) local_variables[i], local_params_db[i].value, local_params_db[i].size) == -1) { oesr_perror("oesr_var_param_value\n"); return -1; } } return 0; }
int param_get(pmid_t id, void *ptr, int max_size, param_type_t *type) { if (type) { *type = (param_type_t) oesr_var_param_type(ctx,(var_t) id); } int n = oesr_var_param_get_value(ctx, (var_t) id, ptr, max_size); if (n == -1) { /* keep quiet in this case */ if (oesr_error_code(ctx) != OESR_ERROR_INVAL) { oesr_perror("oesr_var_param_value\n"); } } return n; }
/** * @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; }
/** * @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; }