/** Sample ALOE component implementation file Specific module code */ /** Include general data type library */ #include "typetools.h" #include "itf_types.h" /*GLOBAL DEFINEs*/ #define L_MAX 50000000 /*GLOBAL VARIABLES & BUFFERS*/ int value; unsigned char frase[L_MAX]; int filelength=0; void init_my_prog() { filelength=lee_archivo("data/rfc793.txt",frase,L_MAX); /*Read the file*/ printf("gen_SOURCEr1.init_my_prog(): file rfc793.txt readed\n"); printf("gen_SOURCEr1.init_my_prog(): filelength=%d \n", filelength); if(filelength > L_MAX)printf("gen_SOURCEr1.init_my_prog(): filelength=%d > LMAX=%d\n",\ filelength, L_MAX); } /** Module function generic format * Returns the output length or -1 if error */ int my_prog(void *pdatain, void *pdataout,\ int processingtypeIN, int processingtypeOUT,\ int inputlength, ControlGEN_SOURCEr1_h myctrl) { int i, k; float *input_f, *output_f; char *input_c, *output_c; int *input_i, *output_i; short *input_s, *output_s; static int p=0, one=3, outputlength=0; static int filefinish=0; //filefinish=1 --> FILE SENT /**Properly typecast your input data pointer and check the input data type*/ if(processingtypeIN==TYPE_BITSTREAM)input_c=(unsigned char *)frase; else { printf("gen_SOURCEr1.my_prog(): ERROR INPUT DATA TYPE NON VALID\n"); return(-1); } if(processingtypeOUT==TYPE_BITSTREAM)output_c=(char *)pdataout; else { printf("gen_SOURCEr1.my_prog(): ERROR OUTPUT DATA TYPE NON VALID\n"); return(-1); } //*YOUR CODE*/ if(filefinish==1){ //printf("outputlength=%d, myctrl.time_slot=%d\n", outputlength, myctrl.time_slot); return(outputlength); } if(myctrl.signalflow==DATAFLOW){ //Read data from file if(p=filelength){ *(output_c+i)=0; /** Send 0 to complete transfer size*/ outputlength=0; } p++; } return(outputlength); } if(p>=filelength){ outputlength=0; if(filefinish==0){ filefinish=1; printf("FILE SENT gen_SOURCEr1: filelength=%d\n", filelength); printf("outputlength=%d, myctrl.time_slot=%d\n", outputlength, myctrl.time_slot); } return(outputlength); } } if(myctrl.signalflow==SAMPLES){ if(myctrl.signaltype==SEN){ /** TO BE EXTENDED*/ } return(outputlength); } one++; return(0); }