00001 /* 00002 * SPUC - Signal processing using C++ - A DSP library 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2, or (at your option) 00007 * any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 */ 00018 #include <time.h> // For time functions 00019 #ifdef KBHITD 00020 #include <conio.h> // For kbhit 00021 #endif 00022 #include <max_pn.h> // Maximal length PN generator 00023 #include <iostream> 00024 #include <fstream> 00025 #include <iomanip> 00026 namespace SPUC { 00035 class bpsk_ber_test 00036 { 00037 public: 00038 long modc; 00039 time_t start_time; 00040 max_pn ref; 00041 long corr_sum; 00042 long errors; 00043 signed char synced; 00044 long interval; 00045 long prev_errors; 00046 00047 bpsk_ber_test(void) : ref(0x006d,63,-1) { 00048 modc = 1; 00049 start_time = time(NULL); 00050 errors = 0; 00051 corr_sum = 0; 00052 synced = 0; 00053 interval = 0; 00054 prev_errors = 0; 00055 } 00056 00057 signed char found_sync(void) { return(synced); } 00058 void ber_results(long received); 00059 long synchronize(long* received, long data); 00060 void final_results(long received); 00061 void correlate(long* received, long data) { 00062 synchronize(received, data); 00063 ber_results(*received); 00064 } 00065 inline void print_running_ber(void) { 00066 long sym_int = interval; 00067 cout << "Symbol interval = " << setw(8) << sym_int; 00068 cout << "BER = " << running_ber() << '\n'; 00069 } 00070 double running_ber(void); 00071 double ber(long received) { return(errors/(double)received); } 00072 00073 }; 00074 } // namespace SPUC