cleaned more unused code (by codex)

This commit is contained in:
2025-11-13 19:31:56 +03:00
parent b80ad585da
commit b7eae9d469
3 changed files with 21 additions and 161 deletions

Binary file not shown.

Binary file not shown.

158
main.c
View File

@ -68,79 +68,12 @@
#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 */
// сколько отсчетов считываем за блок //
@ -149,7 +82,7 @@ const int FFT_length = 1000;
#define READ_TIMEOUT 2000
#define BF_CMD_USER_MULT 0x8001U
/* Unused BF user command define removed */
// номера используемых физических каналов //
@ -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 и
@ -680,7 +605,6 @@ 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);
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");
/* 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;
/* 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,7 +825,6 @@ 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;
//printf("\n dbg value: ");
@ -1191,7 +1052,6 @@ 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;