/** ALOE headers */ #include #include #include #include #include "inputs.h" #include "outputs.h" #include "stats.h" #define FIXED_SEQ_LEN 1024 char file_sequence[INPUT_MAX_DATA]; int filelength, file_ptr; #define MAX_PRINT_BITS 1024 char printbuff[MAX_PRINT_BITS]; int printcnt=0,numpkts=0; int lastnumerrors=0; /** returns number of errors */ int compare_bytes(char x, char y) { char r; int i,count=0; if (x==y) { return 0; } r=x^y; for (i=0;i<8;i++) { if (r&0x1) count++; r>>=1; } return count; } int process_input(int len) { int in_samples; int x; char *y; int i,j; int printed; /** save input signal to stats */ in_len = len; in_samples = typeNsamplesArray(datatype, len); if (in_samples > SIGNAL_VIEW_LEN) { in_samples = SIGNAL_VIEW_LEN; } type2int(input_data, input_i, in_samples, datatype); /** perform ber_check */ if (ber_check && datatype==TYPE_BITSTREAM) { if (reset) { numerrors=0; numbits=0; printcnt=0; lastnumerrors=0; SetStatsValue(stat_reset,&printcnt,1); } numbits+=len*8; ber = (float) numerrors/numbits; numpkts++; printed=0; for (i = 0; i < len; i++) { switch (pattern) { case PAT_ZEROS: numerrors+=compare_bytes(input_data[i],0); break; case PAT_ONES: numerrors+=compare_bytes(input_data[i],0xff); break; case PAT_RANDOM: if (!(i%4)) { x=rand(); y=(char*) &x; for (j=0;j<4;j++) { numerrors+=compare_bytes(input_data[i+j],y[j]); } } break; case PAT_FILE: numerrors+=compare_bytes(input_data[i],file_sequence[file_ptr]); file_ptr++; if (file_ptr==filelength) { file_ptr=0; } break; case PAT_FIXED: if (i+fixed_offset>filelength) { Log("Error while trying to read at position %d. File is length %d\n",i+fixed_offset,filelength); } else { numerrors+=compare_bytes(input_data[i],file_sequence[i+fixed_offset]); } break; default: Log("Unknown pattern %d\n", pattern); return 0; } if (print_position && numerrors-lastnumerrors>0) { Log("Found %d errors at byte %d, packet %d",numerrors-lastnumerrors,i,numpkts); lastnumerrors=numerrors; printed=1; } } if (printed && print_position) Log("\n"); } if (print_bits) { if (print_bits>MAX_PRINT_BITS) { print_bits=MAX_PRINT_BITS; Log("Error! can't print more bits than %d\n",print_bits); } bin2char(input_data,printbuff,print_bits); printf("RCV:\t"); for (i=0;i