diff --git a/BF_companion b/BF_companion index 3c490c3..5db1a46 100755 Binary files a/BF_companion and b/BF_companion differ diff --git a/build/main.o b/build/main.o index 175c207..28dc9cd 100644 Binary files a/build/main.o and b/build/main.o differ diff --git a/main.c b/main.c index c837ec3..5f5c11b 100644 --- a/main.c +++ b/main.c @@ -68,88 +68,21 @@ #include "l502_fpga_regs.h" -typedef enum { - DUMP_TO_FILE, - FLUSH, -}; - -typedef enum { - unknown = 0x00, - ADC_data =0x01, - USR_data, - DIN_data, - FFT_val_re, - FFT_val_im, - FFT_val_f, - LFSM_val_ON, - LFSM_val_OFF, - LFSM_val_X, - USR_msg, - LFSM_started, -} BF_msg_parsed_type; - -typedef struct BF_msg_parsed_typedef { - BF_msg_parsed_type type; - uint8_t chan; - uint8_t flags; - uint8_t raw_header; - uint32_t raw_data; - uint32_t raw_value; - int value_int; - double value; -}; - -typedef struct LFSM_typedef{ //Linear Frequency Sweep Modulation - int * X; - int * Y_on; //intensity while Mach-Zander modulator is "opened" - int * Y_off;//intensity while Mach-Zander modulator is "closed" - int ID; - uint8_t rcv_state; - int max_N; //max number of data points - int curr_I; - uint8_t description; -}; - -typedef struct FFT_res_typedef{ - - int * vals_Re; - int * vals_Im; - int * vals_F; - int values_N; - uint8_t rcv_state; - int max_N; - //int timestamp; - int ID; - uint8_t description; - int curr_I; //current index of value and corresponding frequency -} ; - - - - -const int FFT_length = 1000; +/* Remove unused enums/structs and constants that are not referenced anywhere */ // количество используемых логических каналов // #define ADC_LCH_CNT 1 -// частота сбора АЦП в Гц// -#define ADC_FREQ 2000000 -// частота кадров (на логический канал). При ADC_FREQ/ADC_LCH_CNT - межкадровой задержки нет // -#define ADC_FRAME_FREQ (ADC_FREQ/ADC_LCH_CNT) -// частота синхронного ввода в Гц// -#define DIN_FREQ 500000 - - -#define TCP_CONNECTION_TOUT 5000 +/* Unused frequency/timing defines removed */ // сколько отсчетов считываем за блок // -#define READ_BLOCK_SIZE 4096*200 +#define READ_BLOCK_SIZE 4096*200 // таймаут на прием блока (мс) // -#define READ_TIMEOUT 2000 +#define READ_TIMEOUT 2000 -#define BF_CMD_USER_MULT 0x8001U +/* Unused BF user command define removed */ // номера используемых физических каналов // @@ -192,7 +125,7 @@ static uint32_t f_ch_ranges[ADC_LCH_CNT] = {X502_ADC_RANGE_02, X502_ADC_RANGE_5, // признак необходимости завершить сбор данных // -static int f_out = 0; +static int f_out = 0; #ifndef _WIN32 // Обработчик сигнала завершения для Linux // @@ -210,15 +143,7 @@ typedef struct { } ip_dev_list_t; -volatile sig_atomic_t abort_crtl_C = 0; - -void handle_sigint(int signal_stop){ - (void)signal_stop; - abort_crtl_C = 1; - for (int i = 100; i ; --i){ - printf("abort"); - } -} +/* Unused SIGINT handler and flag removed */ /* Функция находит все подключенные модули по интерфейсам PCI-Express и USB и @@ -679,8 +604,7 @@ void receive_to_file(t_x502_hnd hnd, char* logfilename, uint32_t* inp_buff, uint -int main(int argc, char** argv) { - signal(SIGINT, handle_sigint); +int main(int argc, char** argv) { int32_t err = X502_ERR_OK; uint32_t ver; t_x502_hnd hnd = NULL; @@ -702,45 +626,7 @@ int main(int argc, char** argv) { ver = X502_GetLibraryVersion(); printf("Версия библиотеки: %d.%d.%d\n", (ver >> 24)&0xFF, (ver>>16)&0xFF, (ver>>8)&0xFF); -//* - uint32_t inp_buff[2] = {0,}; - double adc_data[1] = {0,}; - double user_data[1] = {0,}; - uint32_t inp_values_N = 0; - uint32_t adc_chans_N = 1; - uint32_t adc_readouts_N= 2; - uint32_t user_data_chans_N = 3; - uint32_t user_data_readouts_N = 4; - //uint32_t FFT_data_readouts_N = 5; - - - - struct FFT_res_typedef FFT_res_tmp; - FFT_res_tmp.max_N = 1000; - FFT_res_tmp.vals_Re = malloc(FFT_res_tmp.max_N * sizeof(int)); - FFT_res_tmp.vals_Im = malloc(FFT_res_tmp.max_N *sizeof(int)); - FFT_res_tmp.vals_F = malloc(FFT_res_tmp.max_N * sizeof(int)); - FFT_res_tmp.curr_I = 0; - FFT_res_tmp.description = 0; - FFT_res_tmp.rcv_state = 0; - FFT_res_tmp.ID = 0; - - struct FFT_res_typedef FFT_res; - FFT_res.ID = 0; - - - struct LFSM_typedef LFSM_res_tmp; - LFSM_res_tmp.max_N = 1000; - LFSM_res_tmp.X = malloc(LFSM_res_tmp.max_N * sizeof(int)); - LFSM_res_tmp.Y_on = malloc(LFSM_res_tmp.max_N *sizeof(int)); - LFSM_res_tmp.Y_off = malloc(LFSM_res_tmp.max_N * sizeof(int)); - LFSM_res_tmp.curr_I = 0; - LFSM_res_tmp.description = 0; - LFSM_res_tmp.rcv_state = 0; - LFSM_res_tmp.ID = 0; - - struct LFSM_typedef LFSM_res; - LFSM_res.ID = 0; +/* Removed unused temporary buffers and FFT/LFSM placeholders */ @@ -810,17 +696,10 @@ int main(int argc, char** argv) { } - uint32_t BF_cmd_receive_code = 0; - - printf("\n\n\n"); - - //setup ADC: - uint32_t tx_data[] = {0,1,2,3,4,53,4,2,2,1,0}; - - //set ADC Установка значения опорной частоты - uint32_t tx_data_size = 1; - tx_data[0] = 2000000; //valid values: 2000000, 1500000 Hz - //printf("\n"); + printf("\n\n\n"); + + //setup ADC: + /* Removed unused TX data buffer */ @@ -876,10 +755,7 @@ int main(int argc, char** argv) { uint32_t *inp_buff = malloc(1024*100*1024*2*4); double *adc_data = malloc(1024*1024*sizeof(double)); //uint32_t inp_buff[1024*2048] = {0,}; - int ready_cnt = 0; - int ready_cnt_copy = 0; - uint32_t ready_cnt_Err = 0; - uint32_t recv_Err_code = 0; + /* Removed unused counters */ insert_marker_to_file(logfilename, "start transparent"); @@ -892,24 +768,10 @@ int main(int argc, char** argv) { printf("receiving data...\n"); - //ready_cnt_Err = X502_GetRecvReadyCount(hnd, &ready_cnt_copy); - //recv_Err_code = X502_Recv(hnd, inp_buff, 1024, 10); + /* Removed unused readiness checks */ - - ready_cnt = ready_cnt_copy; - -// printf("Ready count: %d, Err: %d \n", ready_cnt, ready_cnt_Err); -// printf("Recv Err code (<0 -- err, >= 0 -- number of received words(32bit)): %d\n", recv_Err_code); - - if (recv_Err_code > 0){ - ready_cnt = recv_Err_code; - } - if (ready_cnt < 0){ - ready_cnt = 0; - } - - int data_receive_trys_counter = 100; - uint32_t max_total_words = 100000; + uint32_t max_total_words = 100000; + /* Removed unused data_receive_trys_counter */ // printf("\nflush TX buff. \n Number of free TX descriptors before flushing:"); // BF_exec_cmd_simple(hnd, 0x8010, 10, 1); @@ -963,8 +825,7 @@ int main(int argc, char** argv) { //fprintf(logfile_ptr, "value number; time, sec; adc_value, V\n"); - data_receive_trys_counter = 100; - max_total_words = 100000; + max_total_words = 100000; //printf("\n dbg value: "); //BF_exec_cmd_simple(hnd, 0x800A, 10, 1); @@ -1190,10 +1051,9 @@ int main(int argc, char** argv) { FD_ZERO(&fds); FD_SET(STDIN_FILENO, &fds); - if (select(1, &fds, NULL, NULL, &tv) == 1) { - int x; - static int adc_disabled = 0; - int ch; + if (select(1, &fds, NULL, NULL, &tv) == 1) { + static int adc_disabled = 0; + int ch; if (adc_disabled) { X502_StreamsEnable(hnd, X502_STREAM_ADC);