@ -21,6 +21,7 @@
*/
# include <ctype.h>
# include <ctime>
# include <errno.h>
# include <stdio.h>
# include <unistd.h>
@ -28,15 +29,14 @@
# include <stdint.h>
# include <string.h>
# include <getopt.h>
# include <allegro.h>
# include "parameters.h"
# include "gpib_functions.h"
# include "gpib/ib.h"
char falpha [ 1024 ] ;
extern char falpha [ 1024 ] ;
double commanalyzer_raw_trace_data [ 1024 ] ;
unsigned long commanalyzerTraceLength ( char * commanalyzerType ) {
unsigned long commanalyzerTraceLength ( const char * commanalyzerType ) {
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
return 417 ;
}
@ -45,7 +45,7 @@ unsigned long commanalyzerTraceLength (char * commanalyzerType) {
}
}
int commanalyzer_set_date ( struct tm * datetime , char * commanalyzerType , int gpibDevice ) {
int commanalyzer_set_date ( struct tm * datetime , const char * commanalyzerType , int gpibDevice ) {
char datebuffer [ 80 ] ;
strftime ( datebuffer , 80 , " CONF:DATE %m%d%y " , datetime ) ;
@ -62,13 +62,16 @@ int commanalyzer_set_date(struct tm * datetime, char * commanalyzerType, int gpi
return 2 ;
}
}
else {
return 1 ;
}
}
else {
return 1 ;
}
}
int commanalyzer_set_time ( struct tm * datetime , char * commanalyzerType , int gpibDevice ) {
int commanalyzer_set_time ( struct tm * datetime , const char * commanalyzerType , int gpibDevice ) {
char timebuffer [ 80 ] ;
strftime ( timebuffer , 80 , " CONF:TIME +%H.%M " , datetime ) ; // FIXME wrong format
@ -85,13 +88,16 @@ int commanalyzer_set_time(struct tm * datetime, char * commanalyzerType, int gpi
return 2 ;
}
}
else {
return 1 ;
}
}
else {
return 1 ;
}
}
int commanalyzer_switch_to_spectrum_analyzer_mode ( char * commanalyzerType , int gpibDevice ) {
int commanalyzer_switch_to_spectrum_analyzer_mode ( const char * commanalyzerType , int gpibDevice ) {
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
printf ( " [INFO] Setting communications analyzer to spectrum anayzer mode \n \r " ) ;
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
@ -106,13 +112,16 @@ int commanalyzer_switch_to_spectrum_analyzer_mode(char * commanalyzerType, int g
return 2 ;
}
}
else {
return 1 ;
}
}
else {
return 1 ;
}
}
int commanalyzer_lock_screen ( char * commanalyzerType , int gpibDevice ) {
int commanalyzer_lock_screen ( const char * commanalyzerType , int gpibDevice ) {
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
printf ( " [INFO] Locking communications analyzer screen \n \r " ) ;
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
@ -127,13 +136,16 @@ int commanalyzer_lock_screen (char * commanalyzerType, int gpibDevice) {
return 2 ;
}
}
else {
return 1 ;
}
}
else {
return 1 ;
}
}
int commanalyzer_spectrum_analyzer_set_generator_mode_tracking ( char * commanalyzerType , int gpibDevice ) {
int commanalyzer_spectrum_analyzer_set_generator_mode_tracking ( const char * commanalyzerType , int gpibDevice ) {
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
printf ( " [INFO] Setting spectrum analyzer generator to tracking mode \n \r " ) ;
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
@ -148,13 +160,16 @@ int commanalyzer_spectrum_analyzer_set_generator_mode_tracking (char * commanaly
return 2 ;
}
}
else {
return 1 ;
}
}
else {
return 1 ;
}
}
int commanalyzer_spectrum_analyzer_set_generator_mode_fixed ( char * commanalyzerType , int gpibDevice ) {
int commanalyzer_spectrum_analyzer_set_generator_mode_fixed ( const char * commanalyzerType , int gpibDevice ) {
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
printf ( " [INFO] Setting spectrum analyzer generator to fixed mode \n \r " ) ;
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
@ -169,13 +184,16 @@ int commanalyzer_spectrum_analyzer_set_generator_mode_fixed (char * commanalyzer
return 2 ;
}
}
else {
return 1 ;
}
}
else {
return 1 ;
}
}
int commanalyzer_spectrum_analyzer_set_rf_input_dedicated ( char * commanalyzerType , int gpibDevice ) {
int commanalyzer_spectrum_analyzer_set_rf_input_dedicated ( const char * commanalyzerType , int gpibDevice ) {
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
printf ( " [INFO] Setting spectrum analyzer RF input to dedicated connector \n \r " ) ;
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
@ -190,13 +208,16 @@ int commanalyzer_spectrum_analyzer_set_rf_input_dedicated (char * commanalyzerTy
return 2 ;
}
}
else {
return 1 ;
}
}
else {
return 1 ;
}
}
int commanalyzer_spectrum_analyzer_set_rf_input_muxed ( char * commanalyzerType , int gpibDevice ) {
int commanalyzer_spectrum_analyzer_set_rf_input_muxed ( const char * commanalyzerType , int gpibDevice ) {
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
printf ( " [INFO] Setting spectrum analyzer RF input to multiplexed connector \n \r " ) ;
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
@ -211,13 +232,16 @@ int commanalyzer_spectrum_analyzer_set_rf_input_muxed (char * commanalyzerType,
return 2 ;
}
}
else {
return 1 ;
}
}
else {
return 1 ;
}
}
int commanalyzer_spectrum_analyzer_set_generator_output_dedicated ( char * commanalyzerType , int gpibDevice ) {
int commanalyzer_spectrum_analyzer_set_generator_output_dedicated ( const char * commanalyzerType , int gpibDevice ) {
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
printf ( " [INFO] Setting spectrum analyzer generator output to dedicated connector \n \r " ) ;
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
@ -232,13 +256,16 @@ int commanalyzer_spectrum_analyzer_set_generator_output_dedicated (char * comman
return 2 ;
}
}
else {
return 1 ;
}
}
else {
return 1 ;
}
}
int commanalyzer_spectrum_analyzer_set_generator_output_muxed ( char * commanalyzerType , int gpibDevice ) {
int commanalyzer_spectrum_analyzer_set_generator_output_muxed ( const char * commanalyzerType , int gpibDevice ) {
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
printf ( " [INFO] Setting spectrum analyzer generator output to multiplexed connector \n \r " ) ;
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
@ -253,25 +280,25 @@ int commanalyzer_spectrum_analyzer_set_generator_output_muxed (char * commanalyz
return 2 ;
}
}
else {
return 1 ;
}
}
else {
return 1 ;
}
}
int commanalyzer_get_spectrum_analyzer_trace ( char * commanalyzerType , int gpibDevice ) {
int commanalyzer_get_spectrum_analyzer_trace ( const char * commanalyzerType , int gpibDevice ) {
int max_num_bytes = 0 ;
unsigned char segarray [ 4194304 ] ;
unsigned char floatstring [ 1024 ] ;
char segarray [ 4194304 ] ;
char floatstring [ 1024 ] ;
long array_pointer ;
long ai ;
long left_char ;
long right_char ;
int x ;
int y ;
if ( ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) ) {
// Send request
printf ( " [INFO] Getting spectrum analyzer trace [Stage 1] \n \r " ) ;
@ -331,9 +358,12 @@ int commanalyzer_get_spectrum_analyzer_trace(char * commanalyzerType, int gpibDe
return 0 ;
}
else {
return 1 ;
}
}
int commanalyzer_set_spectrum_analyzer_center_frequency ( float desired_frequency , char * commanalyzerType , int gpibDevice ) {
int commanalyzer_set_spectrum_analyzer_center_frequency ( float desired_frequency , const char * commanalyzerType , int gpibDevice ) {
if ( ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) ) {
printf ( " [INFO] Setting spectrum analyzer center frequency to %f \n \r " , desired_frequency ) ;
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
@ -348,13 +378,16 @@ int commanalyzer_set_spectrum_analyzer_center_frequency(float desired_frequency,
return 2 ;
}
}
else {
return 1 ;
}
}
else {
return 1 ;
}
}
int commanalyzer_set_spectrum_analyzer_frequency_span ( float desired_frequency , char * commanalyzerType , int gpibDevice ) {
int commanalyzer_set_spectrum_analyzer_frequency_span ( float desired_frequency , const char * commanalyzerType , int gpibDevice ) {
if ( ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) ) {
printf ( " [INFO] Setting spectrum analyzer span frequency to %f \n \r " , desired_frequency ) ;
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
@ -369,13 +402,16 @@ int commanalyzer_set_spectrum_analyzer_frequency_span(float desired_frequency, c
return 2 ;
}
}
else {
return 1 ;
}
}
else {
return 1 ;
}
}
int commanalyzer_set_spectrum_analyzer_input_attenuation ( float desired_attenuation , char * commanalyzerType , int gpibDevice ) {
int commanalyzer_set_spectrum_analyzer_input_attenuation ( float desired_attenuation , const char * commanalyzerType , int gpibDevice ) {
int instrument_att ;
if ( ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) ) {
@ -391,6 +427,9 @@ int commanalyzer_set_spectrum_analyzer_input_attenuation(float desired_attenuati
instrument_att = 40 ;
}
}
else {
return 1 ;
}
printf ( " [INFO] Setting spectrum analyzer attenuation to %d dB \n \r " , instrument_att ) ;
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
sprintf ( falpha , " SAN:ATT '%d DB' " , instrument_att ) ;
@ -404,13 +443,16 @@ int commanalyzer_set_spectrum_analyzer_input_attenuation(float desired_attenuati
return 2 ;
}
}
else {
return 1 ;
}
}
else {
return 1 ;
}
}
int commanalyzer_set_spectrum_analyzer_scale ( float desired_scale , char * commanalyzerType , int gpibDevice ) {
int commanalyzer_set_spectrum_analyzer_scale ( float desired_scale , const char * commanalyzerType , int gpibDevice ) {
int instrument_scale ;
if ( ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) ) {
@ -426,6 +468,9 @@ int commanalyzer_set_spectrum_analyzer_scale(float desired_scale, char * commana
instrument_scale = 10 ;
}
}
else {
return 1 ;
}
printf ( " [INFO] Setting spectrum analyzer scale to %d dB/div \n \r " , instrument_scale ) ;
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
sprintf ( falpha , " SAN:DISP:SCAL '%d DB/DIV' " , instrument_scale ) ;
@ -439,13 +484,16 @@ int commanalyzer_set_spectrum_analyzer_scale(float desired_scale, char * commana
return 2 ;
}
}
else {
return 1 ;
}
}
else {
return 1 ;
}
}
int commanalyzer_set_spectrum_analyzer_input_attenuator_mode_auto ( char * commanalyzerType , int gpibDevice ) {
int commanalyzer_set_spectrum_analyzer_input_attenuator_mode_auto ( const char * commanalyzerType , int gpibDevice ) {
if ( ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) ) {
printf ( " [INFO] Setting spectrum analyzer attenuation mode to automatic \n \r " ) ;
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
@ -460,13 +508,16 @@ int commanalyzer_set_spectrum_analyzer_input_attenuator_mode_auto( char * comman
return 2 ;
}
}
else {
return 1 ;
}
}
else {
return 1 ;
}
}
int commanalyzer_set_spectrum_analyzer_input_attenuator_mode_fixed ( char * commanalyzerType , int gpibDevice ) {
int commanalyzer_set_spectrum_analyzer_input_attenuator_mode_fixed ( const char * commanalyzerType , int gpibDevice ) {
if ( ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) ) {
printf ( " [INFO] Setting spectrum analyzer attenuation mode to fixed \n \r " ) ;
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
@ -481,13 +532,16 @@ int commanalyzer_set_spectrum_analyzer_input_attenuator_mode_fixed( char * comma
return 2 ;
}
}
else {
return 1 ;
}
}
else {
return 1 ;
}
}
int commanalyzer_set_spectrum_analyzer_generator_power ( float desired_power , char * commanalyzerType , int gpibDevice ) {
int commanalyzer_set_spectrum_analyzer_generator_power ( float desired_power , const char * commanalyzerType , int gpibDevice ) {
if ( ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) ) {
printf ( " [INFO] Setting spectrum analyzer generator power to %f \n \r " , desired_power ) ;
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
@ -502,13 +556,16 @@ int commanalyzer_set_spectrum_analyzer_generator_power(float desired_power, char
return 2 ;
}
}
else {
return 1 ;
}
}
else {
return 1 ;
}
}
int commanalyzer_set_spectrum_analyzer_generator_frequency ( float desired_frequency , char * commanalyzerType , int gpibDevice ) {
int commanalyzer_set_spectrum_analyzer_generator_frequency ( float desired_frequency , const char * commanalyzerType , int gpibDevice ) {
if ( ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) ) {
printf ( " [INFO] Setting spectrum analyzer generator frequency to %f \n \r " , desired_frequency ) ;
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
@ -523,13 +580,16 @@ int commanalyzer_set_spectrum_analyzer_generator_frequency(float desired_frequen
return 2 ;
}
}
else {
return 1 ;
}
}
else {
return 1 ;
}
}
int commanalyzer_spectrum_analyzer_set_generator_sweep_ascending ( char * commanalyzerType , int gpibDevice ) {
int commanalyzer_spectrum_analyzer_set_generator_sweep_ascending ( const char * commanalyzerType , int gpibDevice ) {
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
printf ( " [INFO] Setting spectrum analyzer generator output sweep to ascending \n \r " ) ;
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
@ -544,13 +604,16 @@ int commanalyzer_spectrum_analyzer_set_generator_sweep_ascending (char * commana
return 2 ;
}
}
else {
return 1 ;
}
}
else {
return 1 ;
}
}
int commanalyzer_spectrum_analyzer_set_generator_sweep_descending ( char * commanalyzerType , int gpibDevice ) {
int commanalyzer_spectrum_analyzer_set_generator_sweep_descending ( const char * commanalyzerType , int gpibDevice ) {
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
printf ( " [INFO] Setting spectrum analyzer generator output sweep to descending \n \r " ) ;
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
@ -565,13 +628,16 @@ int commanalyzer_spectrum_analyzer_set_generator_sweep_descending (char * comman
return 2 ;
}
}
else {
return 1 ;
}
}
else {
return 1 ;
}
}
int commanalyzer_set_spectrum_analyzer_trace_averaging ( float desired_avg_samples , char * commanalyzerType , int gpibDevice ) {
int commanalyzer_set_spectrum_analyzer_trace_averaging ( float desired_avg_samples , const char * commanalyzerType , int gpibDevice ) {
if ( ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) ) {
int instrument_samples ;
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
@ -598,6 +664,9 @@ int commanalyzer_set_spectrum_analyzer_trace_averaging(float desired_avg_samples
}
}
}
else {
return 1 ;
}
printf ( " [INFO] Setting spectrum analyzer generator trace averaging to %d \n \r " , instrument_samples ) ;
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
if ( instrument_samples > 0 ) {
@ -619,13 +688,16 @@ int commanalyzer_set_spectrum_analyzer_trace_averaging(float desired_avg_samples
return 2 ;
}
}
else {
return 1 ;
}
}
else {
return 1 ;
}
}
int commanalyzer_set_spectrum_analyzer_reference_power_level ( float desired_reflevel , char * commanalyzerType , int gpibDevice ) {
int commanalyzer_set_spectrum_analyzer_reference_power_level ( float desired_reflevel , const char * commanalyzerType , int gpibDevice ) {
if ( ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) ) {
printf ( " [INFO] Setting spectrum analyzer generator reference level to %f dBm \n \r " , desired_reflevel ) ;
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
@ -640,13 +712,16 @@ int commanalyzer_set_spectrum_analyzer_reference_power_level(float desired_refle
return 2 ;
}
}
else {
return 1 ;
}
}
else {
return 1 ;
}
}
int commanalyzer_get_spectrum_analyzer_number_of_vertical_divisions ( char * commanalyzerType , int gpibDevice ) {
int commanalyzer_get_spectrum_analyzer_number_of_vertical_divisions ( const char * commanalyzerType , int gpibDevice ) {
if ( ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) ) {
return 8 ;
}
@ -655,7 +730,7 @@ int commanalyzer_get_spectrum_analyzer_number_of_vertical_divisions( char * comm
}
}
int commanalyzer_get_spectrum_analyzer_number_of_horizontal_divisions ( char * commanalyzerType , int gpibDevice ) {
int commanalyzer_get_spectrum_analyzer_number_of_horizontal_divisions ( const char * commanalyzerType , int gpibDevice ) {
if ( ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) ) {
return 10 ;
}
@ -664,9 +739,9 @@ int commanalyzer_get_spectrum_analyzer_number_of_horizontal_divisions( char * co
}
}
double commanalyzer_get_spectrum_analyzer_reference_power_level ( double * retval , char * commanalyzerType , int gpibDevice ) {
unsigned char segarray [ 4194304 ] ;
unsigned char floatstring [ 1024 ] ;
double commanalyzer_get_spectrum_analyzer_reference_power_level ( double * retval , const char * commanalyzerType , int gpibDevice ) {
char segarray [ 4194304 ] ;
char floatstring [ 1024 ] ;
long array_pointer ;
long ai ;
long left_char ;
@ -689,6 +764,9 @@ double commanalyzer_get_spectrum_analyzer_reference_power_level(double * retval,
return 2 ;
}
}
else {
return 1 ;
}
// Read response
# ifdef ENABLE_EXTRA_DEBUGGING
@ -725,9 +803,9 @@ double commanalyzer_get_spectrum_analyzer_reference_power_level(double * retval,
}
}
double commanalyzer_get_spectrum_analyzer_scale ( double * retval , char * commanalyzerType , int gpibDevice ) {
unsigned char segarray [ 4194304 ] ;
unsigned char floatstring [ 1024 ] ;
double commanalyzer_get_spectrum_analyzer_scale ( double * retval , const char * commanalyzerType , int gpibDevice ) {
char segarray [ 4194304 ] ;
char floatstring [ 1024 ] ;
long array_pointer ;
long ai ;
long left_char ;
@ -750,6 +828,9 @@ double commanalyzer_get_spectrum_analyzer_scale(double * retval, char * commanal
return 2 ;
}
}
else {
return 1 ;
}
// Read response
# ifdef ENABLE_EXTRA_DEBUGGING
@ -795,13 +876,16 @@ double commanalyzer_get_spectrum_analyzer_scale(double * retval, char * commanal
}
}
int commanalyzer_set_display_brightness ( float percent , char * commanalyzerType , int gpibDevice ) {
int commanalyzer_set_display_brightness ( float percent , const char * commanalyzerType , int gpibDevice ) {
int instrument_scale ;
if ( ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) ) {
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
instrument_scale = ( ( percent / 100.0 ) * 7.0 ) + 1 ;
}
else {
return 1 ;
}
printf ( " [INFO] Setting display brightness to %d \n \r " , instrument_scale ) ;
if ( strcmp ( " HP8924C " , commanalyzerType ) = = 0 ) {
sprintf ( falpha , " CONF:INT %d " , instrument_scale ) ;
@ -815,15 +899,18 @@ int commanalyzer_set_display_brightness(float percent, char * commanalyzerType,
return 2 ;
}
}
else {
return 1 ;
}
}
else {
return 1 ;
}
}
double commanalyzer_get_spectrum_analyzer_center_frequency ( double * retval , char * commanalyzerType , int gpibDevice ) {
unsigned char segarray [ 4194304 ] ;
unsigned char floatstring [ 1024 ] ;
double commanalyzer_get_spectrum_analyzer_center_frequency ( double * retval , const char * commanalyzerType , int gpibDevice ) {
char segarray [ 4194304 ] ;
char floatstring [ 1024 ] ;
long array_pointer ;
long ai ;
long left_char ;
@ -846,6 +933,9 @@ double commanalyzer_get_spectrum_analyzer_center_frequency(double * retval, char
return 2 ;
}
}
else {
return 1 ;
}
// Read response
# ifdef ENABLE_EXTRA_DEBUGGING
@ -891,9 +981,9 @@ double commanalyzer_get_spectrum_analyzer_center_frequency(double * retval, char
}
}
double commanalyzer_get_spectrum_analyzer_span ( double * retval , char * commanalyzerType , int gpibDevice ) {
unsigned char segarray [ 4194304 ] ;
unsigned char floatstring [ 1024 ] ;
double commanalyzer_get_spectrum_analyzer_span ( double * retval , const char * commanalyzerType , int gpibDevice ) {
char segarray [ 4194304 ] ;
char floatstring [ 1024 ] ;
long array_pointer ;
long ai ;
long left_char ;