/** * @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; }
/**@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; }
/** @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; }
/** * @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; }
/** * @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; }
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; }
/** * Generates input signal. VERY IMPORTANT to fill 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 i; input_t *input = in; int block_length; pmid_t blen_id; 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)) { moderror("Getting integer parameter block_length\n"); return -1; } modinfo_msg("Parameter block_length is %d\n",block_length); /** HERE INDICATE THE LENGTH OF THE SIGNAL */ lengths[0] = block_length; for (i=0;i<block_length;i++) { input[i] = 0.7 + 0.7*_Complex_I; } return 0; }
/** * Generates input signal. VERY IMPORTANT to fill 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 i; input_t *input = in; int block_length; pmid_t blen_id; 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)) { moderror("Getting integer parameter block_length\n"); return -1; } modinfo_msg("Parameter block_length is %d\n",block_length); /** HERE INDICATE THE LENGTH OF THE SIGNAL */ lengths[0] = block_length; for (i=0;i<block_length;i++) { #ifdef GENESRSLTE_TCOD_RATE_COMPLEX __real__ input[i] = (float) ((i+offset)%(block_length)); __imag__ input[i] = (float) ((block_length-i-1+offset)%(block_length)); #else input[i] = (i+offset)%(block_length); #endif } offset++; return 0; }
int work(void **inp, void **out) { int block_length, type; int i,j; int snd_samples; period_cnt++; if (period_cnt>=period) { period_cnt=0; } if (period_cnt) { return 0; } block_length = 0; if (param_get_int(blen_id,&block_length) != 1) { moderror("Getting integer parameter block_length\n"); return -1; } type = 0; if (param_get_int(gen_id,&type) != 1) { moderror("Getting integer parameter type\n"); return -1; } for(i=0;i<NOF_GENERATORS;i++) { if (generators[i].key == type) { break; } } if (i == NOF_GENERATORS) { moderror_msg("Generator type %d not implemented\n", type); return -1; } if (type != last_type) { moddebug("Select generator: %s\n",generators[i].desc); last_type = type; } if (block_length > OUTPUT_MAX_SAMPLES/generators[i].samp_sz) { moderror_msg("block_length %d too large. Maximum is %d for this generator\n",block_length, OUTPUT_MAX_SAMPLES/generators[i].samp_sz); return -1; } #ifdef _COMPILE_ALOE if (block_length != last_block_length) { moddebug("Select block_length: block_length=%d at tslot=%d\n",block_length,oesr_tstamp(ctx)); last_block_length = block_length; } #endif snd_samples = generators[i].work(out[0],block_length); #ifdef _COMPILE_ALOE moddebug("Sent %d samples at ts=%d\n",snd_samples,oesr_tstamp(ctx)); #endif return snd_samples; }
/** * @ingroup Lte Rate Matching of convolutionally encoded information * Applied for PDCCH * * Main DSP function * * * \param inp Input interface buffers. The value inp[i] points to the buffer received * from the i-th interface. The function get_input_samples(i) returns the number of received * samples (the sample size is by default sizeof(input_t)) * * \param out Output interface buffers. The value out[i] points to the buffer where the samples * to be sent through the i-th interfaces must be stored. * * \param E Number of output bits of rate matching in transmitter mode * \param S Number of output bits of rate matching in receiver mode * * @return On success, returns a non-negative number indicating the output * samples that should be transmitted through all output interface. To specify a different length * for certain interface, use the function set_output_samples(int idx, int len) * On error returns -1. */ int work(void **inp, void **out) { int S, E; int rcv_samples, snd_samples; char *input_b; char *output_b; float *input_f; float *output_f; rcv_samples = get_input_samples(0); if (!rcv_samples || !out[0] || rcv_samples > 3*6114) { return 0; } input_f = inp[0]; input_b = inp[0]; output_f = out[0]; output_b = out[0]; if (!direction) { /* @Transmitter */ if (param_get_int(E_id, &E) != 1) { moderror("Error getting parameter 'E', indiciating the " "number of rate matching output samples in Tx mode.\n"); return -1; } if (E > OUTPUT_MAX_SAMPLES) { moderror("Too may output samples (E).\n"); return -1; } rate_matching(input_b, output_b, rcv_samples, E); snd_samples = E; } else { /* @Receiver */ if (param_get_int(S_id, &S) != 1) { moderror("Error getting parameter 'S', indiciating the " "number of rate matching output samples in Rx mode\n"); return -1; } if (S > OUTPUT_MAX_SAMPLES) { moderror("Too may output samples (S).\n"); return -1; } if (S%3 > 0) { moderror("Number of output samples S not integer divisible by 3.\n"); return -1; } snd_samples = rate_unmatching(input_f, output_f, rcv_samples, S); } return snd_samples; }
/**@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; }
/** * @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 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; }
/** * @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 gen_mux * */ int work(void **inp, void **out) { int i; int out_len; int nof_active_inputs; nof_active_inputs = 0; for (i=0;i<nof_inputs;i++) { input_lengths[i] = get_input_samples(i); nof_active_inputs++; } if (exclusive && nof_active_inputs>1) { moderror_msg("Exclusive mux but %d inputs have data\n",nof_active_inputs); return -1; } if(check_all && (nof_active_inputs<nof_inputs)) { moderror_msg("Only %d/%d inputs have data\n",nof_active_inputs,nof_inputs); return -1; } if (!out[0]) { moderror("Output not ready\n"); return -1; } out_len = sum_i(input_lengths,nof_inputs); if (out_len) { mux(inp,out[0],input_lengths,input_padding_pre,nof_inputs,input_sample_sz); } return out_len; }
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; }
/** * @ingroup lte_resource_mapper * * Main DSP function * * This function allocates the data symbols of one slot (0.5 ms) in the corresponding place * of the LTE frame grid. During initialization phase CRS, PSS and SSS signals has been * incorporated and will no be modified during run phase. * PBCH (Physical Broadcast Channel), PCFICH (Physical Control Format Indicator Channel) & * PDCCH (Physical Downlink Control Channel) will be incorporated. * */ int work(void **inp, void **out) { if (subframe_idx_id) { param_get_int(subframe_idx_id, &subframe_idx); } #ifdef CHECK_RCV_SAMPLES int n; n=check_received_samples_mapper(); if (n < 1) { return n; } #endif #ifdef _COMPILE_ALOE moddebug("subframe_idx=%d tstamp=%d rcv=%d\n",subframe_idx,oesr_tstamp(ctx),get_input_samples(0)); #endif if (allocate_all_channels(inp,out[0])) { moderror("Error allocating channels\n"); return 0; } subframe_idx++; if (subframe_idx==NOF_SUBFRAMES_X_FRAME) { subframe_idx=0; } return 0; }
/** * @ingroup dac_source * * Writes the received samples to the dac output buffer * */ int work(void **inp, void **out) { int n; if (!stream_started) { rtdal_dac_start_rx_stream(dac); stream_started=1; } if (process_params()) { return -1; } if (!nsamples) { return 0; } if (!out[0]) { moderror("Output interface not ready\n"); return -1; } if (cnt<wait_packets) { cnt++; modinfo_msg("not receiving ts=%d\n",oesr_tstamp(ctx)); return 0; } n = rtdal_dac_recv(dac,out[0],nsamples,blocking); modinfo_msg("ts=%d, recv %d samples\n",oesr_tstamp(ctx),n); if (n != nsamples) { moderror_msg("Recv %d/%d samples\n",n,nsamples); return -1; } return nsamples; }
/** * @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; }
/**@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; }
/** * @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; }
int main(int argc, char *argv[]) { int i; long int ret; unsigned long len; void *file; char *filename, *options = strdup(""); char *progname = argv[0]; if (argv[1] && (streq(argv[1], "--version") || streq(argv[1], "-V"))) { puts("klibc insmod"); exit(0); } /* Ignore old options, for backwards compat. */ while (argv[1] && (streq(argv[1], "-p") || streq(argv[1], "-s") || streq(argv[1], "-f"))) { argv++; argc--; } filename = argv[1]; if (!filename) print_usage(progname); /* Rest is options */ for (i = 2; i < argc; i++) { options = realloc(options, strlen(options) + 2 + strlen(argv[i]) + 2); /* Spaces handled by "" pairs, but no way of escaping quotes */ if (strchr(argv[i], ' ')) strcat(options, "\""); strcat(options, argv[i]); if (strchr(argv[i], ' ')) strcat(options, "\""); strcat(options, " "); } file = grab_file(filename, &len); if (!file) { fprintf(stderr, "insmod: can't read '%s': %s\n", filename, strerror(errno)); exit(1); } ret = init_module(file, len, options); if (ret != 0) { fprintf(stderr, "insmod: error inserting '%s': %li %s\n", filename, ret, moderror(errno)); exit(1); } exit(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; }
int main(int argc, char *argv[]) { unsigned int i; long int ret; unsigned long len; void *file; char *filename, *options = strdup(""); char *progname = argv[0]; if (strstr(argv[0], "insmod.static")) try_old_version("insmod.static", argv); else try_old_version("insmod", argv); if (argv[1] && (streq(argv[1], "--version") || streq(argv[1], "-V"))) { puts(PACKAGE " version " VERSION); exit(0); } /* Ignore old options, for backwards compat. */ while (argv[1] && (streq(argv[1], "-p") || streq(argv[1], "-s") || streq(argv[1], "-f"))) { argv++; argc--; } filename = argv[1]; if (!filename) print_usage(progname); /* Rest is options */ for (i = 2; i < argc; i++) { options = realloc(options, strlen(options) + 1 + strlen(argv[i]) + 1); strcat(options, argv[i]); strcat(options, " "); } file = grab_file(filename, &len); if (!file) { fprintf(stderr, "insmod: can't read '%s': %s\n", filename, strerror(errno)); exit(1); } ret = init_module(file, len, options); if (ret != 0) { fprintf(stderr, "insmod: error inserting '%s': %li %s\n", filename, ret, moderror(errno)); exit(1); } exit(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; }
int work(void **inp, void **out) { int i, j, nof_fft; int dft_size; input_t *input; output_t *output; dft_plan_t *plan; if (param_get_int(dft_size_id,&dft_size) != 1) { moderror("Getting parameter dft_size\n"); return -1; } plan = find_plan(dft_size); if (!plan) { if ((plan = generate_new_plan(dft_size)) == NULL) { moderror("Generating plan.\n"); return -1; } } for (i=0;i<NOF_INPUT_ITF;i++) { input = inp[i]; output = out[i]; if (get_input_samples(i) % dft_size) { moderror_msg("Number of input samples (%d) must be multiple of dft_size (%d), in " "interface %d\n",get_input_samples(i),dft_size,i); return -1; } nof_fft = get_input_samples(i)/dft_size; for (j=0;j<nof_fft;j++) { dft_run_c2c(plan, &input[j*dft_size], &output[j*dft_size]); } set_output_samples(i,dft_size*nof_fft); } return 0; }
/** * Generates input signal. VERY IMPORTANT to fill 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 i; input_t *input = in; int block_length; pmid_t blen_id; int size; 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)) { moderror("Getting integer parameter block_length\n"); return -1; } modinfo_msg("Parameter block_length is %d\n",block_length); /** HERE INDICATE THE LENGTH OF THE SIGNAL */ lengths[0] = block_length; for (i=0;i<block_length;i++) { input[i] = 0x1; } /* UL: test*/ input[10] = 'x'; input[11] = 'x'; input[12] = 'x'; input[13] = 'x'; input[14] = 'y'; return 0; }
int hyper_insmod(char *module) { size_t size, offset = 0, rc; struct stat st; char *buf = NULL; int ret; int fd = open(module, O_RDONLY); if (fd == -1) { fprintf (stderr, "insmod: open: %s: %m\n", module); return -1; } if (fstat(fd, &st) == -1) { perror ("insmod: fstat"); goto err; } size = st.st_size; buf = malloc(size); if (buf == NULL) goto err; do { rc = read(fd, buf + offset, size - offset); if (rc == -1) { perror ("insmod: read"); goto err; } offset += rc; } while (offset < size); if (init_module(buf, size, "") != 0) { fprintf (stderr, "insmod: init_module: %s: %s\n", module, moderror(errno)); goto err; } ret = 0; out: close(fd); free(buf); return ret; err: ret = -1; goto out; }
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; }
int work(void **inp, void **out) { int i,n; #if NOF_INPUTS>1 for (i=0;i<NOF_INPUT_ITF;i++) { binsource.input[i] = inp[i]; binsource.in_len[i] = get_input_samples(i) } #elif NOF_INPUTS == 1 binsource.input = inp[0]; binsource.in_len = get_input_samples(0); #endif #if NOF_OUTPUTS>1 for (i=0;i<NOF_OUTPUT_ITF;i++) { binsource.output[i] = out[i]; binsource.out_len = &out_len[i]; } #elif NOF_OUTPUTS == 1 binsourceoutput = out[0]; binsource.out_len = &out_len[0]; #endif /* Get input parameters */ if (param_get_int(nbits_id, &binsource.ctrl_in.nbits) != 1) { moderror("Error getting parameter nbits\n"); return -1; } /* call work */ n = binsource_work(&binsource); /* Set output nof_samples */ for (i=0;i<NOF_OUTPUT_ITF;i++) { set_output_samples(i,out_len[i]); binsource.out_len = &out_len[i]; } /* Set output parameters */ return n; }