Add preliminary support for HP 8924 series communication analyzer (spectrum analyzer) to GPIB server

Fix build warnings
Formalize copyright notice with FOSS line
master
Timothy Pearson 12 years ago
parent f658d9ce8f
commit 74e755f0c4

@ -1,6 +1,6 @@
bin_PROGRAMS = main_server_lin
main_server_lin_SOURCES = gpib_functions.c main_server_lin.c scope_functions.c \
signal_functions.c
signal_functions.c commanalyzer_functions.c
# set the include path found by configure
INCLUDES= $(all_includes)
@ -8,4 +8,4 @@ INCLUDES= $(all_includes)
# the library search path.
main_server_lin_LDFLAGS = $(all_libraries)
noinst_HEADERS = gpib_functions.h parameters.h scope_functions.h \
signal_functions.h
signal_functions.h commanalyzer_functions.h

@ -138,7 +138,7 @@ sysconfdir = @sysconfdir@
target_alias = @target_alias@
bin_PROGRAMS = main_server_lin
main_server_lin_SOURCES = gpib_functions.c main_server_lin.c scope_functions.c \
signal_functions.c
signal_functions.c commanalyzer_functions.c
# set the include path found by configure
@ -147,7 +147,7 @@ INCLUDES = $(all_includes)
# the library search path.
main_server_lin_LDFLAGS = $(all_libraries)
noinst_HEADERS = gpib_functions.h parameters.h scope_functions.h \
signal_functions.h
signal_functions.h commanalyzer_functions.h
subdir = src
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@ -159,7 +159,7 @@ PROGRAMS = $(bin_PROGRAMS)
am_main_server_lin_OBJECTS = gpib_functions.$(OBJEXT) \
main_server_lin.$(OBJEXT) scope_functions.$(OBJEXT) \
signal_functions.$(OBJEXT)
signal_functions.$(OBJEXT) commanalyzer_functions.$(OBJEXT)
main_server_lin_OBJECTS = $(am_main_server_lin_OBJECTS)
main_server_lin_LDADD = $(LDADD)
main_server_lin_DEPENDENCIES =
@ -170,7 +170,8 @@ am__depfiles_maybe = depfiles
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/gpib_functions.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/main_server_lin.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/scope_functions.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/signal_functions.Po
@AMDEP_TRUE@ ./$(DEPDIR)/signal_functions.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/commanalyzer_functions.Po
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
@ -236,6 +237,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main_server_lin.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scope_functions.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/signal_functions.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/commanalyzer_functions.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \

