#include #include #include #include "globdef.h" #if(OSNUM == OS_FLAG_WINDOWS) #include #define INVSOCK INVALID_SOCKET #endif #if(OSNUM == OS_FLAG_LINUX) #define INVSOCK -1 #endif #include "uidef.h" #include "fft1def.h" #include "fft2def.h" #include "screendef.h" #include "powtdef.h" #include "vernr.h" #include "sigdef.h" #include "seldef.h" #include "thrdef.h" #include "sdrdef.h" #include "caldef.h" #include "conf.h" #include "keyboard_def.h" #include "txdef.h" extern int tune_bytes; #if (USERS_EXTRA_PRESENT == 1) extern void init_users_extra(void); #endif char *parfilnam; int uiparm_save[MAX_UIPARM]; int dirflag, iqflag; void prompt_reason(char *s) { clear_screen(); lir_text(5,8,"You are prompted to the parameter selection screens"); lir_text(15,10,"for the following reason:"); lir_text(5,13,s); lir_text(20,16,press_any_key); await_keyboard(); } void check_output_no_of_channels(void) { int i; i=1+((genparm[OUTPUT_MODE]>>1)&1); if(iui.rx_max_da_channels)i=ui.rx_max_da_channels; i--; genparm[OUTPUT_MODE]&=-3; genparm[OUTPUT_MODE]|=i<<1; } void show_bw(void) { char s[80]; clear_screen(); sprintf(s,"fft1 size %d (Bw=%fHz)",fft1_size,fft1_bandwidth); lir_text(1,1,s); sprintf(s,"fft2 size %d (Bw=%fHz)",fft2_size,fft2_bandwidth); lir_text(1,2,s); } void modify_parms(char *line1, int first, int last) { char s[80]; int line1_len; int i, j, k, m, no, mouse_line,parnum; line1_len=strlen(line1)+8; no=last-first+1; start:; hide_mouse(0,screen_width,0,screen_height); clear_screen(); settextcolor(14); lir_text(5,1, line1); // Make sure fft1_n and fft2_n are defined and // in agreement with current parameters. get_wideband_sizes(); if( first <= FIRST_FFT_SINPOW && last >= FIRST_FFT_SINPOW) { sprintf(s,"fft1 size=%d (Bw=%fHz)",fft1_size,fft1_bandwidth); lir_text(line1_len,1,s); } if( first <= SECOND_FFT_SINPOW && last >= SECOND_FFT_SINPOW) { sprintf(s,"fft2 size=%d (Bw=%fHz)",fft2_size,fft2_bandwidth); lir_text(line1_len,1,s); } if(kill_all_flag) return; if( first <= DA_OUTPUT_SPEED && last >= DA_OUTPUT_SPEED) { if(genparm[DA_OUTPUT_SPEED] < ui.rx_min_da_speed) genparm[DA_OUTPUT_SPEED]=ui.rx_min_da_speed; if(genparm[DA_OUTPUT_SPEED] > ui.rx_max_da_speed) genparm[DA_OUTPUT_SPEED]=ui.rx_max_da_speed; if(ui.rx_ad_speed != genparm[DA_OUTPUT_SPEED] && disksave_flag != 2 && (ui.network_flag&NET_RX_INPUT) == 0) { settextcolor(12); lir_text(1,14,"WARNING input and output sampling rate different."); lir_text(1,15,"Some old boards require the same speed setting."); lir_text(1,16,"VIBRA 16C, MAD 16 Pro,......"); } } if( first <= CW_DECODE_ENABLE && last >= CW_DECODE_ENABLE) { if(rx_mode==MODE_WCW || rx_mode==MODE_NCW || rx_mode==MODE_HSMS) { if(genparm[CW_DECODE_ENABLE] != 0) { settextcolor(12); lir_text(1,14,"WARNING: The Morse decode routines are incomplete."); lir_text(1,15,"They will not produce any useful output and may cause"); lir_text(1,16,"a program crasch. Use only for development and perhaps"); lir_text(1,17,"for some evaluation of chirp and other keying defects"); lir_text(1,18,"with the coherent graph oscilloscope."); } } else { genparm[CW_DECODE_ENABLE]=0; } } if( first <= FIRST_BCKFFT_ATT_N && last >= FIRST_BCKFFT_ATT_N) { k=(fft1_n-4)&0xfffe; if(genparm[FIRST_BCKFFT_ATT_N]>k)genparm[FIRST_BCKFFT_ATT_N]=k; if(genparm[FIRST_BCKFFT_ATT_N]<0)genparm[FIRST_BCKFFT_ATT_N]= genparm_min[FIRST_BCKFFT_ATT_N]; } if( first <= SECOND_FFT_ATT_N && last >= SECOND_FFT_ATT_N) { k=fft2_n-2; if(genparm[SECOND_FFT_ATT_N]>k)genparm[SECOND_FFT_ATT_N]=k; } settextcolor(7); for(i=0; i= 0 && mouse_line 0 && k < MAX_FFT1_VERNR-1)k++; if(simd_present == 0) { while( fft_cntrl[fft1_version[fft1mode][k]].simd != 0)k--; } if(mmx_present == 0) { while( fft_cntrl[fft1_version[fft1mode][k]].mmx != 0)k--; } } if(parnum == FIRST_BCKFFT_VERNR) { k=0; while( fft1_back_version[ui.rx_rf_channels-1][k+1] > 0 && k < MAX_FFT1_BCKVERNR-1)k++; if(mmx_present == 0) { while( fft_cntrl[fft1_back_version[ui.rx_rf_channels-1][k]].mmx != 0)k--; } } if(parnum == FIRST_BCKFFT_ATT_N) { k=(fft1_n-4)&0xfffe; } if(parnum == SECOND_FFT_ATT_N) { k=fft2_n-2; } if(parnum == SECOND_FFT_VERNR) { k=0; while( fft2_version[ui.rx_rf_channels-1][k+1] > 0 && k < MAX_FFT2_VERNR-1)k++; if(mmx_present == 0) { while( fft_cntrl[fft2_version[ui.rx_rf_channels-1][k]].mmx != 0)k--; } } if(parnum == MIX1_BANDWIDTH_REDUCTION_N) { if(genparm[SECOND_FFT_ENABLE] == 0) { k=fft1_n-3; } else { k=fft2_n-3; } } if(parnum == DA_OUTPUT_SPEED) { m=ui.rx_min_da_speed; k=ui.rx_max_da_speed; } if(parnum == MAX_NO_OF_SPURS) { if(genparm[AFC_ENABLE]==0) { k=0; } else { if(genparm[SECOND_FFT_ENABLE] == 0) { k=2*fft1_size/SPUR_WIDTH; } else { k=2*fft2_size/SPUR_WIDTH; } } } if(parnum == SPUR_TIMECONSTANT) { if(genparm[SECOND_FFT_ENABLE] == 0) { k=5*genparm[FFT1_STORAGE_TIME]; } else { k=5*genparm[FFT2_STORAGE_TIME]; } } // In case fft sizes are not set. if(k < m || mgenparm_max[parnum]) { k=genparm_max[parnum]; m=genparm_min[parnum]; } sprintf(s," %s (%d to %d)",genparm_text[parnum], m,k); lir_text(1,11+no, s); genparm[parnum]=lir_get_integer(10, 13+no, 8, m,k); if(kill_all_flag) return; if(parnum == OUTPUT_MODE)check_output_no_of_channels(); goto start; } } test_keyboard(); if(kill_all_flag) return; if(lir_inkey != 0) { process_current_lir_inkey(); if(kill_all_flag) return; } if(lir_inkey == F1_KEY) { mouse_line=mouse_y/text_height-3; if(mouse_line >= 0 && mouse_line =2)goto cal_skip; fft1_pa=fft1_block; fft1_na=1; fft1_pb=0; fft1_px=0; fft1_nx=0; timf1p_pa=ad_read_bytes; timf1p_px=0; if(kill_all_flag) goto cal_skip; cal_initscreen(); if( (ui.rx_input_mode&IQ_DATA) != 0) { if( (ui.rx_input_mode&DIGITAL_IQ) == 0) { lir_text(0, 5,"Running in IQ mode (direct conversion receiver)"); lir_text(0, 6,"The I/Q phase and amplitude should be calibrated before"); lir_text(0, 7,"the total amplitude and phase response is calibrated"); lir_text(5, 9,"A=> Calibrate I/Q phase and amplitude."); } lir_text(5,10,"B=> Calibrate total amplitude and phase"); lir_text(5,11,"C=> Remove center discontinuity"); lir_text(5,12,"D=> Refine amplitude and phase correction"); await_processed_keyboard(); if(kill_all_flag) goto cal_skip; switch (lir_inkey) { case 'X': goto cal_skip; case 'A': if( (ui.rx_input_mode&DIGITAL_IQ) != 0)break; if( (fft1_calibrate_flag&CALAMP)==CALAMP) { clear_screen(); lir_text(5,5,"The amplitudes are already calibrated."); make_iqcorr_filename(s); sprintf(ss,"Exit from Linrad and remove the file %s",s); lir_text(1,6,ss); lir_text(5,8,press_any_key); await_keyboard(); break; } usercontrol_mode=USR_IQ_BALANCE; init_semaphores(); ampinfo_flag=1; linrad_thread_create(rx_input_thread); if(kill_all_flag) goto cal_skip_freesem; linrad_thread_create(THREAD_USER_COMMAND); if(kill_all_flag) goto iqbal; linrad_thread_create(THREAD_CAL_IQBALANCE); if(kill_all_flag) goto iqbal; linrad_thread_create(THREAD_WIDEBAND_DSP); iqbal:; lir_sleep(50000); lir_refresh_screen(); lir_join(THREAD_USER_COMMAND); linrad_thread_stop_and_join(rx_input_thread); linrad_thread_stop_and_join(THREAD_CAL_IQBALANCE); linrad_thread_stop_and_join(THREAD_WIDEBAND_DSP); free_semaphores(); if(kill_all_flag) goto cal_skip; break; case 'B': goto pulsecal; case 'C': if(remove_iq_notch() == 0)goto cal_skip; break; case 'D': final_filtercorr_init(); goto cal_skip; case F1_KEY: help_message(302); break; } } else { lir_text(5, 9,"A=> Calibrate frequency response"); lir_text(5,10,"B=> Refine amplitude and phase correction"); await_processed_keyboard(); if(kill_all_flag) goto cal_skip; switch (lir_inkey) { case 'X': goto cal_skip; case 'A': goto pulsecal; case 'B': final_filtercorr_init(); goto cal_skip; case F1_KEY: help_message(303); break; } } goto iqbeg; pulsecal:; timf1p_pa=0; usercontrol_mode=USR_CAL_INTERVAL; init_semaphores(); ampinfo_flag=1; linrad_thread_create(rx_input_thread); if(kill_all_flag) goto cal_skip_freesem; linrad_thread_create(THREAD_USER_COMMAND); if(kill_all_flag) goto calint; linrad_thread_create(THREAD_CAL_INTERVAL); calint:; lir_sleep(50000); lir_refresh_screen(); lir_join(THREAD_USER_COMMAND); linrad_thread_stop_and_join(rx_input_thread); linrad_thread_stop_and_join(THREAD_CAL_INTERVAL); free_semaphores(); if(kill_all_flag)goto cal_skip; clear_screen(); lir_refresh_screen(); if(usercontrol_mode != USR_CAL_FILTERCORR)goto iqbeg; if( (ui.rx_input_mode&IQ_DATA) == 0)cal_interval/=2; #define ERRLINE 5 if(cal_interval > fft1_size/5) { lir_text(5,ERRLINE,"Pulse repetition frequency too low."); lir_text(5,ERRLINE+1,"Increase PRF or set fft1 bandwidth lower to"); lir_text(5,ERRLINE+2,"increase transform size."); err1:; lir_text(5,ERRLINE+5,press_any_key); await_keyboard(); goto iqbeg; } if(cal_signal_level > 0.9) { lir_text(5,ERRLINE,"Pulses too strong (above 90%)"); goto err1; } timf1p_pa=0; timf1p_px=0; init_semaphores(); linrad_thread_create(rx_input_thread); if(kill_all_flag) goto cal_skip_freesem; linrad_thread_create(THREAD_WIDEBAND_DSP); if(kill_all_flag) goto calfil; linrad_thread_create(THREAD_CAL_FILTERCORR); if(kill_all_flag) goto calfil; linrad_thread_create(THREAD_USER_COMMAND); calfil:; lir_sleep(50000); lir_refresh_screen(); lir_join(THREAD_USER_COMMAND); linrad_thread_stop_and_join(rx_input_thread); linrad_thread_stop_and_join(THREAD_CAL_FILTERCORR); linrad_thread_stop_and_join(THREAD_WIDEBAND_DSP); free_semaphores(); if(kill_all_flag)goto cal_skip; goto iqbeg; // ******************************** cal_skip_freesem:; free_semaphores(); cal_skip:; memcheck(199,calmem,(int*)&calmem_handle); calmem_handle=chk_free(calmem_handle); free_buffers(); } void restore_uiparm(void) { int i; int *uiparm; uiparm=(void*)(&ui); for(i=0; i= MAX_RX_MODE)goto saverr_close; i=fread(s,1,1,file); if(i != 1)goto saverr_close; if(s[0]=='1') { savefile_repeat_flag=1; } else { if(s[0]!='0')goto saverr_close; savefile_repeat_flag=0; } if(wav_read_flag==0)goto skip_modlin; i=fread(s,1,1,file); if(i != 1)goto saverr_close; if(s[0]=='1') { iqflag=1; i=fread(s,1,1,file); if(i != 1)goto saverr_close; if(s[0]=='1') { dirflag=1; } else { if(s[0]!='0')goto saverr_close; dirflag=0; } } else { if(s[0]!='0')goto saverr_close; iqflag=0; } skip_modlin:; // We use disk input and something was wrong with the first line. // Read until end of line, then ask the user for the desired mode. i=fread(s,1,1,file); if(s[0]=='\n') goto fileok; if(i==1)goto skip_modlin; saverr_close:; fclose(file); saverr:; parwrite_flag=1; } if(disksave_flag == 2) { for(i=0; i MAX_RX_MODE) { toupper_await_keyboard(); if(kill_all_flag) return; rx_mode=lir_inkey-'A'; } clear_screen(); lir_text(5,5,"Repeat recording endlessly (Y/N)?"); savrpt:; toupper_await_keyboard(); if(kill_all_flag) return; if(lir_inkey=='Y') { savefile_repeat_flag=1; } else { if(lir_inkey != 'N')goto savrpt; savefile_repeat_flag=0; } if( wav_read_flag != 0) { if(ui.rx_ad_channels == 2) { lir_text(5,6,"Stereo recording. Interpret as I/Q data (Y/N) ?"); wawiq:; toupper_await_keyboard(); if(kill_all_flag) return; if(lir_inkey=='Y') { iqflag=1; lir_text(5,7,"Invert frequency scale (Y/N) ?"); diriq:; toupper_await_keyboard(); if(kill_all_flag) return; if(lir_inkey=='Y') { dirflag=1; } else { if(lir_inkey != 'N')goto diriq; dirflag=0; } } else { if(lir_inkey != 'N')goto wawiq; iqflag=0; } } } if(savefile_parname[0]!=0) { file = fopen( savefile_parname, "r"); if(file == NULL) parwrite_flag=1; } } if(parfile_flag == 0)parfilnam=rxpar_filenames[rx_mode]; file = fopen(rxpar_filenames[rx_mode], "r"); if(file == NULL) { sprintf(s,"%s file missing",rxpar_filenames[rx_mode]); prompt_reason(s); iniparm:; if(kill_all_flag) return; for(i=0; i= 4095) { sprintf(ss,"Excessive file size"); daterr:; sprintf(s,"%s Data error in file %s",ss,parfilnam); prompt_reason(s); goto iniparm; } k=0; for(i=0; i kmax) { sprintf(ss,"Premature end of file"); daterr_free:; parinfo=chk_free(parinfo); goto daterr; } j=0; while(parinfo[k]== genparm_text[i][j]) { k++; j++; } sprintf(ss,"Error: %s ",genparm_text[i]); if(genparm_text[i][j] != 0 || k > kmax) { goto daterr_free; } while(k <= kmax && parinfo[k]!='[')k++; if(k > kmax) { goto daterr_free; } sscanf(&parinfo[k],"[%d]",&genparm[i]); while(k <= kmax && parinfo[k]!='\n')k++; if(k > kmax) { goto daterr_free; } } parinfo=chk_free(parinfo); if(disksave_flag == 4) { if(init_diskread(-1) != 0) { lirerr(3641); free(parinfo); return; } } else { if(genparm[MAX_GENPARM] != ui.rx_ad_speed) { sprintf(s,"Input sampling speed changed %d (old=%d)", ui.rx_ad_speed, genparm[MAX_GENPARM]); prompt_reason(s); goto iniparm; } } if(genparm[MAX_GENPARM+1] != (int)(GENPARM_VERNR)) { prompt_reason("GENPARM version changed"); goto iniparm; } if(rx_mode!=MODE_WCW && rx_mode!=MODE_NCW && rx_mode!=MODE_HSMS && genparm[CW_DECODE_ENABLE] != 0) { prompt_reason("Mode not compatible with morse decode"); goto iniparm; } for(i=0; i genparm_max[i]) { illegal_value:; sprintf(s,"Illegal value for %s: %d (%d to %d)",genparm_text[i], genparm[i],genparm_min[i], genparm_max[i]); prompt_reason(s); goto iniparm; } } fft1mode=(ui.rx_input_mode&(TWO_CHANNELS+IQ_DATA))/2; i=fft1_version[fft1mode][genparm[FIRST_FFT_VERNR]]; if( i < 0 || i>=MAX_FFT_VERSIONS) { prompt_reason("FFT1 version incompatible with A/D mode"); goto iniparm; } if(simd_present == 0) { if( fft_cntrl[i].simd != 0) { prompt_reason("Parameters say use SIMD - not supported by computer!"); goto iniparm; } } if(genparm[SECOND_FFT_ENABLE] != 0) { if(mmx_present == 0) { if( fft_cntrl[i].mmx != 0) { nommx:; prompt_reason("Parameters say use MMX - not supported by computer!"); goto iniparm; } } i=fft1_back_version[ui.rx_rf_channels-1][genparm[FIRST_BCKFFT_VERNR]]; if( i < 0 || i>=MAX_FFT_VERSIONS) { prompt_reason("Backwards FFT1 version incompatible with no of channels"); goto iniparm; } if(mmx_present == 0) { if( fft_cntrl[i].mmx != 0)goto nommx; } i=fft2_version[ui.rx_rf_channels-1][genparm[SECOND_FFT_VERNR]]; if( i < 0 || i>=MAX_FFT_VERSIONS) { prompt_reason("FFT2 version incompatible with no of channels"); goto iniparm; } if(mmx_present == 0) { if( fft_cntrl[i].mmx != 0)goto nommx; } // Make sure fft1_n and fft2_n are defined. get_wideband_sizes(); if(kill_all_flag) return; k=(fft1_n-4)&0xfffe; if(genparm[FIRST_BCKFFT_ATT_N]>k) { i=FIRST_BCKFFT_ATT_N; goto illegal_value; } k=fft2_n-2; if(genparm[SECOND_FFT_ATT_N]>k) { i=SECOND_FFT_ATT_N; goto illegal_value; } } if(genparm[DA_OUTPUT_SPEED] > ui.rx_max_da_speed|| genparm[DA_OUTPUT_SPEED] < ui.rx_min_da_speed) { sprintf(s,"Output sampling speed out of range %d (%d to %d)", genparm[DA_OUTPUT_SPEED],ui.rx_min_da_speed, ui.rx_max_da_speed); prompt_reason(s); goto iniparm; } check_output_no_of_channels(); } if( wav_read_flag != 0) { if(iqflag==1) { ui.rx_rf_channels=1; ui.rx_input_mode|=IQ_DATA; } else { ui.rx_input_mode|=TWO_CHANNELS; } if(dirflag == 1) { fg.passband_direction=-1; } else { fg.passband_direction=1; } fft1_direction=fg.passband_direction; } if(genparm[AFC_ENABLE] == 0) { genparm[CW_DECODE_ENABLE]=0; } if(parwrite_flag!=0)goto write_savefile_parms; } void main_menu(void) { int first_txproc_no; int i, k, m; int uiupd; char s[256],ss[80]; char *sdrnam, *netin; int ctlc_fix; int x[4096]; int message_line; FILE *file; int *uiparm; float t1, t2; uiparm=(void*)(&ui); eme_flag=0; read_eme_database(); if(kill_all_flag) goto menu_x; // Save the ui parameters. // The user has set up the sound cards for normal operation // with his hardware but some routines, e.g. txtest may change // the A/D parameters and/or other parameters. // We will always start here with the initial ui parameters. save_uiparm(); ctlc_fix=3; menu_loop:; restore_uiparm(); clear_screen(); settextcolor(12); if(ui.rx_addev_no == SDR14_DEVICE_CODE) { sdrnam=sdr14_name_string; } else { if(ui.rx_addev_no == SDRIQ_DEVICE_CODE) { sdrnam=sdriq_name_string; } else { sdrnam=" "; } } if((ui.network_flag&NET_RX_INPUT) != 0) { switch (ui.network_flag & NET_RX_INPUT) { case NET_RXIN_RAW16: netin="RAW16"; break; case NET_RXIN_RAW18: netin="RAW18"; break; case NET_RXIN_RAW24: netin="RAW24"; break; case NET_RXIN_FFT1: netin="FFT1"; break; default: netin="ERROR"; break; } sdrnam=" "; sprintf(ss,"NETWORK RX INPUT %s",netin); } else { if(allow_parport) { sprintf(ss,"Parport %d:%d",ui.parport,ui.parport_pin); } else { ss[0]=0; } } sprintf(s,"%s %s %s",PROGRAM_NAME, ss, sdrnam); lir_text(14,0,s); if((ui.network_flag&NET_RX_OUTPUT) != 0)lir_text(0,0,"NETSEND"); lir_refresh_screen(); if(kill_all_flag)goto menu_x; settextcolor(7); button_color=7; for(i=0; i0) { // We have to write several times to the screen in order to // not destroy the terminals Alt F1, Alt F2, Alt F3.... when entering // the very first time. // The videocard settings become corrupted if a ctrl C is pressed // before we wrote enough to the screen. The reason is unknown // but this fix helps svgalib-1.9.21 as well as svgalib-1.9.24 ctlc_fix--; goto menu_loop; } if(kill_all_flag) goto menu_x; toupper_await_keyboard(); if(kill_all_flag) goto menu_x; menu_loop_b:; savefile_parname[0]=0; calibrate_flag=0; disksave_flag=0; iqflag=0; dirflag=0; rx_input_thread=THREAD_RX_ADINPUT; if(ui.rx_addev_no == SDR14_DEVICE_CODE || ui.rx_addev_no == SDRIQ_DEVICE_CODE )rx_input_thread=THREAD_SDR14_INPUT; t1=t2=0; x[0]=0; parfilnam=NULL; lir_status=LIR_OK; switch ( lir_inkey ) { case 'R': manage_network(NET_RX_INPUT); save_uiparm(); uiparm_change_flag=TRUE; break; case 'T': manage_network(NET_RX_OUTPUT); save_uiparm(); uiparm_change_flag=TRUE; break; case 'M': init_eme_database(); if(kill_all_flag) goto menu_x; break; case F1_KEY: help_message(1); if(kill_all_flag) goto menu_x; break; if((ui.network_flag&NET_RX_INPUT) == 0) { case '1': case '3': wav_read_flag=0; rx_input_thread=THREAD_RX_FILE_INPUT; if(init_diskread(lir_inkey-'1') == 0) goto do_pc_radio; break; case '2': case '4': wav_read_flag=1; rx_input_thread=THREAD_RX_FILE_INPUT; if(init_diskread(lir_inkey-'2') == 0) goto do_pc_radio; break; case 'U': setad:; set_analog_io(); if(kill_all_flag) goto menu_x; save_uiparm(); uiparm_change_flag=TRUE; break; case 'V': i=tx_setup(); if(kill_all_flag) goto menu_x; if(i==TRUE) { save_uiparm(); uiparm_change_flag=TRUE; } break; case 'Z': hware_interface_test(); if(kill_all_flag) goto menu_x; break; } case 'N': manage_network(0); if(kill_all_flag) goto menu_x; save_uiparm(); uiparm_change_flag=TRUE; break; case 'S': switch (os_flag) { case OS_FLAG_LINUX: lin_global_uiparms(1); break; case OS_FLAG_WINDOWS: win_global_uiparms(1); break; case OS_FLAG_X: x_global_uiparms(1); break; } if(kill_all_flag) goto menu_x; save_uiparm(); uiparm_change_flag=TRUE; break; case 'W': file = fopen(userint_filename, "w"); if (file == NULL) { lirerr(1029); goto menu_x; } ui.check=UI_VERNR; for(i=0; i=MAX_RX_MODE)goto menu_loop; if( (ui.network_flag&NET_RX_INPUT)==0 && ui.rx_input_mode < 0)goto setad; if(ui.rx_max_da_channels==0)goto setad; { do_pc_radio:; calibrate_flag=0; parfilnam=NULL; open_mouse(); rxinput_local_px=0; uiupd=FALSE; if((ui.network_flag&NET_RX_INPUT) == 0) { updparm:; init_genparm(uiupd); if(kill_all_flag) goto menu_x; } clear_screen(); settextcolor(7); #if (USERS_EXTRA_PRESENT == 1) init_users_extra(); #endif lir_status=LIR_OK; fft1_waterfall_flag=0; all_threads_started=FALSE; switch (rx_mode) { case MODE_WCW: case MODE_NCW: case MODE_HSMS: case MODE_SSB: case MODE_QRSS: use_bfo=1; goto do_normal_rx; case MODE_FM: case MODE_AM: use_bfo=0; do_normal_rx:; usercontrol_mode=USR_NORMAL_RX; first_txproc_no=tg.spproc_no; if(read_txpar_file()==FALSE)ui.tx_enable=0; if(ui.network_flag!=0) { if( (ui.network_flag & (NET_RXOUT_FFT2+NET_RXOUT_TIMF2)) != 0 && genparm[SECOND_FFT_ENABLE] == 0) { lirerr(1281); goto menu_x; } init_network(); if(kill_all_flag) goto menu_x; } else { get_wideband_sizes(); if(kill_all_flag) goto menu_x; get_buffers(1); } if(kill_all_flag) goto menu_x; if(lir_status != LIR_OK)goto rx_modes_exit; if(disksave_flag < 2 && netfd.rec_rx == INVSOCK) { read_freq_control_data(); } check_filtercorr_direction(); init_wide_graph(); if( genparm[SECOND_FFT_ENABLE] != 0 )init_blanker(); if(kill_all_flag) goto menu_x; if(lir_status != LIR_OK)goto rx_modes_exit; if(genparm[SECOND_FFT_ENABLE] != 0) { init_hires_graph(); if(kill_all_flag) goto menu_x; if(lir_status != LIR_OK)goto rx_modes_exit; } if(genparm[AFC_ENABLE] != 0) { init_afc_graph(); if(kill_all_flag) goto menu_x; if(lir_status != LIR_OK) goto rx_modes_exit; } if(ui.rx_rf_channels == 2) { init_pol_graph(); if(kill_all_flag) goto menu_x; if(lir_status != LIR_OK) goto rx_modes_exit; } init_baseband_graph(); if(kill_all_flag) goto menu_x; if(lir_status != LIR_OK) goto rx_modes_exit; init_coherent_graph(); if(kill_all_flag) goto menu_x; if(lir_status != LIR_OK) goto rx_modes_exit; if(eme_flag != 0) { init_eme_graph(); if(kill_all_flag) goto menu_x; if(lir_status != LIR_OK) goto rx_modes_exit; } if(disksave_flag < 2 && netfd.rec_rx==INVSOCK) { init_freq_control(); if(kill_all_flag) goto menu_x; if(lir_status != LIR_OK) goto rx_modes_exit; } if(ui.tx_enable!=0 ) { // Get the xxproc file that the user stored in tg.spproc_no init_tx_graph(); if(read_txpar_file()==FALSE) { // If it failed, read the one that was succesful before. tg.spproc_no=first_txproc_no; read_txpar_file(); } } // Make sure users_init_mode is the last window(s) we open. // the avoid collission routine does not know where // users windows are placed. users_init_mode(); if(kill_all_flag) goto menu_x; if(lir_status != LIR_OK) goto rx_modes_exit; init_semaphores(); linrad_thread_create(rx_input_thread); if(kill_all_flag) goto normal_rx; if( (ui.rx_input_mode&NO_DUPLEX)==0) { linrad_thread_create(THREAD_RX_OUTPUT); if(kill_all_flag) goto normal_rx; } linrad_thread_create(THREAD_USER_COMMAND); if(kill_all_flag) goto normal_rx; linrad_thread_create(THREAD_NARROWBAND_DSP); if(kill_all_flag) goto normal_rx; linrad_thread_create(THREAD_WIDEBAND_DSP); if(kill_all_flag) goto normal_rx; linrad_thread_create(THREAD_SCREEN); if(kill_all_flag) goto normal_rx; if((ui.network_flag&NET_RX_OUTPUT)!=0) { linrad_thread_create(THREAD_LIR_SERVER); if(kill_all_flag) goto normal_rx; } if(ui.tx_enable!=0 ) { open_tx_output(); if(kill_all_flag)goto normal_rx; open_tx_input(); if(kill_all_flag)goto normal_rx;; switch (rx_mode) { case MODE_SSB: init_txmem_spproc(); break; case MODE_WCW: case MODE_NCW: case MODE_HSMS: case MODE_QRSS: init_txmem_cwproc(); break; } if(kill_all_flag)goto normal_rx; linrad_thread_create(THREAD_TX_INPUT); if(kill_all_flag) goto normal_rx; linrad_thread_create(THREAD_TX_OUTPUT); if(kill_all_flag) goto normal_rx; lir_mutex_init(); } normal_rx:; fft1_waterfall_flag=1; lir_sleep(50000); lir_refresh_screen(); all_threads_started=TRUE; lir_sleep(50000); rxin_block_counter=0; i=0; k=0; t1=4000000./interrupt_rate; if(disksave_flag < 2) { while(!kill_all_flag && thread_status_flag[THREAD_USER_COMMAND]==THRFLAG_ACTIVE) { m=30; while(m>0 && rxin_block_counter == i) { m--; lir_sleep(t1); } if(rxin_block_counter == i && i!=0) { sprintf(s,"No input %d",k); lir_text(0,screen_last_line,s); lir_refresh_screen(); } k++; if(k==10000)k=1; i=rxin_block_counter; } m=30; while(m>0 && rxin_block_counter == i) { m--; lir_sleep(t1); } if(rxin_block_counter == i && i!=0) { sprintf(s,"No input %d",k); lir_text(0,screen_last_line,s); lir_refresh_screen(); lirerr(1284); } } lir_join(THREAD_USER_COMMAND); if( (ui.rx_input_mode&NO_DUPLEX)==0) { linrad_thread_stop_and_join(THREAD_RX_OUTPUT); } linrad_thread_stop_and_join(rx_input_thread); linrad_thread_stop_and_join(THREAD_SCREEN); linrad_thread_stop_and_join(THREAD_NARROWBAND_DSP); if((ui.network_flag&NET_RX_OUTPUT)!=0) { linrad_thread_stop_and_join(THREAD_LIR_SERVER); } if(ui.tx_enable!=0) { linrad_thread_stop_and_join(THREAD_TX_OUTPUT); linrad_thread_stop_and_join(THREAD_TX_INPUT); close_tx_output(); close_tx_input(); free(txmem_handle); } lir_mutex_destroy(); linrad_thread_stop_and_join(THREAD_WIDEBAND_DSP); free_semaphores(); if(kill_all_flag) goto menu_x; break; case MODE_TXTEST: usercontrol_mode=USR_TXTEST; if(ui.network_flag != 0 || disksave_flag != 0) { lirerr(1158); goto menu_x; } if( (ui.rx_input_mode&IQ_DATA) != 0) { ui.rx_ad_channels=2; } else { ui.rx_ad_channels=1; } ui.rx_input_mode&=-1-TWO_CHANNELS; ui.rx_rf_channels=1; genparm[AFC_ENABLE]=0; genparm[SECOND_FFT_ENABLE]=0; get_wideband_sizes(); if(kill_all_flag) goto menu_x; // Open the graph windows on the screen. // Note that they must be opened in this order because // Each window is placed outside the previous ones and the init // routines assumes the order below and does not check for all possible // conflicts. get_buffers(1); if(kill_all_flag) goto menu_x; if(lir_status != LIR_OK)goto rx_modes_exit; read_freq_control_data(); init_wide_graph(); if(kill_all_flag) goto menu_x; for(i=0; i .99 || bal_updflag == 1) { settextcolor(14); lir_text(3,10,"Calibrate the RX2500 (Read z_CALIBRATE.txt)"); settextcolor(7); lir_text(5,13,press_any_key); await_processed_keyboard(); if(kill_all_flag) goto menu_x; break; } lir_inkey=0; init_semaphores(); linrad_thread_create(rx_input_thread); if(kill_all_flag) goto tune; linrad_thread_create(THREAD_TUNE); if(kill_all_flag) goto tune; linrad_thread_create(THREAD_USER_COMMAND); tune:; lir_sleep(50000); lir_refresh_screen(); all_threads_started=TRUE; lir_join(THREAD_USER_COMMAND); linrad_thread_stop_and_join(rx_input_thread); linrad_thread_stop_and_join(THREAD_TUNE); free_semaphores(); if(kill_all_flag)goto menu_x; break; default: lirerr(436); } rx_modes_exit:; close_network_sockets(); if( (disksave_flag&(2+4+8)) != 0) { disksave_flag=4; fclose(save_file); save_file=NULL; } txtest_exit:; free_buffers(); if(kill_all_flag)goto menu_x; if(lir_status > LIR_OK) { if(lir_status == LIR_TUNEERR)goto menu_loop; clear_screen(); lir_text(5,5,"Out of memory. Try less demanding parameters"); lir_text(5,8,press_any_key); await_keyboard(); if(kill_all_flag) goto menu_x; go_updparm:; uiupd=TRUE; restore_uiparm(); goto updparm; } settextcolor(7); if(lir_status == LIR_NEW_POL) { clear_screen(); select_pol_default(); if(kill_all_flag) goto menu_x; lir_status = LIR_OK; goto do_pc_radio; } if(lir_status == LIR_POWTIM)goto do_pc_radio; if(lir_status < LIR_OK) { goto go_updparm; } fft1_waterfall_flag=0; wt_kbd:; clear_screen(); settextcolor(12); lir_text(25,1,PROGRAM_NAME); settextcolor(15); sprintf(s,"B = Back to %s without change",rxmodes[rx_mode]); lir_text(12,3,s); lir_text(12,4,"P = Change parameters"); lir_text(12,5,"C = Calibrate"); if(ui.rx_rf_channels == 2)lir_text(12,6,"D = Select Pol. default"); settextcolor(7); sprintf(s,"Current parameters (file: %s)",parfilnam); lir_text(2,8,s); for(i=0; i