@ -0,0 +1,647 @@
/*
* Remote Laboratory Instrumentation Server
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (c) 2009 Timothy Pearson
* Raptor Engineering
* http://www.raptorengineeringinc.com
*/
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#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];
double commanalyzer_raw_trace_data[1024];
unsigned long commanalyzerTraceLength (char * commanalyzerType) {
if (strcmp("HP8924C", commanalyzerType) == 0) {
return 417;
}
else {
return 1;
}
}
int commanalyzer_set_date(struct tm * datetime, char * commanalyzerType, int gpibDevice) {
char datebuffer [80];
strftime(datebuffer,80,"CONF:DATE %m%d%y",datetime);
if (strcmp("HP8924C", commanalyzerType) == 0) {
printf("[INFO] Setting date on communications analyzer\n\r");
if (strcmp("HP8924C", commanalyzerType) == 0) {
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Writing: %s\n\r", datebuffer);
#endif
if (gpib_write(gpibDevice, datebuffer) == 0) {
return 0;
}
else {
return 2;
}
}
}
else {
return 1;
}
}
int commanalyzer_set_time(struct tm * datetime, char * commanalyzerType, int gpibDevice) {
char timebuffer [80];
strftime(timebuffer,80,"CONF:TIME +%H.%M",datetime); // FIXME wrong format
if (strcmp("HP8924C", commanalyzerType) == 0) {
printf("[INFO] Setting time on communications analyzer\n\r");
if (strcmp("HP8924C", commanalyzerType) == 0) {
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Writing: %s\n\r", timebuffer);
#endif
if (gpib_write(gpibDevice, timebuffer) == 0) {
return 0;
}
else {
return 2;
}
}
}
else {
return 1;
}
}
int commanalyzer_switch_to_spectrum_analyzer_mode(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) {
sprintf(falpha,"DISP SAN");
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Writing: %s\n\r", falpha);
#endif
if (gpib_write(gpibDevice, falpha) == 0) {
return 0;
}
else {
return 2;
}
}
}
else {
return 1;
}
}
int commanalyzer_lock_screen (char * commanalyzerType, int gpibDevice) {
if (strcmp("HP8924C", commanalyzerType) == 0) {
printf("[INFO] Locking communications analyzer screen\n\r");
if (strcmp("HP8924C", commanalyzerType) == 0) {
sprintf(falpha,"SPEC:DISP 'LOCKED'");
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Writing: %s\n\r", falpha);
#endif
if (gpib_write(gpibDevice, falpha) == 0) {
return 0;
}
else {
return 2;
}
}
}
else {
return 1;
}
}
int commanalyzer_spectrum_analyzer_set_generator_mode_tracking (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) {
sprintf(falpha,"SAN:RFG 'TRACK'");
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Writing: %s\n\r", falpha);
#endif
if (gpib_write(gpibDevice, falpha) == 0) {
return 0;
}
else {
return 2;
}
}
}
else {
return 1;
}
}
int commanalyzer_spectrum_analyzer_set_generator_mode_fixed (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) {
sprintf(falpha,"SAN:RFG 'FIXED'");
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Writing: %s\n\r", falpha);
#endif
if (gpib_write(gpibDevice, falpha) == 0) {
return 0;
}
else {
return 2;
}
}
}
else {
return 1;
}
}
int commanalyzer_spectrum_analyzer_set_rf_input_dedicated (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) {
sprintf(falpha,"SAN:INP 'ANT'");
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Writing: %s\n\r", falpha);
#endif
if (gpib_write(gpibDevice, falpha) == 0) {
return 0;
}
else {
return 2;
}
}
}
else {
return 1;
}
}
int commanalyzer_spectrum_analyzer_set_rf_input_muxed (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) {
sprintf(falpha,"SAN:INP 'RF IN'");
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Writing: %s\n\r", falpha);
#endif
if (gpib_write(gpibDevice, falpha) == 0) {
return 0;
}
else {
return 2;
}
}
}
else {
return 1;
}
}
int commanalyzer_spectrum_analyzer_set_generator_output_dedicated (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) {
sprintf(falpha,"SAN:TGEN:DEST 'DUPL'");
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Writing: %s\n\r", falpha);
#endif
if (gpib_write(gpibDevice, falpha) == 0) {
return 0;
}
else {
return 2;
}
}
}
else {
return 1;
}
}
int commanalyzer_spectrum_analyzer_set_generator_output_muxed (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) {
sprintf(falpha,"SAN:TGEN:DEST 'RF OUT'");
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Writing: %s\n\r", falpha);
#endif
if (gpib_write(gpibDevice, falpha) == 0) {
return 0;
}
else {
return 2;
}
}
}
else {
return 1;
}
}
int commanalyzer_get_spectrum_analyzer_trace(char * commanalyzerType, int gpibDevice) {
int max_num_bytes = 0;
unsigned char segarray[4194304];
unsigned 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");
if (strcmp("HP8924C", commanalyzerType) == 0) {
sprintf(falpha,"MEAS:SAN:TRACE?");
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Writing: %s\n\r", falpha);
#endif
if (gpib_write(gpibDevice, falpha) == 0) {
max_num_bytes = (commanalyzerTraceLength(commanalyzerType)*24); // Request more bytes than are possible to ensure no bytes are left behind
}
else {
return 2;
}
}
// Read response
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Trying to read %i bytes from GPIB device...\n", max_num_bytes);
#endif
ibtmo(gpibDevice, T30s);
ibeos(gpibDevice, 0x0);
ai = gpib_read_array(gpibDevice, max_num_bytes, segarray);
if (ai == -1) {
return 1;
}
else {
if (strcmp("HP8924C", commanalyzerType) == 0) {
left_char = 0;
right_char = 0;
array_pointer = 0;
while (left_char < ai) {
for (right_char=left_char;right_char<ai;right_char++) {
if (segarray[right_char] == ',') {
break;
}
}
strncpy(floatstring, segarray+left_char, right_char-left_char);
floatstring[right_char-left_char] = 0;
commanalyzer_raw_trace_data[array_pointer] = atof(floatstring);
array_pointer++;
left_char = right_char+1;
}
}
else {
return 2;
}
}
ibtmo(gpibDevice, T10s);
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Read %li bytes from GPIB device\n", array_pointer);
#endif
return 0;
}
}
int commanalyzer_set_spectrum_analyzer_center_frequency(float desired_frequency, 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) {
sprintf(falpha,"SAN:CFR %E", desired_frequency);
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Writing: %s\n\r", falpha);
#endif
if (gpib_write(gpibDevice, falpha) == 0) {
return 0;
}
else {
return 2;
}
}
}
else {
return 1;
}
}
int commanalyzer_set_spectrum_analyzer_frequency_span(float desired_frequency, 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) {
sprintf(falpha,"SAN:SPAN %E", desired_frequency);
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Writing: %s\n\r", falpha);
#endif
if (gpib_write(gpibDevice, falpha) == 0) {
return 0;
}
else {
return 2;
}
}
}
else {
return 1;
}
}
int commanalyzer_set_spectrum_analyzer_input_attenuation(float desired_attenuation, char * commanalyzerType, int gpibDevice) {
int instrument_att;
if ((strcmp("HP8924C", commanalyzerType) == 0)) {
if (strcmp("HP8924C", commanalyzerType) == 0) {
// Only three attenuation values are valid
if (desired_attenuation < 10) {
instrument_att = 0;
}
else if (desired_attenuation < 30) {
instrument_att = 20;
}
else {
instrument_att = 40;
}
}
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);
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Writing: %s\n\r", falpha);
#endif
if (gpib_write(gpibDevice, falpha) == 0) {
return 0;
}
else {
return 2;
}
}
}
else {
return 1;
}
}
int commanalyzer_set_spectrum_analyzer_scale(float desired_scale, char * commanalyzerType, int gpibDevice) {
int instrument_scale;
if ((strcmp("HP8924C", commanalyzerType) == 0)) {
if (strcmp("HP8924C", commanalyzerType) == 0) {
// Only three scale values are valid
if (desired_scale < 1.5) {
instrument_scale = 1;
}
else if (desired_scale < 6) {
instrument_scale = 2;
}
else {
instrument_scale = 10;
}
}
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);
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Writing: %s\n\r", falpha);
#endif
if (gpib_write(gpibDevice, falpha) == 0) {
return 0;
}
else {
return 2;
}
}
}
else {
return 1;
}
}
int commanalyzer_set_spectrum_analyzer_input_attenuator_mode_auto( 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) {
sprintf(falpha,"SAN:ATT:MODE 'AUTO'");
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Writing: %s\n\r", falpha);
#endif
if (gpib_write(gpibDevice, falpha) == 0) {
return 0;
}
else {
return 2;
}
}
}
else {
return 1;
}
}
int commanalyzer_set_spectrum_analyzer_input_attenuator_mode_fixed( 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) {
sprintf(falpha,"SAN:ATT:MODE 'HOLD'");
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Writing: %s\n\r", falpha);
#endif
if (gpib_write(gpibDevice, falpha) == 0) {
return 0;
}
else {
return 2;
}
}
}
else {
return 1;
}
}
int commanalyzer_set_spectrum_analyzer_generator_power(float desired_power, 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) {
sprintf(falpha,"SAN:TGEN:AMPL %E", desired_power);
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Writing: %s\n\r", falpha);
#endif
if (gpib_write(gpibDevice, falpha) == 0) {
return 0;
}
else {
return 2;
}
}
}
else {
return 1;
}
}
int commanalyzer_set_spectrum_analyzer_generator_frequency(float desired_frequency, 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) {
sprintf(falpha,"SAN:TGEN:OFR %E", desired_frequency);
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Writing: %s\n\r", falpha);
#endif
if (gpib_write(gpibDevice, falpha) == 0) {
return 0;
}
else {
return 2;
}
}
}
else {
return 1;
}
}
int commanalyzer_spectrum_analyzer_set_generator_sweep_ascending (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) {
sprintf(falpha,"SAN:TGEN:SWE 'NORM'");
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Writing: %s\n\r", falpha);
#endif
if (gpib_write(gpibDevice, falpha) == 0) {
return 0;
}
else {
return 2;
}
}
}
else {
return 1;
}
}
int commanalyzer_spectrum_analyzer_set_generator_sweep_descending (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) {
sprintf(falpha,"SAN:TGEN:SWE 'INVERT'");
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Writing: %s\n\r", falpha);
#endif
if (gpib_write(gpibDevice, falpha) == 0) {
return 0;
}
else {
return 2;
}
}
}
else {
return 1;
}
}
int commanalyzer_set_spectrum_analyzer_trace_averaging(float desired_avg_samples, char * commanalyzerType, int gpibDevice) {
if ((strcmp("HP8924C", commanalyzerType) == 0)) {
int instrument_samples;
if (strcmp("HP8924C", commanalyzerType) == 0) {
// Only certain values are valid, and I am interpreting 0 as no pk/avg and -1 as peak hold
instrument_samples = desired_avg_samples;
if (desired_avg_samples > 5) {
if (desired_avg_samples < 5) {
instrument_samples = desired_avg_samples;
}
else if (desired_avg_samples < 7) {
instrument_samples = 5;
}
else if (desired_avg_samples < 15) {
instrument_samples = 10;
}
else if (desired_avg_samples < 35) {
instrument_samples = 20;
}
else if (desired_avg_samples < 75) {
instrument_samples = 50;
}
else {
instrument_samples = 100;
}
}
}
printf("[INFO] Setting spectrum analyzer generator trace averaging to %d\n\r", instrument_samples);
if (strcmp("HP8924C", commanalyzerType) == 0) {
if (instrument_samples > 0) {
sprintf(falpha,"SAN:TRAC:MHOL 'AVG %d'", instrument_samples);
}
else if (instrument_samples == -1) {
sprintf(falpha,"SAN:TRAC:MHOL 'PK HOLD'");
}
else {
sprintf(falpha,"SAN:TRAC:MHOL 'NO PK/AVG'");
}
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Writing: %s\n\r", falpha);
#endif
if (gpib_write(gpibDevice, falpha) == 0) {
return 0;
}
else {
return 2;
}
}
}
else {
return 1;
}
}
int commanalyzer_set_spectrum_analyzer_reference_power_level(float desired_reflevel, 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) {
sprintf(falpha,"SAN:RLEV %E", desired_reflevel);
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Writing: %s\n\r", falpha);
#endif
if (gpib_write(gpibDevice, falpha) == 0) {
return 0;
}
else {
return 2;
}
}
}
else {
return 1;
}
}

@ -0,0 +1,49 @@
/*
* Remote Laboratory Instrumentation Server
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (c) 2009 Timothy Pearson
* Raptor Engineering
* http://www.raptorengineeringinc.com
*/
extern double commanalyzer_raw_trace_data[1024];
unsigned long commanalyzerTraceLength (char * commanalyzerType);
int commanalyzer_set_date(struct tm * datetime, char * commanalyzerType, int gpibDevice);
int commanalyzer_set_time(struct tm * datetime, char * commanalyzerType, int gpibDevice);
int commanalyzer_switch_to_spectrum_analyzer_mode (char * commanalyzerType, int gpibDevice);
int commanalyzer_lock_screen (char * commanalyzerType, int gpibDevice);
int commanalyzer_get_spectrum_analyzer_trace (char * commanalyzerType, int gpibDevice);
int commanalyzer_set_spectrum_analyzer_center_frequency(float desired_frequency, char * commanalyzerType, int gpibDevice);
int commanalyzer_set_spectrum_analyzer_frequency_span(float desired_frequency, char * commanalyzerType, int gpibDevice);
int commanalyzer_spectrum_analyzer_set_generator_mode_tracking (char * commanalyzerType, int gpibDevice);
int commanalyzer_spectrum_analyzer_set_generator_mode_fixed (char * commanalyzerType, int gpibDevice);
int commanalyzer_spectrum_analyzer_set_rf_input_dedicated (char * commanalyzerType, int gpibDevice);
int commanalyzer_spectrum_analyzer_set_rf_input_muxed (char * commanalyzerType, int gpibDevice);
int commanalyzer_spectrum_analyzer_set_generator_output_dedicated (char * commanalyzerType, int gpibDevice);
int commanalyzer_spectrum_analyzer_set_generator_output_muxed (char * commanalyzerType, int gpibDevice);
int commanalyzer_set_spectrum_analyzer_input_attenuation(float desired_attenuation, char * commanalyzerType, int gpibDevice);
int commanalyzer_set_spectrum_analyzer_scale(float desired_scale, char * commanalyzerType, int gpibDevice);
int commanalyzer_set_spectrum_analyzer_input_attenuator_mode_auto( char * commanalyzerType, int gpibDevice);
int commanalyzer_set_spectrum_analyzer_input_attenuator_mode_fixed( char * commanalyzerType, int gpibDevice);
int commanalyzer_set_spectrum_analyzer_generator_power(float desired_power, char * commanalyzerType, int gpibDevice);
int commanalyzer_set_spectrum_analyzer_generator_frequency(float desired_frequency, char * commanalyzerType, int gpibDevice);
int commanalyzer_spectrum_analyzer_set_generator_sweep_ascending (char * commanalyzerType, int gpibDevice);
int commanalyzer_spectrum_analyzer_set_generator_sweep_descending (char * commanalyzerType, int gpibDevice);
int commanalyzer_set_spectrum_analyzer_trace_averaging(float desired_avg_samples, char * commanalyzerType, int gpibDevice);
int commanalyzer_set_spectrum_analyzer_reference_power_level(float desired_reflevel, char * commanalyzerType, int gpibDevice);

@ -22,6 +22,7 @@
#include <stdio.h> /* perror() */
#include <stdlib.h> /* atoi() */
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h> /* read() */
@ -40,6 +41,7 @@
#include "parameters.h"
#include "scope_functions.h"
#include "signal_functions.h"
#include "commanalyzer_functions.h"
// Server variables
char *serverAddress;
@ -61,6 +63,13 @@ char *funcgenType;
char funcgenFound = 0;
int funcgen_board_device;
// Communications analyzer parameters
char *commanalyzerBoard;
char *commanalyzerDevice;
char *commanalyzerType;
char commanalyzerFound = 0;
int commanalyzer_board_device;
// Serial port parameters
char *serialDevice;
long serialBaud = 0;
@ -128,6 +137,14 @@ int m;
static const char filename[] = "remotefpga_gpib.conf";
char linedata [256];
// Shut up GCC
void quiet_write(int fd, const void *buf, size_t count) {
int retcode = write(fd, buf, count);
if (retcode < 0) {
printf("[WARN] Network error\n\r");
}
}
void getMyIP (void)
{
char Buf [256];
@ -255,6 +272,15 @@ char * scopeLongDescription (char * scopeType) {
}
}
char * commanalyzerLongDescription (char * scopeType) {
if (strcmp("HP8924C", commanalyzerType) == 0) {
return "Hewlett Packard 8924 series";
}
else {
return "UNKNOWN";
}
}
char * funcgenLongDescription (char * funcgenType) {
if (strcmp("AG33250A", funcgenType) == 0) {
return "Agilent AG33250A";
@ -285,7 +311,7 @@ int readConfig(void) {
if (strcmp(linedata, "9600") == 0) serialBaud = B9600;
if (strcmp(linedata, "115200") == 0) serialBaud = B115200;
//serialBaud = B9600;
printf("[INFO] Baud Rate: %s [%d]\n\r", linedata, serialBaud);
printf("[INFO] Baud Rate: %s [%ld]\n\r", linedata, serialBaud);
serialportDescription = strdup(linedata);
}
if (getConfig("SCOPE_BOARD:", line) == 0) {
@ -312,6 +338,18 @@ int readConfig(void) {
funcgenType = strdup(linedata);
funcgenFound++;
}
if (getConfig("COMMANALYZER_BOARD:", line) == 0) {
commanalyzerBoard = strdup(linedata);
commanalyzerFound++;
}
if (getConfig("COMMANALYZER_DEVICE:", line) == 0) {
commanalyzerDevice = strdup(linedata);
commanalyzerFound++;
}
if (getConfig("COMMANALYZER_TYPE:", line) == 0) {
commanalyzerType = strdup(linedata);
commanalyzerFound++;
}
}
fclose ( file );
if (scopeFound == 3) {
@ -357,6 +395,27 @@ int readConfig(void) {
}
}
}
if (commanalyzerFound == 3) {
printf("[INFO] Communications analyzer conjectured to be on GPIB address %s:%s\n\r", commanalyzerBoard, commanalyzerDevice);
commanalyzer_board_device = open_gpib_device(atoi(commanalyzerBoard), atoi(commanalyzerDevice));
if (commanalyzer_board_device < 0) {
//return 1;
}
else {
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
printf("[INFO] Configuring %s communications analyzer\n\r", commanalyzerLongDescription(commanalyzerType));
if (commanalyzer_set_time(timeinfo, commanalyzerType, commanalyzer_board_device) == 0) {
commanalyzer_set_date(timeinfo, commanalyzerType, commanalyzer_board_device);
printf("[INFO] Communication verified\n\r");
}
else {
printf("[WARN] Communication failed!\n\r");
}
}
}
}
else
{
@ -515,10 +574,10 @@ int mainserver(int fd) {
if (serialBaud != 0) {
if (setupSerial() != 0) {
printf("[FAIL] Cannot open serial port\n\r");
write(fd, "NCK\r", strlen("NCK\r"));
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
else {
write(fd, "ACK\r", strlen("ACK\r"));
quiet_write(fd, "ACK\r", strlen("ACK\r"));
main_server_state[fd] = 4;
server_fd_with_serial = fd;
printf("[INFO] Entering state 4 on server fd %d\n\r", fd);
@ -526,26 +585,26 @@ int mainserver(int fd) {
}
else {
printf("[FAIL] Serial port not set up!\n\r");
write(fd, "NCK\r", strlen("NCK\r"));
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
}
else if (readbuf[0] == 21) {
// Scope request
if (scope_board_device < 0) {
write(fd, "NCK\r", strlen("NCK\r"));
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
else {
if (strcmp("HP54600OS", scopeType) == 0) {
write(fd, "546\r", strlen("546\r"));
quiet_write(fd, "546\r", strlen("546\r"));
main_server_state[fd] = 5;
}
else if (strcmp("TDS744AOS", scopeType) == 0) {
write(fd, "744\r", strlen("744\r"));
quiet_write(fd, "744\r", strlen("744\r"));
main_server_state[fd] = 5;
}
else {
// Scope not recognized, apparently
write(fd, "NCK\r", strlen("NCK\r"));
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
printf("[INFO] Entering state %d on server fd %d\n\r", main_server_state[fd], fd);
}
@ -553,12 +612,12 @@ int mainserver(int fd) {
else if (readbuf[0] == 40) {
// Function generator request
if (funcgen_board_device < 0) {
write(fd, "NCK\r", strlen("NCK\r"));
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
else {
if (strcmp("AG33250A", funcgenType) == 0) {
//if (signal_reset(funcgenType, funcgen_board_device, errorbuf) == 0) {
write(fd, "ACK\r", strlen("ACK\r"));
quiet_write(fd, "ACK\r", strlen("ACK\r"));
main_server_state[fd] = 6;
//}
// Function generator seems to have failed
@ -566,7 +625,24 @@ int mainserver(int fd) {
}
else {
// Function generator not recognized, apparently
write(fd, "NCK\r", strlen("NCK\r"));
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
printf("[INFO] Entering state %d on server fd %d\n\r", main_server_state[fd], fd);
}
}
else if (readbuf[0] == 41) {
// Communications analyzer request
if (commanalyzer_board_device < 0) {
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
else {
if (strcmp("HP8924C", commanalyzerType) == 0) {
quiet_write(fd, "892\r", strlen("892\r"));
main_server_state[fd] = 7;
}
else {
// Communications analyzer not recognized, apparently
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
printf("[INFO] Entering state %d on server fd %d\n\r", main_server_state[fd], fd);
}
@ -577,7 +653,7 @@ int mainserver(int fd) {
case 4: // Process serial port transfers
cc = read(fd_tty, readbuf, 100000);
if (cc > 0) {
write(fd, readbuf, cc);
quiet_write(fd, readbuf, cc);
fsync(fd_tty);
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Got %d bytes from the serial port\n\r", cc);
@ -585,7 +661,7 @@ int mainserver(int fd) {
}
cc = read(fd, writebuf, 100000);
if (cc > 0) {
write(fd_tty, writebuf, cc);
quiet_write(fd_tty, writebuf, cc);
fsync(fd);
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Got %d bytes from the network interface\n\r", cc);
@ -601,14 +677,14 @@ int mainserver(int fd) {
printf("[DEBG] Got command %d on server fd %d\n\r", readbuf[0], fd);
#endif
if ((readbuf[0] == 20) || (readbuf[0] == 29)) { // Want scope screenshot!
write(fd, "ACK", strlen("ACK"));
quiet_write(fd, "ACK", strlen("ACK"));
fsync(fd);
if (scope_get_screenshot(scopeType, scope_board_device) == 0) {
sleep (5);
scope_board_device = open_gpib_device(atoi(scopeBoard), atoi(scopeDevice));
if (scope_get_screenshot_stage2(scopeType, scope_board_device) == 0) {
// Send the data, all of it!
write(fd, "ACK", strlen("ACK"));
quiet_write(fd, "ACK", strlen("ACK"));
bytestosend = scopeScreenSize(scopeType);
k=0;
@ -621,74 +697,74 @@ int mainserver(int fd) {
}
}
else {
write(fd, "NCK", strlen("NCK"));
quiet_write(fd, "NCK", strlen("NCK"));
}
}
else {
write(fd, "NCK", strlen("NCK"));
quiet_write(fd, "NCK", strlen("NCK"));
}
}
if (readbuf[0] == 22) { // Want to change horizontal timebase
buffer_lookfor_termdegree(readbuf, 25);
if (scope_set_timebase(atof(readbuf), scopeType, scope_board_device) == 0) {
write(fd, "ACK\r", strlen("ACK\r"));
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
write(fd, "NCK\r", strlen("NCK\r"));
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
}
if (readbuf[0] == 23) { // Want to change volts per division
buffer_lookfor_two_termdegree(readbuf, readbuf2, 25);
if (scope_set_volts_div(atoi(readbuf), atof(readbuf2), scopeType, scope_board_device) == 0) {
write(fd, "ACK\r", strlen("ACK\r"));
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
write(fd, "NCK\r", strlen("NCK\r"));
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
}
if (readbuf[0] == 24) { // Want to change run status
buffer_lookfor_termdegree(readbuf, 25);
if (scope_set_acquisition(atoi(readbuf), scopeType, scope_board_device) == 0) {
write(fd, "ACK\r", strlen("ACK\r"));
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
write(fd, "NCK\r", strlen("NCK\r"));
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
}
if (readbuf[0] == 25) { // Want to change channel enable
buffer_lookfor_two_termdegree(readbuf, readbuf2, 25);
if (scope_set_channel_state(atoi(readbuf), atoi(readbuf2), scopeType, scope_board_device) == 0) {
write(fd, "ACK\r", strlen("ACK\r"));
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
write(fd, "NCK\r", strlen("NCK\r"));
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
}
if (readbuf[0] == 26) { // Want to change trigger channel
buffer_lookfor_termdegree(readbuf, 25);
if (scope_set_trigger_channel(atoi(readbuf), scopeType, scope_board_device) == 0) {
write(fd, "ACK\r", strlen("ACK\r"));
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
write(fd, "NCK\r", strlen("NCK\r"));
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
}
if (readbuf[0] == 27) { // Want to change trigger level
buffer_lookfor_termdegree(readbuf, 25);
if (scope_set_trigger_level(atof(readbuf), scopeType, scope_board_device) == 0) {
write(fd, "ACK\r", strlen("ACK\r"));
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
write(fd, "NCK\r", strlen("NCK\r"));
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
}
if (readbuf[0] == 28) { // Want to change channel vertical position
buffer_lookfor_two_termdegree(readbuf, readbuf2, 25);
if (scope_set_channel_position(atoi(readbuf), atof(readbuf2), scopeType, scope_board_device) == 0) {
write(fd, "ACK\r", strlen("ACK\r"));
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
write(fd, "NCK\r", strlen("NCK\r"));
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
}
}
@ -702,82 +778,281 @@ int mainserver(int fd) {
#endif
if (readbuf[0] == 40) { // Want to reset function generator
if (signal_reset(funcgenType, funcgen_board_device, errorbuf) == 0) {
write(fd, "ACK\r", strlen("ACK\r"));
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
write(fd, errorbuf, strlen(errorbuf));
quiet_write(fd, errorbuf, strlen(errorbuf));
}
}
if (readbuf[0] == 41) { // Is function generator configured?
// If I'm in state 6 it had *better* be available!!!
write(fd, "ACK\r", strlen("ACK\r"));
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
if (readbuf[0] == 42) { // Want to change frequency
buffer_lookfor_termdegree(readbuf, 25);
if (signal_set_frequency(atof(readbuf), funcgenType, funcgen_board_device, errorbuf) == 0) {
write(fd, "ACK\r", strlen("ACK\r"));
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
write(fd, errorbuf, strlen(errorbuf));
quiet_write(fd, errorbuf, strlen(errorbuf));
}
}
if (readbuf[0] == 43) { // Want to change duty cycle
buffer_lookfor_termdegree(readbuf, 25);
if (signal_set_duty_cycle(atof(readbuf), funcgenType, funcgen_board_device, errorbuf) == 0) {
write(fd, "ACK\r", strlen("ACK\r"));
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
write(fd, errorbuf, strlen(errorbuf));
quiet_write(fd, errorbuf, strlen(errorbuf));
}
}
if (readbuf[0] == 44) { // Want to set square wave
if (signal_set_waveform("SQUARE", funcgenType, funcgen_board_device, errorbuf) == 0) {
write(fd, "ACK\r", strlen("ACK\r"));
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
write(fd, errorbuf, strlen(errorbuf));
quiet_write(fd, errorbuf, strlen(errorbuf));
}
}
if (readbuf[0] == 45) { // Want to set sine wave
if (signal_set_waveform("SINUSOID", funcgenType, funcgen_board_device, errorbuf) == 0) {
write(fd, "ACK\r", strlen("ACK\r"));
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
write(fd, errorbuf, strlen(errorbuf));
quiet_write(fd, errorbuf, strlen(errorbuf));
}
}
if (readbuf[0] == 46) { // Want to set triangle wave
if (signal_set_waveform("RAMP", funcgenType, funcgen_board_device, errorbuf) == 0) {
write(fd, "ACK\r", strlen("ACK\r"));
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
write(fd, errorbuf, strlen(errorbuf));
quiet_write(fd, errorbuf, strlen(errorbuf));
}
}
if (readbuf[0] == 47) { // Want to set noise wave
if (signal_set_waveform("NOISE", funcgenType, funcgen_board_device, errorbuf) == 0) {
write(fd, "ACK\r", strlen("ACK\r"));
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
write(fd, errorbuf, strlen(errorbuf));
quiet_write(fd, errorbuf, strlen(errorbuf));
}
}
if (readbuf[0] == 48) { // Want to change P-P voltage
buffer_lookfor_termdegree(readbuf, 25);
if (signal_set_peak_peak_voltage(atof(readbuf), funcgenType, funcgen_board_device, errorbuf) == 0) {
write(fd, "ACK\r", strlen("ACK\r"));
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
write(fd, errorbuf, strlen(errorbuf));
quiet_write(fd, errorbuf, strlen(errorbuf));
}
}
if (readbuf[0] == 49) { // Want to change offset voltage
buffer_lookfor_termdegree(readbuf, 25);
if (signal_set_offset_voltage(atof(readbuf), funcgenType, funcgen_board_device, errorbuf) == 0) {
write(fd, "ACK\r", strlen("ACK\r"));
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
quiet_write(fd, errorbuf, strlen(errorbuf));
}
}
}
break;
case 7: // Process communications analyzer interface commands
cc = read(fd, readbuf, 25);
if (cc > 0) {
// Got one!
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Got command %d on server fd %d\n\r", readbuf[0], fd);
#endif
if (readbuf[0] == 40) { // Want to set SA mode
if (commanalyzer_switch_to_spectrum_analyzer_mode(commanalyzerType, commanalyzer_board_device) == 0) {
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
}
if (readbuf[0] == 41) { // Is communications analyzer configured?
// If I'm in state 7 it had *better* be available!!!
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
if ((readbuf[0] == 42)) { // Want SA trace
quiet_write(fd, "ACK", strlen("ACK"));
fsync(fd);
if (commanalyzer_get_spectrum_analyzer_trace(commanalyzerType, commanalyzer_board_device) == 0) {
bytestosend = commanalyzerTraceLength(commanalyzerType)*sizeof(double);
k=0;
while (bytestosend > 0) {
return_status = write(fd, commanalyzer_raw_trace_data+k, 1);
if (return_status > 0) {
bytestosend = bytestosend - return_status;
k++;
}
}
}
else {
quiet_write(fd, "NCK", strlen("NCK"));
}
}
if (readbuf[0] == 43) { // Want to lock screen
if (commanalyzer_lock_screen(commanalyzerType, commanalyzer_board_device) == 0) {
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
}
if (readbuf[0] == 44) { // Want to set generator to tracking mode
if (commanalyzer_spectrum_analyzer_set_generator_mode_tracking(commanalyzerType, commanalyzer_board_device) == 0) {
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
}
if (readbuf[0] == 45) { // Want to set generator to fixed mode
if (commanalyzer_spectrum_analyzer_set_generator_mode_fixed(commanalyzerType, commanalyzer_board_device) == 0) {
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
}
if (readbuf[0] == 46) { // Want to change center frequency
buffer_lookfor_termdegree(readbuf, 25);
if (commanalyzer_set_spectrum_analyzer_center_frequency(atof(readbuf), commanalyzerType, commanalyzer_board_device) == 0) {
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
}
if (readbuf[0] == 47) { // Want to change frequency span
buffer_lookfor_termdegree(readbuf, 25);
if (commanalyzer_set_spectrum_analyzer_frequency_span(atof(readbuf), commanalyzerType, commanalyzer_board_device) == 0) {
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
}
if (readbuf[0] == 48) { // Want to set RF input to dedicated connector
if (commanalyzer_spectrum_analyzer_set_rf_input_dedicated(commanalyzerType, commanalyzer_board_device) == 0) {
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
}
if (readbuf[0] == 49) { // Want to set RF input to multiplexed connector
if (commanalyzer_spectrum_analyzer_set_rf_input_muxed(commanalyzerType, commanalyzer_board_device) == 0) {
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
}
if (readbuf[0] == 50) { // Want to set generator output to dedicated connector
if (commanalyzer_spectrum_analyzer_set_generator_output_dedicated(commanalyzerType, commanalyzer_board_device) == 0) {
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
}
if (readbuf[0] == 51) { // Want to set generator output to multiplexed connector
if (commanalyzer_spectrum_analyzer_set_generator_output_muxed(commanalyzerType, commanalyzer_board_device) == 0) {
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
}
if (readbuf[0] == 52) { // Want to change input attenuation
buffer_lookfor_termdegree(readbuf, 25);
if (commanalyzer_set_spectrum_analyzer_input_attenuation(atof(readbuf), commanalyzerType, commanalyzer_board_device) == 0) {
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
}
if (readbuf[0] == 53) { // Want to change scale
buffer_lookfor_termdegree(readbuf, 25);
if (commanalyzer_set_spectrum_analyzer_scale(atof(readbuf), commanalyzerType, commanalyzer_board_device) == 0) {
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
}
if (readbuf[0] == 54) { // Want to set RF input attenuator mode to automatic
if (commanalyzer_set_spectrum_analyzer_input_attenuator_mode_auto(commanalyzerType, commanalyzer_board_device) == 0) {
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
}
if (readbuf[0] == 55) { // Want to set RF input attenuator mode to fixed
if (commanalyzer_set_spectrum_analyzer_input_attenuator_mode_fixed(commanalyzerType, commanalyzer_board_device) == 0) {
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
}
if (readbuf[0] == 56) { // Want to change generator output power
buffer_lookfor_termdegree(readbuf, 25);
if (commanalyzer_set_spectrum_analyzer_generator_power(atof(readbuf), commanalyzerType, commanalyzer_board_device) == 0) {
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
write(fd, errorbuf, strlen(errorbuf));
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
}
if (readbuf[0] == 57) { // Want to change generator output frequency
buffer_lookfor_termdegree(readbuf, 25);
if (commanalyzer_set_spectrum_analyzer_generator_frequency(atof(readbuf), commanalyzerType, commanalyzer_board_device) == 0) {
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
}
if (readbuf[0] == 58) { // Want to set generator sweep to ascending
if (commanalyzer_spectrum_analyzer_set_generator_sweep_ascending(commanalyzerType, commanalyzer_board_device) == 0) {
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
}
if (readbuf[0] == 59) { // Want to set generator sweep to descending
if (commanalyzer_spectrum_analyzer_set_generator_sweep_descending(commanalyzerType, commanalyzer_board_device) == 0) {
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
}
if (readbuf[0] == 60) { // Want to set trace averaging
buffer_lookfor_termdegree(readbuf, 25);
if (commanalyzer_set_spectrum_analyzer_trace_averaging(atof(readbuf), commanalyzerType, commanalyzer_board_device) == 0) {
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
}
if (readbuf[0] == 61) { // Want to set reference power level
buffer_lookfor_termdegree(readbuf, 25);
if (commanalyzer_set_spectrum_analyzer_reference_power_level(atof(readbuf), commanalyzerType, commanalyzer_board_device) == 0) {
quiet_write(fd, "ACK\r", strlen("ACK\r"));
}
else {
quiet_write(fd, "NCK\r", strlen("NCK\r"));
}
}
}
@ -829,6 +1104,7 @@ int main(int argc, char *argv[])
printf("RemoteFPGA GPIB Server v%s.%s%s\n\r", SERVER_MAJOR, SERVER_MINOR, SERVER_REVISION);
printf("(c) %s Timothy Pearson\n\r", COPYRIGHT_DATE);
printf("(c) %s Remote Laboratory FOSS Contributors\n\r", FOSS_COPYRIGHT_DATE);
getMyIP();
@ -887,21 +1163,25 @@ int main(int argc, char *argv[])
FD_SET(ssock_query, &afds_query);
if (strlen(gpibServerString) > 0) {
write(ssock_query, gpibServerString, strlen(gpibServerString));
write(ssock_query, "\r", strlen("\r"));
quiet_write(ssock_query, gpibServerString, strlen(gpibServerString));
quiet_write(ssock_query, "\r", strlen("\r"));
}
if (serialBaud != 0) {
write(ssock_query, "Auxiliary serial port: ", strlen("Auxiliary serial port: "));
write(ssock_query, serialportDescription, strlen(serialportDescription));
write(ssock_query, " baud\r", strlen(" baud\r"));
quiet_write(ssock_query, "Auxiliary serial port: ", strlen("Auxiliary serial port: "));
quiet_write(ssock_query, serialportDescription, strlen(serialportDescription));
quiet_write(ssock_query, " baud\r", strlen(" baud\r"));
}
if (scopeFound == 3) {
write(ssock_query, scopeLongDescription(scopeType), strlen(scopeLongDescription(scopeType)));
write(ssock_query, " oscilloscope\r", strlen(" oscilloscope\r"));
quiet_write(ssock_query, scopeLongDescription(scopeType), strlen(scopeLongDescription(scopeType)));
quiet_write(ssock_query, " oscilloscope\r", strlen(" oscilloscope\r"));
}
if (funcgenFound == 3) {
write(ssock_query, funcgenLongDescription(funcgenType), strlen(funcgenLongDescription(funcgenType)));
write(ssock_query, " signal generator\r", strlen(" signal generator\r"));
quiet_write(ssock_query, funcgenLongDescription(funcgenType), strlen(funcgenLongDescription(funcgenType)));
quiet_write(ssock_query, " signal generator\r", strlen(" signal generator\r"));
}
if (commanalyzerFound == 3) {
quiet_write(ssock_query, commanalyzerLongDescription(commanalyzerType), strlen(commanalyzerLongDescription(commanalyzerType)));
quiet_write(ssock_query, " communications analyzer\r", strlen(" communications analyzer\r"));
}
}
else {
@ -929,7 +1209,7 @@ int main(int argc, char *argv[])
optval = 4194304;
status = setsockopt(ssock_mainserver, SOL_SOCKET, SO_SNDBUF, &optval, sizeof(optval));
printf("[INFO] Socket send buffer size set to %d bytes\n", optval, status);
printf("[INFO] Socket send buffer size set to %ld bytes\n", optval, status);
if (ssock_mainserver >= 0) {
//printf("[INFO] Connection established with %s\n\r", &fsin_mainserver.sin_addr);

@ -21,7 +21,8 @@
*/
#define SERVER_MAJOR "1"
#define SERVER_MINOR "00"
#define SERVER_MINOR "01"
#define SERVER_REVISION "a"
#define COPYRIGHT_DATE "2009"
#define COPYRIGHT_DATE "2009-2012"
#define FOSS_COPYRIGHT_DATE "2009-2012"
#define ENABLE_EXTRA_DEBUGGING
Loading…
Cancel
Save