summaryrefslogtreecommitdiff
path: root/parser.c
diff options
context:
space:
mode:
authorroot <root@xena.domain.avtechpulse.com>2012-08-23 09:24:20 -0400
committerroot <root@xena.domain.avtechpulse.com>2012-08-23 09:24:20 -0400
commit8c3652a30c35847380e19397077e41362bdefcb6 (patch)
treeb59cacf814ba8d53284530a8107a0fca2320bbb2 /parser.c
parenta453d3b91e5d947f4706c2c355948eda7a8f15d2 (diff)
added most commands to the parser, with supporting global vars
Diffstat (limited to 'parser.c')
-rw-r--r--parser.c2687
1 files changed, 2677 insertions, 10 deletions
diff --git a/parser.c b/parser.c
index 299a4b1..e0499ad 100644
--- a/parser.c
+++ b/parser.c
@@ -12,6 +12,9 @@ END DESCRIPTION **********************************************************/
#include "parser.h"
#include "flash.h"
#include "nicutils.h"
+#include "version.h"
+#include "dummy_functions.h"
+#include "i2c.h"
#include <glib/gprintf.h>
//STATICS
@@ -38,7 +41,6 @@ static int Handle_Units(float *mult,char *units, char *base);
static int Is_Min_Command(char *text);
static int Is_Max_Command(char *text);
-static int Go_freq_32_33(gchar** response, int channel, char *parameter,char *units,int command_type);
static int Go_syst_err_11(gchar** response, int channel, char *parameter,char *units,int command_type);
static int Go_syst_errcnt66(gchar** response, int channel, char *parameter,char *units,int command_type);
static int Go_Str_eprom_47(gchar** response, int channel, char *loc_string,char *store_string,int command_type);
@@ -48,6 +50,71 @@ static int Go_char_eprom_70(gchar** response, int channel, char *loc_string,char
static int Go_eprom_siz_86(gchar** response, int channel, int command_type);
static int Go_sys_net_91(gchar** response, int channel, char *loc_string,char *store_string,int command_type);
+static int Go_ampl_26(gchar** response, int channel, char *parameter,char *units,int command_type,char *mode);
+static int Go_pw_36(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_duty_37(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_offset_29(gchar** response, int channel, char *parameter,char *units,int command_type,char *mode);
+static int Go_idn_5(gchar** response, int channel, char *loc_string,char *store_string,int command_type);
+static int Go_freq_32_33(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_period_35(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_delay_39(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_dbl_pulse_40(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_func_34(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_polarity_42(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_hold_38(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_output_55(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_trig_source46(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_gate_type_56(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_gate_level_67(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_delay_test58(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_wai_10(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_opc_5(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_ese_2(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_esr_3(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_cls_1(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_sre_7(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_stb_8(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_tst_9(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_syst_ver_12(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_event_13(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_oper_enable15(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_ques_enable18(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_preset_19(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_zout_20(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_prot_trip_21(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_gpib_addr_59(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_ser_baud_60(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_ser_par_61(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_ser_bits_62(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_ser_sbits_63(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_ser_rts_64(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_ser_echo_65(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_load_68(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_meas_ampl_69(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_rst_6(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_calib_amp_72(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_calib_mon_73(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_mon_step_74(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_outputtype_75(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_calib_os_76(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_calib_pw_77(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_routeclose_78(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Parse_chan_list(int channel,char *parameter,int *primary_selected, int *secondary_selected,gchar** response);
+static int Go_dly_shift_82(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_amp_pnt_83(gchar** response, int channel, char *parameter,char *units,int command_type,int cal_type);
+static int Go_puls_count_88(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_puls_sep_89(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_sys_pwd_92(gchar** response, int channel, char *parameter,int command_type);
+static int Go_eprom_sus_93(gchar** response, int channel, char *parameter,int command_type);
+static int Go_rise_time_94(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_rcl_53(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_sav_54(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_soft_current_limit_96(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_curr_slew_98(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_avrq_ampl(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_cal_100(gchar** response, int channel, char *parameter,char *units,int command_type);
+static int Go_cal_interval_101(gchar** response, int channel, char *parameter,char *units,int command_type);
+
static int Parser_id_word(char *id_me, int *channel, int *with_id_code)
{
int id_code;
@@ -730,13 +797,110 @@ void Parser_main (char *raw_in, int interactive_terminal, void(*cbfunc)(gpointer
case 0:
error_num=Unrecognized;
break;
+
+ case 1:
+ error_num=Go_cls_1(&response,channel,parameter,units,command_type);
+ break;
+ case 2:
+ error_num=Go_ese_2(&response,channel,parameter,units,command_type);
+ break;
+ case 3:
+ error_num=Go_esr_3(&response,channel,parameter,units,command_type);
+ break;
+ case 4:
+ error_num=Go_idn_5(&response,channel,parameter,units,command_type);
+ break;
+ case 5:
+ error_num=Go_opc_5(&response,channel,parameter,units,command_type);
+ break;
+ case 6:
+ error_num=Go_rst_6(&response,channel,parameter,units,command_type);
+ break;
+ case 7:
+ error_num=Go_sre_7(&response,channel,parameter,units,command_type);
+ break;
+ case 8:
+ error_num=Go_stb_8(&response,channel,parameter,units,command_type);
+ break;
+ case 9:
+ error_num=Go_tst_9(&response,channel,parameter,units,command_type);
+ break;
+ case 10:
+ error_num=Go_wai_10(&response,channel,parameter,units,command_type);
+ break;
case 11:
error_num=Go_syst_err_11(&response,channel,parameter,units,command_type);
break;
+ case 12:
+ error_num=Go_syst_ver_12(&response,channel,parameter,units,command_type);
+ break;
+ case 13:
+ case 14:
+ case 16:
+ case 17:
+ error_num=Go_event_13(&response,channel,parameter,units,command_type);
+ break;
+ case 15:
+ error_num=Go_oper_enable15(&response,channel,parameter,units,command_type);
+ break;
+ case 18:
+ error_num=Go_ques_enable18(&response,channel,parameter,units,command_type);
+ break;
+ case 19:
+ error_num=Go_preset_19(&response,channel,parameter,units,command_type);
+ break;
+ case 20:
+ error_num=Go_zout_20(&response,channel,parameter,units,command_type);
+ break;
+ case 21:
+ case 30:
+ case 31:
+ error_num=Go_prot_trip_21(&response,channel,parameter,units,command_type);
+ break;
+ case 22:
+ error_num=Go_ampl_26(&response,channel,parameter,units,command_type,"a");
+ break;
+ case 25:
+ error_num=Go_offset_29(&response,channel,parameter,units,command_type,"a");
+ break;
+ case 26:
+ error_num=Go_ampl_26(&response,channel,parameter,units,command_type,"v");
+ break;
+ case 29:
+ error_num=Go_offset_29(&response,channel,parameter,units,command_type,"v");
+ break;
case 32:
case 33:
error_num=Go_freq_32_33(&response,channel,parameter,units,command_type);
break;
+ case 34:
+ error_num=Go_func_34(&response,channel,parameter,units,command_type);
+ break;
+ case 35:
+ error_num=Go_period_35(&response,channel,parameter,units,command_type);
+ break;
+ case 36:
+ error_num=Go_pw_36(&response,channel,parameter,units,command_type);
+ break;
+ case 37:
+ error_num=Go_duty_37(&response,channel,parameter,units,command_type);
+ break;
+ case 38:
+ error_num=Go_hold_38(&response,channel,parameter,units,command_type);
+ break;
+ case 39:
+ case 41:
+ error_num=Go_delay_39(&response,channel,parameter,units,command_type);
+ break;
+ case 40:
+ error_num=Go_dbl_pulse_40(&response,channel,parameter,units,command_type);
+ break;
+ case 42:
+ error_num=Go_polarity_42(&response,channel,parameter,units,command_type);
+ break;
+ case 46:
+ error_num=Go_trig_source46(&response,channel,parameter,units,command_type);
+ break;
case 47:
error_num=Go_Str_eprom_47(&response,channel,parameter,units,command_type);
break;
@@ -746,21 +910,141 @@ void Parser_main (char *raw_in, int interactive_terminal, void(*cbfunc)(gpointer
case 51:
error_num=Go_Float_eprom51(&response,channel,parameter,units,command_type);
break;
-
+ case 53:
+ error_num=Go_rcl_53(&response,channel,parameter,units,command_type);
+ break;
+ case 54:
+ error_num=Go_sav_54(&response,channel,parameter,units,command_type);
+ break;
+ case 55:
+ error_num=Go_output_55(&response,channel,parameter,units,command_type);
+ break;
+ case 56:
+ error_num=Go_gate_type_56(&response,channel,parameter,units,command_type);
+ break;
+ case 58:
+ error_num=Go_delay_test58(&response,channel,parameter,units,command_type);
+ break;
+ case 59:
+ error_num=Go_gpib_addr_59(&response,channel,parameter,units,command_type);
+ break;
+ case 60:
+ error_num=Go_ser_baud_60(&response,channel,parameter,units,command_type);
+ break;
+ case 61:
+ error_num=Go_ser_par_61(&response,channel,parameter,units,command_type);
+ break;
+ case 62:
+ error_num=Go_ser_bits_62(&response,channel,parameter,units,command_type);
+ break;
+ case 63:
+ error_num=Go_ser_sbits_63(&response,channel,parameter,units,command_type);
+ break;
+ case 64:
+ error_num=Go_ser_rts_64(&response,channel,parameter,units,command_type);
+ break;
+ case 65:
+ error_num=Go_ser_echo_65(&response,channel,parameter,units,command_type);
+ break;
case 66:
error_num=Go_syst_errcnt66(&response,channel,parameter,units,command_type);
break;
+ case 67:
+ error_num=Go_gate_level_67(&response,channel,parameter,units,command_type);
+ break;
+ case 68:
+ error_num=Go_load_68(&response,channel,parameter,units,command_type);
+ break;
+ case 69:
+ error_num=Go_meas_ampl_69(&response,channel,parameter,units,command_type);
+ break;
case 70:
error_num=Go_char_eprom_70(&response,channel,parameter,units,command_type);
break;
-
+ case 72:
+ error_num=Go_calib_amp_72(&response,channel,parameter,units,command_type);
+ break;
+ case 73:
+ error_num=Go_calib_mon_73(&response,channel,parameter,units,command_type);
+ break;
+ case 74:
+ error_num=Go_mon_step_74(&response,channel,parameter,units,command_type);
+ break;
+ case 75:
+ error_num=Go_outputtype_75(&response,channel,parameter,units,command_type);
+ break;
+ case 76:
+ error_num=Go_calib_os_76(&response,channel,parameter,units,command_type);
+ break;
+ case 77:
+ error_num=Go_calib_pw_77(&response,channel,parameter,units,command_type);
+ break;
+ case 78:
+ error_num=Go_routeclose_78(&response,channel,parameter,units,command_type);
+ break;
+ case 79:
+ error_num=Go_amp_pnt_83(&response,channel,parameter,units,command_type,pwl_pw_values);
+ break;
+ case 80:
+ error_num=Go_amp_pnt_83(&response,channel,parameter,units,command_type,pwl_delay_values);
+ break;
+ case 81:
+ error_num=Go_amp_pnt_83(&response,channel,parameter,units,command_type,pwl_period_values);
+ break;
+ case 82:
+ error_num=Go_dly_shift_82(&response,channel,parameter,units,command_type);
+ break;
+ case 83:
+ error_num=Go_amp_pnt_83(&response,channel,parameter,units,command_type,pwl_ampl_values);
+ break;
+ case 84:
+ error_num=Go_amp_pnt_83(&response,channel,parameter,units,command_type,pwl_os_values);
+ break;
case 86:
error_num=Go_eprom_siz_86(&response,channel,command_type);
break;
-
+ case 88:
+ error_num=Go_puls_count_88(&response,channel,parameter,units,command_type);
+ break;
+ case 89:
+ error_num=Go_puls_sep_89(&response,channel,parameter,units,command_type);
+ break;
+ case 90:
+ error_num=Go_amp_pnt_83(&response,channel,parameter,units,command_type,pwl_burst_values);
+ break;
case 91:
error_num=Go_sys_net_91(&response,channel,parameter,units,command_type);
break;
+ case 92:
+ error_num=Go_sys_pwd_92(&response,channel,parameter,command_type);
+ break;
+ case 93:
+ error_num=Go_eprom_sus_93(&response,channel,parameter,command_type);
+ break;
+ case 94:
+ error_num=Go_rise_time_94(&response,channel,parameter,units,command_type);
+ break;
+ case 95:
+ error_num=Go_amp_pnt_83(&response,channel,parameter,units,command_type,pwl_rise_time_values);
+ break;
+ case 96:
+ error_num=Go_soft_current_limit_96(&response,channel,parameter,units,command_type);
+ break;
+ case 97:
+ error_num=Go_amp_pnt_83(&response,channel,parameter,units,command_type,pwl_load_type_values);
+ break;
+ case 98:
+ error_num=Go_curr_slew_98(&response,channel,parameter,units,command_type);
+ break;
+ case 99:
+ error_num=Go_amp_pnt_83(&response,channel,parameter,units,command_type,pwl_slew_values);
+ break;
+ case 100:
+ error_num=Go_cal_100(&response,channel,parameter,units,command_type);
+ break;
+ case 101:
+ error_num=Go_cal_interval_101(&response,channel,parameter,units,command_type);
+ break;
case 9999:
// was only whitespace, ignore
@@ -846,12 +1130,10 @@ static int Parser_channel (int *channel,int with_id_code,int routine_num)
static int Go_freq_32_33(gchar** response, int channel, char *parameter,char *units,int command_type)
{
- // this is a typical parser function - there will be many more added later
-
float new_freq;
int status;
- if ( (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_frequency))) {
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_frequency)) {
return status;
}
@@ -859,13 +1141,13 @@ static int Go_freq_32_33(gchar** response, int channel, char *parameter,char *un
switch (command_type) {
case command_param_units:
- if ( (status=Handle_Units(&new_freq,units,"hz")) ) {
+ if (status=Handle_Units(&new_freq,units,"hz")) {
return status;
}
/* no break */
case command_withparam:
- if ( (status = process_float_param (parameter, &new_freq, globals.Flash.min_freq[channel], globals.Flash.max_freq[channel], NORMAL_ZERO)) ) {
+ if (status = process_float_param (parameter, &new_freq, globals.Constraints.err_min_freq[channel], globals.Constraints.err_max_freq[channel], NORMAL_ZERO)) {
return status;
}
return Set_frequency(0,0,0,channel,new_freq);
@@ -876,7 +1158,7 @@ static int Go_freq_32_33(gchar** response, int channel, char *parameter,char *un
break;
case query_param:
- return query_min_max_float (response, parameter, globals.Flash.min_freq[channel], globals.Flash.max_freq[channel]);
+ return query_min_max_float (response, parameter, globals.Constraints.err_min_freq[channel], globals.Constraints.err_max_freq[channel]);
break;
default:
@@ -1360,3 +1642,2388 @@ static int Go_syst_errcnt66(gchar** response, int channel, char *parameter,char
}
}
+
+static int Go_ampl_26(gchar** response, int channel, char *parameter,char *units,int command_type,char *mode)
+{
+ float new_ampl;
+ int status;
+ int max_chan;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_amplitude)) {
+ return status;
+ }
+ if (!strcmp(mode,"v")) {
+ if (globals.Flash.enable_avrq_extra_ampls && channel > 1) {
+ return Go_avrq_ampl (response, channel, parameter, units, command_type);
+ }
+ if (!globals.Flash.voltage_enabled[channel]) {
+ return Unrecognized;
+ }
+ }
+ if (!strcmp(mode,"a") && !globals.Flash.current_enabled[channel]) {
+ return Unrecognized;
+ }
+
+ new_ampl=1.0;
+
+ switch (command_type) {
+ case command_param_units:
+ if (status=Handle_Units(&new_ampl,units,mode)) {
+ return status;
+ }
+ /* no break */
+
+ case command_withparam:
+ if (!strcmp(parameter,"ext") || !strcmp(parameter,"external")) {
+ return Set_EA(channel,amp_mode_ea);
+ } else if (!strcmp(parameter,"amp") || !strcmp(parameter,"amplify")) {
+ return Set_EA(channel,amp_mode_amplify);
+ } else if (status = process_float_param (parameter, &new_ampl, globals.Constraints.err_min_ampl[channel], globals.Constraints.err_max_ampl[channel], ALLOW_NEG_ZERO)) {
+ return status;
+ }
+
+ Set_EA(channel,amp_mode_normal);
+ return Set_Amplitude(0,0,0,0,0,0,channel,new_ampl,0);
+ break;
+
+ case query_simple:
+ if (globals.ChannelState[channel].amp_mode==amp_mode_ea) {
+ return query_string(response, "EXT");
+ } else if (globals.ChannelState[channel].amp_mode==amp_mode_amplify) {
+ return query_string(response, "AMP");
+ } else {
+ return query_float(response, globals.ChannelState[channel].amplitude);
+ }
+ break;
+
+ case query_param:
+ return query_min_max_float (response, parameter, globals.Constraints.err_min_ampl[channel], globals.Constraints.err_max_ampl[channel]);
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_pw_36(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ float new_pw;
+ int check_valid;
+ int status;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_pw)) {
+ return status;
+ }
+ if (globals.Flash.fixed_pw[channel]) {
+ return Unrecognized;
+ }
+
+ new_pw=1.0;
+
+ switch (command_type) {
+ case command_param_units:
+ if (status=Handle_Units(&new_pw,units,"s")) {
+ return status;
+ }
+ /* no break */
+
+ case command_withparam:
+ if (!strcmp(parameter,"in")) {
+ return Set_Pwmode(channel,pw_in_out);
+ } else if (status = process_float_param (parameter, &new_pw, globals.Constraints.err_min_pw[channel], globals.Constraints.err_max_pw[channel], NORMAL_ZERO)) {
+ return status;
+ }
+
+ if (status = Set_Pwmode(channel,pw_normal)) {
+ return status;
+ }
+ return Set_Pw(0,0,0,channel,new_pw,0);
+ break;
+
+ case query_simple:
+ if (globals.ChannelState[channel].ab_mode==pw_normal) {
+ return query_float(response, globals.ChannelState[channel].pw);
+ } else {
+ return query_string(response, "The output pulse width is equal to the input pulse width.");
+ }
+ break;
+
+ case query_param:
+ return query_min_max_float (response, parameter, globals.Constraints.err_min_pw[channel], globals.Constraints.err_max_pw[channel]);
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_duty_37(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ float new_duty;
+ int status;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_pw)) {
+ return status;
+ }
+ if (globals.ChannelState[channel].trigger_source!=source_internal) {
+ return DutyTriggerError;
+ }
+
+ new_duty=1.0;
+
+ switch (command_type) {
+ case command_param_units:
+ if (status=Handle_Units(&new_duty,units,"%")) {
+ return status;
+ }
+ /* no break */
+
+ case command_withparam:
+ if (status = process_float_param (parameter, &new_duty, globals.Constraints.err_min_pw[channel]*globals.ChannelState[channel].frequency*100, globals.Constraints.err_max_pw[channel]*globals.ChannelState[channel].frequency*100, NORMAL_ZERO)) {
+ return status;
+ }
+ return Set_Pw(0,0,0,channel,new_duty/(100*globals.ChannelState[channel].frequency),0);
+ break;
+
+ case query_simple:
+ return query_float(response, 100*globals.ChannelState[channel].pw*globals.ChannelState[channel].frequency);
+ break;
+
+ case query_param:
+ return query_min_max_float (response, parameter, globals.Constraints.err_min_pw[channel]*globals.ChannelState[channel].frequency*100, globals.Constraints.err_max_pw[channel]*globals.ChannelState[channel].frequency*100);
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+
+static int Go_offset_29(gchar** response, int channel, char *parameter,char *units,int command_type,char *mode)
+{
+ float new_offset;
+ int status;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_offset)) {
+ return status;
+ }
+ if (!strcmp(mode,"v") && !globals.Flash.voltage_offset_enabled[channel]) {
+ return Unrecognized;
+ }
+ if (!strcmp(mode,"a") && !globals.Flash.current_offset_enabled[channel]) {
+ return Unrecognized;
+ }
+
+ new_offset=1.0;
+
+ switch (command_type) {
+ case command_param_units:
+ if (status=Handle_Units(&new_offset,units,mode)) {
+ return status;
+ }
+ /* no break */
+
+ case command_withparam:
+ if (!strcmp(parameter,"ext") || !strcmp(parameter,"external")) {
+ return Set_EO(channel,os_mode_eo);
+ } else if (status = process_float_param (parameter, &new_offset, globals.Constraints.err_min_offset[channel], globals.Constraints.err_max_offset[channel], NORMAL_ZERO)) {
+ return status;
+ }
+
+ Set_EO(channel,os_mode_normal);
+ return Set_Offset(0,0,0,0,channel,new_offset);
+ break;
+
+ case query_simple:
+ if (globals.ChannelState[channel].os_mode) {
+ return query_string(response, "EXT");
+ } else {
+ return query_float(response, globals.ChannelState[channel].offset);
+ }
+ break;
+
+ case query_param:
+ return query_min_max_float (response, parameter, globals.Constraints.err_min_offset[channel], globals.Constraints.err_max_offset[channel]);
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_idn_5(gchar** response, int channel, char *loc_string,char *store_string,int command_type)
+{
+ /* *idn? - 5 */
+
+ switch (command_type) {
+ case query_simple:
+ idn_string(response);
+ return OK;
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_period_35(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ float new_period;
+ float min_period;
+ float max_period;
+ int status;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_frequency)) {
+ return status;
+ }
+
+ new_period=1.0;
+
+ switch (command_type) {
+ case command_param_units:
+ if (status=Handle_Units(&new_period,units,"s")) {
+ return status;
+ }
+ /* no break */
+
+ case command_withparam:
+ min_period = 1.0/globals.Constraints.err_max_freq[channel];
+
+ max_period = globals.Constraints.err_min_freq[channel];
+ if (max_period==0.0) {
+ return OutOfRange;
+ } else {
+ max_period = 1.0/max_period;
+ }
+
+ if (status = process_float_param (parameter, &new_period, min_period, max_period, NORMAL_ZERO)) {
+ return status;
+ }
+ return Set_frequency(0,0,0,channel,1.0/new_period);
+ break;
+
+ case query_simple:
+ return query_float(response, 1/globals.ChannelState[channel].frequency);
+ break;
+
+ case query_param:
+ return query_min_max_float (response, parameter, 1.0/globals.Constraints.err_max_freq[channel], 1.0/globals.Constraints.err_min_freq[channel]);
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_delay_39(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ float new_delay;
+ int status;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_delay)) {
+ return status;
+ }
+
+ new_delay=1.0;
+
+ switch (command_type) {
+ case command_param_units:
+ if (status=Handle_Units(&new_delay,units,"s")) {
+ return status;
+ }
+ /* no break */
+
+ case command_withparam:
+ if (status = process_float_param (parameter, &new_delay, globals.Constraints.err_min_delay[channel], globals.Constraints.err_max_delay[channel], NORMAL_ZERO)) {
+ return status;
+ }
+ return Set_Delay(0,0,0,channel,new_delay);
+ break;
+
+ case query_simple:
+ return query_float(response, globals.ChannelState[channel].delay);
+ break;
+
+ case query_param:
+ return query_min_max_float (response, parameter, globals.Constraints.err_min_delay[channel], globals.Constraints.err_max_delay[channel]);
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_dbl_pulse_40(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ int on_off, status;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_double_pulse)) {
+ return status;
+ }
+ if (!(globals.Flash.double_pulse_allowed[channel])) {
+ return Unrecognized;
+ }
+
+ switch (command_type) {
+ case command_withparam:
+ if (status=process_on_off (parameter, &on_off)) {
+ return status;
+ }
+ return Set_Double(channel,on_off);
+ break;
+
+ case query_simple:
+ return query_int (response, globals.ChannelState[channel].double_pulse);
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_func_34(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ int status;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_func_mode)) {
+ return status;
+ }
+
+ switch (command_type) {
+ case command_withparam:
+ if (!strcmp(parameter,"dc")) {
+ return Set_Func(channel,dc_mode_on);
+ } else if (!strcmp(parameter,"pulse") || !strcmp(parameter,"puls")) {
+ return Set_Func(channel,pulse_mode_on);
+ } else if (!strcmp(parameter,"sinusoid") || !strcmp(parameter,"sin") || !strcmp(parameter,"sine")) {
+ return Set_Func(channel,sin_mode_on);
+ } else if (!strcmp(parameter,"triangle") || !strcmp(parameter,"tri")) {
+ return Set_Func(channel,tri_mode_on);
+ } else if (!strcmp(parameter,"square") || !strcmp(parameter,"squ")) {
+ return Set_Func(channel,squ_mode_on);
+ } else if (!strcmp(parameter,"amplify") || !strcmp(parameter,"amp")) {
+ return Set_Func(channel,amp_mode_on);
+ } else {
+ return SyntaxError;
+ }
+ break;
+
+ case query_simple:
+ if (globals.ChannelState[channel].func_mode==dc_mode_on) {
+ return query_string(response, "DC");
+ } else if (globals.ChannelState[channel].func_mode==pulse_mode_on) {
+ return query_string(response, "PULSE");
+ } else if (globals.ChannelState[channel].func_mode==sin_mode_on) {
+ return query_string(response, "SIN");
+ } else if (globals.ChannelState[channel].func_mode==tri_mode_on) {
+ return query_string(response, "TRI");
+ } else if (globals.ChannelState[channel].func_mode==squ_mode_on) {
+ return query_string(response, "SQU");
+ } else if (globals.ChannelState[channel].func_mode==amp_mode_on) {
+ return query_string(response, "AMP");
+ }
+ return OK;
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_polarity_42(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ int status;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_polarity)) {
+ return status;
+ }
+ if (!(globals.Flash.invert_allowed[channel])) {
+ return Unrecognized;
+ }
+
+ switch (command_type) {
+ case command_withparam:
+ if (!strcmp(parameter,"norm") || !strcmp(parameter,"normal")) {
+ return Set_Pol(channel,pol_norm);
+ } else if (!strcmp(parameter,"comp") || !strcmp(parameter,"complement")
+ || !strcmp(parameter,"inv") || !strcmp(parameter,"inverted") )
+
+ {
+ return Set_Pol(channel,pol_complement);
+ } else {
+ return SyntaxError;
+ }
+ break;
+
+ case query_simple:
+ if (globals.ChannelState[channel].polarity==pol_norm) {
+ return query_string(response, "NORM");
+ } else {
+ return query_string(response, "COMP");
+ }
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_hold_38(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ int status;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_hold_setting)) {
+ return status;
+ }
+
+ switch (command_type) {
+ case command_withparam:
+ if (!strcmp(parameter,"widt") || !strcmp(parameter,"width")) {
+ Set_Hold(channel,hold_width);
+ return OK;
+ } else if (!strcmp(parameter,"dcyc") || !strcmp(parameter,"dcycle")) {
+ Set_Hold(channel,hold_duty);
+ return OK;
+ } else {
+ return SyntaxError;
+ }
+ break;
+
+ case query_simple:
+ if (globals.ChannelState[channel].hold_setting==hold_width) {
+ return query_string(response, "WIDT");
+ } else {
+ return query_string(response, "DCYC");
+ }
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_output_55(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ int on_off, status;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_output_state)) {
+ return status;
+ }
+ if(!globals.Flash.on_off_used) {
+ return Unrecognized;
+ }
+
+ switch (command_type) {
+ case command_withparam:
+ if (status=process_on_off (parameter, &on_off)) {
+ return status;
+ }
+ return Set_Output_State(channel,on_off);
+ break;
+
+ case query_simple:
+ return query_int (response, globals.ChannelState[channel].output_state);
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_trig_source46(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ int status;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_trigger_source)) {
+ return status;
+ }
+
+ if (globals.Flash.is_func_gen[channel]) {
+ return Unrecognized;
+ }
+
+ switch (command_type) {
+ case command_withparam:
+ if (!strcmp(parameter,"int") || !strcmp(parameter,"internal")) {
+ Set_Trig_Source(channel,source_internal);
+ } else if (!strcmp(parameter,"ext") || !strcmp(parameter,"external")) {
+ Set_Trig_Source(channel,source_external);
+ } else if (!strcmp(parameter,"man") || !strcmp(parameter,"manual")) {
+ Set_Trig_Source(channel,source_manual);
+ } else if (!strcmp(parameter,"hold")) {
+ Set_Trig_Source(channel,source_hold);
+ } else if (!strcmp(parameter,"imm") || !strcmp(parameter,"immediate")) {
+ Set_Trig_Source(channel,source_immediate);
+ } else {
+ return SyntaxError;
+ }
+ break;
+
+ case query_simple:
+ if (globals.ChannelState[channel].trigger_source==source_internal) {
+ return query_string(response, "INT");
+ } else if (globals.ChannelState[channel].trigger_source==source_external) {
+ return query_string(response, "EXT");
+ } else if (globals.ChannelState[channel].trigger_source==source_manual) {
+ return query_string(response, "MAN");
+ } else if (globals.ChannelState[channel].trigger_source==source_hold) {
+ return query_string(response, "HOLD");
+ } else if (globals.ChannelState[channel].trigger_source==source_immediate) {
+ return query_string(response, "IMM");
+ }
+ return OK;
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_gate_type_56(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ int status;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_gate_type)) {
+ return status;
+ }
+ if (globals.Flash.is_func_gen[channel]) {
+ return Unrecognized;
+ }
+
+ switch (command_type) {
+ case command_withparam:
+ if (!strcmp(parameter,"sync")) {
+ return Set_Gate_Sync(channel,gate_sync);
+ } else if (!strcmp(parameter,"async")) {
+ /* async mode doesn't work properly in dual-channel units */
+ if ( (globals.Flash.channels>1) || globals.Flash.sync_only) {
+ return AsyncModeDisabled;
+ }
+
+ return Set_Gate_Sync(channel,gate_async);
+ } else {
+ return SyntaxError;
+ }
+ break;
+
+ case query_simple:
+ if (globals.ChannelState[channel].gate_type==gate_sync) {
+ return query_string(response, "SYNC");
+ } else {
+ return query_string(response, "ASYNC");
+ }
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_gate_level_67(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ int status;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_gate_level)) {
+ return status;
+ }
+ if (globals.Flash.is_func_gen[channel]) {
+ return Unrecognized;
+ }
+
+ switch (command_type) {
+ case command_withparam:
+ if (!strcmp(parameter,"hi") || !strcmp(parameter,"high")) {
+ return Set_Gate_Level(channel,gate_high);
+ } else if (!strcmp(parameter,"low") || !strcmp(parameter,"lo")) {
+ return Set_Gate_Level(channel,gate_low);
+ } else {
+ return SyntaxError;
+ }
+ break;
+
+ case query_simple:
+ if (globals.ChannelState[channel].gate_level==gate_high) {
+ return query_string(response, "HI");
+ } else {
+ return query_string(response, "LO");
+ }
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_delay_test58(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ int on_off, status;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_delay)) {
+ return status;
+ }
+
+ switch (command_type) {
+ case command_withparam:
+ if (status=process_on_off (parameter, &on_off)) {
+ return status;
+ }
+ globals.ChannelState[channel].test_delay_mode=on_off;
+ return Set_Mux(channel);
+ break;
+
+ default:
+ return IllegalParameter;
+ break;
+ }
+}
+
+
+static int Go_wai_10(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ /* the *WAI command has no effect since all OP1B commands are non-overlapping */
+
+ switch (command_type) {
+ case command_simple:
+ return OK;
+ break;
+
+ default:
+
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_opc_5(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ /* the OPC commands automatically signal "operation complete" */
+ /* since all OP1B commands are non-overlapping */
+
+ switch (command_type) {
+ case command_simple:
+ GPIB_set_ESR(0x01,1);
+ return OK;
+ break;
+
+ case query_simple:
+ return query_int (response, 1);
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_ese_2(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ int value, status;
+
+ switch (command_type) {
+ case command_withparam:
+ if (status = process_int_range (parameter, &value, 0, 255)) {
+ return status;
+ }
+ GPIB_set_ESE(0xff,0);
+ GPIB_set_ESE(value,1);
+ return OK;
+ break;
+
+ case query_simple:
+ return query_int (response, GPIB_get_ESE());
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_esr_3(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ int orig_esr;
+
+ switch (command_type) {
+ case query_simple:
+ orig_esr = GPIB_get_ESR();
+ GPIB_clear_events();
+ return query_int (response, orig_esr);
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_cls_1(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ switch (command_type) {
+ case command_simple:
+ GPIB_clear_events();
+ globals.number_of_errors=0;
+ return OK;
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_sre_7(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ int value, status;
+
+ switch (command_type) {
+ case command_withparam:
+ if (status = process_int_range (parameter, &value, 0, 255)) {
+ return status;
+ }
+ GPIB_set_SRE(0xbf,0);
+ GPIB_set_SRE(value,1);
+ return OK;
+ break;
+
+ case query_simple:
+ return query_int (response, GPIB_get_SRE());
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_stb_8(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ switch (command_type) {
+ case query_simple:
+ return query_int (response, GPIB_get_STB());
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_tst_9(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ switch (command_type) {
+ case query_simple:
+ return query_int (response, 0);
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_syst_ver_12(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ switch (command_type) {
+ case query_simple:
+ return query_string(response, SCPI_version);
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_event_13(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ switch (command_type) {
+ case query_simple:
+ return query_int (response, 0);
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_oper_enable15(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ int value, status;
+
+ switch (command_type) {
+ case command_withparam:
+ if (status = process_int_range (parameter, &value, 0, 255)) {
+ return status;
+ }
+ globals.oper_enable_register=value;
+ return OK;
+ break;
+
+ case query_simple:
+ return query_int (response, globals.oper_enable_register);
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_ques_enable18(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ int value, status;
+
+ switch (command_type) {
+ case command_withparam:
+ if (status = process_int_range (parameter, &value, 0, 255)) {
+ return status;
+ }
+ globals.ques_enable_register=value;
+ return OK;
+ break;
+
+ case query_simple:
+ return query_int (response, globals.ques_enable_register);
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_preset_19(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ switch (command_type) {
+ case command_simple:
+ globals.oper_enable_register=0;
+ globals.ques_enable_register=0;
+ return OK;
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_zout_20(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ int value, status;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_zout)) {
+ return status;
+ }
+ if (!globals.Flash.switchable_zout[channel] || globals.Flash.volt_ctrl_pw[channel]) {
+ return Unrecognized;
+ }
+
+ switch (command_type) {
+ case command_param_units:
+ // non-std unit handling, because zout is an integer, not a float
+ if (strcmp(units,"ohm")) {
+ return UnknownUnits;
+ }
+ /* no break */
+
+ case command_withparam:
+ if (status=process_two_ints (parameter, &value, globals.Flash.zout_min[channel], globals.Flash.zout_max[channel])) {
+ return status;
+ }
+ return Set_zout(channel,value,1);
+ break;
+
+ case query_simple:
+ return query_int (response, globals.ChannelState[channel].zout);
+ break;
+
+ case query_param:
+ return query_min_max_int(response, parameter, globals.Flash.zout_min[channel], globals.Flash.zout_max[channel]);
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_prot_trip_21(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ switch (command_type) {
+ case query_simple:
+ if (I2C_Read(PCF8574A+Button_Press_Port) & Overload_Input) {
+ return query_int (response, 0); /* overload not tripped */
+ } else {
+ return query_int (response, 1); /* overload tripped */
+ }
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_gpib_addr_59(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ int value, status;
+
+ switch (command_type) {
+ case command_withparam:
+ if (status = process_int_range (parameter, &value, 0, 30)) {
+ return status;
+ }
+ GPIB_change_address(value);
+ return OK;
+ break;
+
+ case query_simple:
+ return query_int (response, globals.GPIB.PRIMARY_ADDRESS);
+ break;
+
+ case query_param:
+ return query_min_max_int (response, parameter, 0, 30);
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_ser_baud_60(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ int value, status;
+
+ switch (command_type) {
+ case command_withparam:
+ if (status=process_four_ints (parameter, &value, 1200, 2400, 4800, 9600)) {
+ return status;
+ }
+
+ if (value==1200) {
+ globals.RS232.baud = rs232_1200_baud;
+ } else if (value==2400) {
+ globals.RS232.baud = rs232_2400_baud;
+ } else if (value==4800) {
+ globals.RS232.baud = rs232_4800_baud;
+ } else {
+ globals.RS232.baud = rs232_9600_baud;
+ }
+
+ IO_Setup_RS232();
+
+ return OK;
+ break;
+
+ case query_simple:
+ if (globals.RS232.baud==rs232_1200_baud) {
+ value=1200;
+ } else if (globals.RS232.baud==rs232_2400_baud) {
+ value=2400;
+ } else if (globals.RS232.baud==rs232_4800_baud) {
+ value=4800;
+ } else if (globals.RS232.baud==rs232_9600_baud) {
+ value=9600;
+ }
+
+ return query_int (response, value);
+ break;
+
+ case query_param:
+ return query_min_max_int (response, parameter, 1200, 9600);
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_ser_par_61(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ switch (command_type) {
+ case command_withparam:
+ if (!strcmp(parameter,"even")) {
+ globals.RS232.parity = rs232_parity_even;
+ } else if (!strcmp(parameter,"odd")) {
+ globals.RS232.parity = rs232_parity_odd;
+ } else if (!strcmp(parameter,"none")) {
+ globals.RS232.parity = rs232_parity_none;
+ } else {
+ return IllegalParameter;
+ }
+
+ IO_Setup_RS232();
+
+ return OK;
+ break;
+
+ case query_simple:
+ if (globals.RS232.parity==rs232_parity_even) {
+ return query_string(response, "EVEN");
+ } else if (globals.RS232.parity==rs232_parity_odd) {
+ return query_string(response, "ODD");
+ } else if (globals.RS232.parity==rs232_parity_none) {
+ return query_string(response, "NONE");
+ }
+ return OK;
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_ser_bits_62(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ int value, status;
+
+ switch (command_type) {
+ case command_withparam:
+ if (status=process_two_ints (parameter, &value, 7, 8)) {
+ return status;
+ }
+
+ if (value==7) {
+ globals.RS232.databits = rs232_7data_bits;
+ } else {
+ globals.RS232.databits = rs232_8data_bits;
+ }
+
+ IO_Setup_RS232();
+
+ return OK;
+ break;
+
+ case query_simple:
+ if (globals.RS232.databits==rs232_7data_bits) {
+ value=7;
+ } else if (globals.RS232.databits==rs232_8data_bits) {
+ value=8;
+ }
+
+ return query_int (response, value);
+ break;
+
+ case query_param:
+ return query_min_max_int (response, parameter, 7, 8);
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_ser_sbits_63(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ int value, status;
+
+ switch (command_type) {
+ case command_withparam:
+ if (status=process_two_ints (parameter, &value, 1, 2)) {
+ return status;
+ }
+
+ if (value==1) {
+ globals.RS232.stopbits = rs232_1stop_bit;
+ } else {
+ globals.RS232.stopbits = rs232_2stop_bits;
+ }
+
+ IO_Setup_RS232();
+
+ return OK;
+ break;
+
+ case query_simple:
+ if (globals.RS232.stopbits==rs232_1stop_bit) {
+ value=1;
+ } else if (globals.RS232.stopbits==rs232_2stop_bits) {
+ value=2;
+ }
+
+ return query_int (response, value);
+ break;
+
+ case query_param:
+ return query_min_max_int (response, parameter, 1, 2);
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_ser_rts_64(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ switch (command_type) {
+ case command_withparam:
+ if (!strcmp(parameter,"rfr") || !strcmp(parameter,"ibf")
+ || !strcmp(parameter,"ibfull")) {
+ globals.RS232.hardhand = rs232_hard_on;
+ } else if (!strcmp(parameter,"on")) {
+ globals.RS232.hardhand = rs232_hard_off;
+ } else {
+ return IllegalParameter;
+ }
+
+ IO_Setup_RS232();
+
+ return OK;
+ break;
+
+ case query_simple:
+ if (globals.RS232.hardhand==rs232_hard_on) {
+ return query_string(response, "IBF");
+ } else if (globals.RS232.hardhand==rs232_hard_off) {
+ return query_string(response, "ON");
+ }
+ return OK;
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_ser_echo_65(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ int on_off, status;
+
+ switch (command_type) {
+ case command_withparam:
+ if (status=process_on_off (parameter, &on_off)) {
+ return status;
+ }
+
+ if (on_off) {
+ globals.RS232.echo = rs232_echo_on;
+ } else {
+ globals.RS232.echo = rs232_echo_off;
+ }
+
+ return OK;
+ break;
+
+ case query_simple:
+ if (globals.RS232.echo==rs232_echo_on) {
+ return query_int (response, 1);
+ } else if (globals.RS232.echo==rs232_echo_off) {
+ return query_int (response, 0);
+ }
+ return OK;
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_load_68(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ float new_load_type;
+ int status;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_load_type)) {
+ return status;
+ }
+ if (!globals.Flash.switchable_load[channel]) {
+ return Unrecognized;
+ }
+
+ new_load_type=1.0;
+
+ switch (command_type) {
+ case command_param_units:
+ if (status=Handle_Units(&new_load_type,units,"ohm")) {
+ return status;
+ }
+ /* no break */
+
+ case command_withparam:
+ if (status = process_float_param (parameter, &new_load_type, globals.Constraints.err_min_load_type[channel], globals.Constraints.err_max_load_type[channel], NORMAL_ZERO)) {
+ return status;
+ }
+ return Set_Load(channel,new_load_type);
+ break;
+
+ case query_simple:
+ return query_float(response, globals.ChannelState[channel].load_type);
+ break;
+
+ case query_param:
+ return query_min_max_float (response, parameter, globals.Constraints.err_min_load_type[channel], globals.Constraints.err_max_load_type[channel]);
+ break;
+
+ default:
+
+ return SyntaxError;
+ break;
+ }
+
+}
+
+
+static int Go_meas_ampl_69(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ int i, status;
+ float meas_ampl;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_amplitude)) {
+ return status;
+ }
+ if (!globals.Flash.monitor_enabled[channel]) {
+ return Unrecognized;
+ }
+
+ switch (command_type) {
+ case query_simple:
+ return query_float(response, globals.ChannelState[channel].Curr_Mon_value);
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_rst_6(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ switch (command_type) {
+ case command_simple:
+ Main_Rst();
+ return OK;
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_calib_amp_72(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ float cal_val;
+ int status;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_amplitude)) {
+ return status;
+ }
+ if (!globals.Flash.voltage_enabled[channel] && !globals.Flash.current_enabled[channel]) {
+ return Unrecognized;
+ }
+
+ cal_val=1.0;
+
+ switch (command_type) {
+ case command_param_units:
+ if (globals.Flash.current_enabled[channel]) {
+ if (status=Handle_Units(&cal_val,units,"a")) {
+ return status;
+ }
+ } else if (globals.Flash.voltage_enabled[channel]) {
+ if (status=Handle_Units(&cal_val,units,"v")) {
+ return status;
+ }
+ /* no break */
+ }
+
+ case command_withparam:
+ if (!String_is_it_numeric(parameter)) {
+ return SyntaxError;
+ }
+
+ Set_Amp_Calib(channel,atof(parameter)*cal_val);
+
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_calib_mon_73(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ float mon_val;
+ int status;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_amplitude)) {
+ return status;
+ }
+ if (!globals.Flash.monitor_enabled[channel]) {
+ return Unrecognized;
+ }
+
+ mon_val=1.0;
+
+ switch (command_type) {
+ case command_param_units:
+ if (status=Handle_Units(&mon_val,units,"a")) {
+ return status;
+ }
+
+ case command_withparam:
+ if (!String_is_it_numeric(parameter)) {
+ return SyntaxError;
+ }
+
+ Set_Mon_Calib(channel,atof(parameter)*mon_val);
+
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_mon_step_74(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ float mon_val;
+ float span , step_min, step_max;
+ int status;
+ int eprom_loc;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_amplitude)) {
+ return status;
+ }
+ if (!globals.Flash.monitor_enabled[channel]) {
+ return Unrecognized;
+ }
+
+ mon_val=1.0;
+
+ span = fabs(globals.Flash.max_ampl[channel]-globals.Flash.min_ampl[channel]);
+ if (globals.Flash.voltage_enabled[channel] || globals.Flash.current_enabled[channel]) {
+ step_min = span / 5000.0;
+ step_max = span / 5.0;
+ } else {
+ step_min = 0.0001;
+ step_max = 10.0;
+ }
+
+ switch (command_type) {
+ case command_param_units:
+ if (status=Handle_Units(&mon_val,units,"a")) {
+ return status;
+ }
+
+ case command_withparam:
+ if (status = process_float_param (parameter, &mon_val, step_min, step_max, NORMAL_ZERO)) {
+ return status;
+ }
+ mon_val=fabs(mon_val);
+
+ if ((mon_val < step_min) || (mon_val > step_max)) {
+ return OutOfRange;
+ }
+
+ globals.Flash.monitor_step[channel]=mon_val;
+ eprom_loc = (char *) &(globals.Flash.monitor_step) - (char *) &(globals.Flash.flash_start);
+ if (!globals.flash_writes_suspended) {
+ writeUserBlock(eprom_loc,&globals.Flash.flash_start + eprom_loc,sizeof(globals.Flash.monitor_step));
+ }
+
+ break;
+
+ case query_simple:
+ return query_float(response, globals.Flash.monitor_step[channel]);
+ break;
+
+ case query_param:
+ return query_min_max_float (response, parameter, step_min, step_max);
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_outputtype_75(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ int new_logic_level, status;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_logic_level)) {
+ return status;
+ }
+ if (!globals.Flash.logic_level_enabled) {
+ return Unrecognized;
+ }
+
+ switch (command_type) {
+ case command_withparam:
+ if (!strcmp(parameter,"ttl")) {
+ new_logic_level=logic_ttl;
+ } else if (!strcmp(parameter,"ecl")) {
+ new_logic_level=logic_ecl;
+ } else {
+ return SyntaxError;
+ }
+
+ return Set_Logic_Level(channel,new_logic_level);
+ break;
+
+ case query_simple:
+ if (globals.ChannelState[channel].logic_level==logic_ttl) {
+ return query_string(response, "TTL");
+ } else {
+ return query_string(response, "ECL");
+ }
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+
+static int Go_calib_os_76(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ float mon_val;
+ int status;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_offset)) {
+ return status;
+ }
+ if ( !globals.Flash.current_offset_enabled[channel] && !globals.Flash.voltage_offset_enabled[channel]) {
+ return Unrecognized;
+ }
+
+ mon_val=1.0;
+
+ switch (command_type) {
+ case command_param_units:
+ if (globals.Flash.current_offset_enabled[channel]) {
+ if (status=Handle_Units(&mon_val,units,"a")) {
+ return status;
+ }
+ } else {
+ if (status=Handle_Units(&mon_val,units,"v")) {
+ return status;
+ }
+ }
+
+ case command_withparam:
+ if (!String_is_it_numeric(parameter)) {
+ return SyntaxError;
+ }
+
+ Set_OS_Calib(channel,atof(parameter)*mon_val);
+
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_calib_pw_77(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ float pw_adjust;
+ int status;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_pw)) {
+ return status;
+ }
+
+ pw_adjust=1.0;
+
+ switch (command_type) {
+ case command_param_units:
+ if (status=Handle_Units(&pw_adjust,units,"s")) {
+ return status;
+ }
+ /* no break */
+
+ case command_withparam:
+ if (status = process_float_param (parameter, &pw_adjust, -1.0e-6, 1.0e-6, NORMAL_ZERO)) {
+ return status;
+ }
+ return Set_PW_shift(channel,pw_adjust);
+ break;
+
+ case query_simple:
+ return query_float(response, Get_PW_shift(channel));
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_routeclose_78(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ char channels_selected[max_channels+1];
+ int error_num;
+ int temp1, temp2, status;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_route)) {
+ return status;
+ }
+ if (!globals.Flash.routing_required[channel]) {
+ return Unrecognized;
+ }
+
+ temp1 = globals.ChannelState[channel].route_primary;
+ temp2 = globals.ChannelState[channel].route_secondary;
+
+ switch (command_type) {
+ case command_withparam:
+ if (error_num=Parse_chan_list(channel,
+ parameter,
+ &temp1,
+ &temp2,
+ NULL)) {
+ return error_num;
+ } else {
+ Set_Route(channel,ROUTE_PRIMARY,temp1);
+ Set_Route(channel,ROUTE_SECONDARY,temp2);
+ }
+ break;
+
+ case query_param:
+ if (error_num=Parse_chan_list(channel,
+ parameter,
+ &temp1,
+ &temp2,
+ response)) {
+ return error_num;
+ } else {
+ return OK;
+ }
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Parse_chan_list(int channel,char *parameter,int *primary_selected, int *secondary_selected,gchar** response)
+{
+ // FIXME with g_str functions
+ int i;
+ int n;
+ int m;
+ int pointer;
+ int count;
+ int has_module_name;
+ int *value_pointer;
+
+#define PARSE_MAX_STRING 20
+ char temp[PARSE_MAX_STRING+1];
+
+ count=0;
+
+ if (response) {
+ response[0]=0;
+ }
+
+ if ( !(parameter[0]=='(' && parameter[1]=='@')) {
+ return SyntaxError;
+ }
+
+ if (strchr (parameter, ':')) {
+ return Route_Range_Error;
+ }
+
+ if (strchr (parameter, '!')) {
+ return Route_Range_Error;
+ }
+
+ pointer=1;
+
+ do {
+ pointer++;
+ has_module_name = FALSE;
+
+ /* get module name, if any */
+ for (i=0; isalpha(parameter[pointer]) && (i<PARSE_MAX_STRING); i++) {
+ temp[i]=parameter[pointer];
+ pointer++;
+ }
+ temp[i]=0;
+
+ value_pointer = primary_selected;
+ if (i>0) {
+ has_module_name = TRUE;
+
+ if (!strcmp (temp, "anod")) {
+ value_pointer = primary_selected;
+ } else if (!strcmp (temp, "cath")) {
+ if (globals.Flash.routing_required[channel]<2) {
+ return IllegalParameter;
+ }
+ value_pointer = secondary_selected;
+ } else {
+ return IllegalParameter;
+ }
+
+ if (parameter[pointer] == '(' ) {
+ pointer++;
+ } else {
+ return SyntaxError;
+ }
+ }
+
+ /* get digits */
+ for (i=0; isdigit(parameter[pointer]) && (i<PARSE_MAX_STRING); i++) {
+ temp[i]=parameter[pointer];
+ pointer++;
+ }
+ temp[i]=0;
+
+ if (i==0) {
+ return SyntaxError;
+ }
+
+ n = atoi(temp);
+ if ((n < 1) || (n > globals.Flash.routing_max_pins[channel])) {
+ return OutOfRange;
+ }
+
+ if (has_module_name) {
+ if (parameter[pointer] == ')' ) {
+ pointer++;
+ } else {
+ return SyntaxError;
+ }
+ }
+
+ /* query or command? */
+ if (response) {
+ if (*value_pointer == n) {
+ strcat(response,"1 ");
+ } else {
+ strcat(response,"0 ");
+ }
+ } else {
+ if (value_pointer) {
+ *value_pointer=n;
+ }
+ }
+
+
+ } while (parameter[pointer]==',');
+
+ if ( parameter[pointer]==')') {
+ pointer++;
+ for(; parameter[pointer]; pointer++)
+ if (!isspace(parameter[pointer])) {
+ return SyntaxError;
+ }
+ } else {
+ return SyntaxError;
+ }
+
+ return OK;
+}
+
+
+static int Go_dly_shift_82(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+#define num_of_dly_shift_points 2
+
+ int value, status;
+ float cal_point;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_delay)) {
+ return status;
+ }
+
+ switch (command_type) {
+ case command_param_units:
+ /* if param=point number, and units=measurement, then update calibration */
+ if (String_is_it_numeric(parameter) && String_is_it_numeric(units)) {
+ value=atoi(parameter);
+ if (value>num_of_dly_shift_points || value<1) {
+ return IllegalParameter;
+ }
+ cal_point=atof(units);
+ return Set_Dly_Shr_Cal(channel,value,cal_point);
+ } else if (String_is_it_numeric(parameter) && !strcmp(units,"go")) {
+ value=atoi(parameter);
+ if (value>num_of_dly_shift_points || value<1) {
+ return IllegalParameter;
+ }
+ Set_Dly_Shr_Nom(channel,value);
+ } else {
+ return SyntaxError;
+ }
+
+ return OK;
+ break;
+
+ case query_param:
+ return query_min_max_int(response, parameter, 1, num_of_dly_shift_points);
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_amp_pnt_83(gchar** response, int channel, char *parameter,char *units,int command_type,int cal_type)
+{
+ int value,status;
+ float cal_point;
+
+ switch (cal_type) {
+ case pwl_burst_values:
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_Burst_Time)) {
+ return status;
+ }
+ if (globals.Flash.max_burst_count[channel]<2) {
+ return Unrecognized;
+ }
+ break;
+ case pwl_ampl_values:
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_amplitude)) {
+ return status;
+ }
+ if (!globals.Flash.enable_avrq_extra_ampls && !globals.Flash.voltage_enabled[channel] && !globals.Flash.current_enabled[channel]) {
+ return Unrecognized;
+ }
+ if ((channel > 1) && globals.Flash.enable_avrq_extra_ampls) {
+ switch (channel) {
+ case 2:
+ cal_type=pwl_vcc1_values;
+ break;
+ case 3:
+ cal_type=pwl_vcc2_values;
+ break;
+ default:
+ return InvalidChannel;
+ break;
+ }
+ }
+ break;
+ case pwl_rise_time_values:
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_rise_time)) {
+ return status;
+ }
+ if (globals.Flash.fixed_rise_time[channel]) {
+ return Unrecognized;
+ }
+ break;
+ case pwl_slew_values:
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_slew)) {
+ return status;
+ }
+ if (!globals.Flash.curr_slew[channel]) {
+ return Unrecognized;
+ }
+ break;
+ case pwl_load_type_values:
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_load_type)) {
+ return status;
+ }
+ if (!globals.Flash.switchable_load[channel]) {
+ return Unrecognized;
+ }
+ break;
+ case pwl_os_values:
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_offset)) {
+ return status;
+ }
+ if (!globals.Flash.voltage_offset_enabled[channel] && !globals.Flash.current_offset_enabled[channel]) {
+ return Unrecognized;
+ }
+ break;
+ case pwl_pw_values:
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_pw)) {
+ return status;
+ }
+ break;
+ case pwl_delay_values:
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_delay)) {
+ return status;
+ }
+ break;
+ case pwl_period_values:
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_frequency)) {
+ return status;
+ }
+ break;
+ }
+
+ switch (command_type) {
+ case command_param_units:
+ /* if param=point number, and units=measurement, then update calibration */
+ if (String_is_it_numeric(parameter) && String_is_it_numeric(units)) {
+ value=atoi(parameter);
+ if (value>Get_VI_Num_Pnts(cal_type,channel) || value<1) {
+ return IllegalParameter;
+ }
+ cal_point=atof(units);
+ return Set_VI_Cal_Pnt(cal_type,channel,value,cal_point);
+ } else if (String_is_it_numeric(parameter) && !strcmp(units,"go")) {
+ value=atoi(parameter);
+ if (value>Get_VI_Num_Pnts(cal_type,channel) || value<1) {
+ return IllegalParameter;
+ }
+ if (status=Set_Cal_Nom(channel,value,cal_type,NULL)) {
+ return status;
+ }
+ } else if (String_is_it_numeric(parameter) && !strcmp(units,"delete")) {
+ value=atoi(parameter);
+ if (value>Get_VI_Num_Pnts(cal_type,channel) || value<1) {
+ return IllegalParameter;
+ }
+ if (status=Set_VI_Del_Cal(cal_type,channel,value)) {
+ return status;
+ }
+ } else if (String_is_it_numeric(parameter) && !strcmp(units,"add")) {
+ cal_point=atof(parameter);
+ if (status=Set_VI_Add_Cal(cal_type,channel,cal_point)) {
+ return status;
+ }
+ } else {
+ return SyntaxError;
+ }
+
+ return OK;
+ break;
+
+ case query_param:
+ return query_min_max_int(response, parameter, 1, Get_VI_Num_Pnts(cal_type,channel));
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+int Handle_Curr_Slew_Unit(float *new_val,char *units);
+int Handle_Curr_Slew_Unit(float *new_val,char *units)
+{
+ // FIXME with g_str functions
+ char *slash;
+ float tmp1, tmp2;
+
+ *new_val = 1.0;
+
+ slash = strstr (units,"/");
+ if (slash == NULL) {
+ return UnknownUnits;
+ }
+
+ slash[0]=0;
+
+ if (Handle_Units (&tmp1, units, "a") != OK) {
+ return UnknownUnits;
+ }
+
+ if (Handle_Units (&tmp2, slash+1, "s") != OK) {
+ return UnknownUnits;
+ }
+
+ *new_val = tmp1 / tmp2;
+
+ return OK;
+}
+
+
+static int Go_puls_count_88(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ int value, status;
+ int min_val;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_Burst_Count)) {
+ return status;
+ }
+
+ /* if the maximum burst count is 0 or 1, disable this command */
+ if (globals.Flash.max_burst_count[channel]<2) {
+ return Unrecognized;
+ }
+
+ min_val = 1; // -BR
+ if (globals.Flash.burst_func[channel]) {
+ min_val = 0; // -PANB
+ }
+
+ switch (command_type) {
+ case command_withparam:
+ if (status = process_int_range (parameter, &value, min_val, globals.Constraints.err_max_burst_count[channel])) {
+ return status;
+ }
+ return Set_Burst_Count(channel,value,globals.ChannelState[channel].burst_time);
+ break;
+
+ case query_simple:
+ return query_int (response, globals.ChannelState[channel].burst_count);
+ break;
+
+ case query_param:
+ return query_min_max_int(response, parameter, min_val, globals.Constraints.err_max_burst_count[channel]);
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_puls_sep_89(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ float new_pw;
+ int check_valid;
+ int status;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_Burst_Time)) {
+ return status;
+ }
+
+ /* if the maximum burst count is 0 or 1, disable this command */
+ if ((globals.Flash.max_burst_count[channel]<2) || (globals.Flash.burst_func[channel])) {
+ return Unrecognized;
+ }
+
+ new_pw=1.0;
+
+ switch (command_type) {
+ case command_param_units:
+ if (status=Handle_Units(&new_pw,units,"s")) {
+ return status;
+ }
+ /* no break */
+
+ case command_withparam:
+ globals.ChannelState[channel].ab_mode=pw_normal;
+ if (status = process_float_param (parameter, &new_pw, globals.Constraints.err_min_burst_time[channel], globals.Constraints.err_max_burst_time[channel], NORMAL_ZERO)) {
+ return status;
+ }
+ return Set_Burst_Time(0,0,0,channel,new_pw);
+ break;
+
+ case query_simple:
+ return query_float(response, globals.ChannelState[channel].burst_time);
+ break;
+
+ case query_param:
+ return query_min_max_float (response, parameter, globals.Constraints.err_min_burst_time[channel], globals.Constraints.err_max_burst_time[channel]);
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_sys_pwd_92(gchar** response, int channel, char *parameter,int command_type)
+{
+ // FIXME /etc/shadow !
+ return SyntaxError;
+}
+
+
+static int Go_eprom_sus_93(gchar** response, int channel, char *parameter,int command_type)
+{
+ // FIXME - not implemented in flash code yet
+ if (channel) {
+ return InvalidChannel;
+ }
+
+ switch (command_type) {
+ case command_withparam:
+ if (!strcmp(parameter,"1")) {
+ globals.flash_writes_suspended=1;
+ } else if (!strcmp(parameter,"0")) {
+ globals.flash_writes_suspended=0;
+ writeUserBlock(&globals.Flash,0,sizeof(globals.Flash));
+ } else {
+ return SyntaxError;
+ }
+
+ Menu_Clear_Buttons();
+ return OK;
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_rise_time_94(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ float new_rise_time;
+ int check_valid;
+ int status;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_rise_time)) {
+ return status;
+ }
+ if (globals.Flash.fixed_rise_time[channel]) {
+ return Unrecognized;
+ }
+
+ new_rise_time=1.0;
+
+ switch (command_type) {
+ case command_param_units:
+ if (status=Handle_Units(&new_rise_time,units,"s")) {
+ return status;
+ }
+ /* no break */
+
+ case command_withparam:
+ if (status = process_float_param (parameter, &new_rise_time, globals.Constraints.err_min_rise_time[channel], globals.Constraints.err_max_rise_time[channel], NORMAL_ZERO)) {
+ return status;
+ }
+ return Set_rise_time(0,0,0,channel,new_rise_time);
+ break;
+
+ case query_simple:
+ return query_float(response, globals.ChannelState[channel].rise_time);
+ break;
+
+ case query_param:
+ return query_min_max_float (response, parameter, globals.Constraints.err_min_rise_time[channel], globals.Constraints.err_max_rise_time[channel]);
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_rcl_53(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ int value, status;
+
+ switch (command_type) {
+ case command_withparam:
+ if (status = process_int_range (parameter, &value, 0, 3)) {
+ return status;
+ }
+ Set_Rcl(value);
+ return OK;
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_sav_54(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ int value, status;
+
+ switch (command_type) {
+ case command_withparam:
+ if (status = process_int_range (parameter, &value, 0, 3)) {
+ return status;
+ }
+ Set_Sav(value);
+ return OK;
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_soft_current_limit_96(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ float new_soft_current_limit;
+ int check_valid;
+ int status;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_current_limit)) {
+ return status;
+ }
+ if (!globals.Flash.soft_current_limit_enabled[channel]) {
+ return Unrecognized;
+ }
+
+ new_soft_current_limit=1.0;
+
+ switch (command_type) {
+ case command_param_units:
+ if (status=Handle_Units(&new_soft_current_limit,units,"a")) {
+ return status;
+ }
+ /* no break */
+
+ case command_withparam:
+ if (status = process_float_param (parameter, &new_soft_current_limit, globals.Constraints.err_min_soft_current_limit[channel], globals.Constraints.err_max_soft_current_limit[channel], NORMAL_ZERO)) {
+ return status;
+ }
+
+ return Set_current_limit(0,channel,new_soft_current_limit);
+
+ break;
+
+ case query_simple:
+ return query_float(response, globals.ChannelState[channel].soft_current_limit);
+ break;
+
+ case query_param:
+ return query_min_max_float (response, parameter, globals.Constraints.err_min_soft_current_limit[channel], globals.Constraints.err_max_soft_current_limit[channel]);
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_curr_slew_98(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ float new_slew;
+ int check_valid;
+ int status;
+
+ if (status = check_channel_ok (channel, globals.Flash.channels, globals.Flash.ChanKey_slew)) {
+ return status;
+ }
+ if (!globals.Flash.curr_slew[channel]) {
+ return Unrecognized;
+ }
+
+ new_slew=1.0;
+
+ switch (command_type) {
+ case command_param_units:
+ if (status=Handle_Curr_Slew_Unit(&new_slew,units)) {
+ return status;
+ }
+ /* no break */
+
+ case command_withparam:
+ if (status = process_float_param (parameter, &new_slew, globals.Constraints.err_min_slew[channel], globals.Constraints.err_max_slew[channel], NORMAL_ZERO)) {
+ return status;
+ }
+ return Set_slew(0,0,0,channel,new_slew);
+ break;
+
+ case query_simple:
+ return query_float(response, globals.ChannelState[channel].slew);
+ break;
+
+ case query_param:
+ return query_min_max_float (response, parameter, globals.Constraints.err_min_slew[channel], globals.Constraints.err_max_slew[channel]);
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_avrq_ampl(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ float new_ampl;
+ int status;
+ int max_chan;
+ float min_val,max_val,cur_val;
+
+ new_ampl=1.0;
+
+ switch (channel) {
+ case 2:
+ min_val=globals.Constraints.err_min_vcc1[0];
+ max_val=globals.Constraints.err_max_vcc1[0];
+ cur_val=globals.ChannelState[0].vcc1;
+ break;
+ case 3:
+ min_val=globals.Constraints.err_min_vcc2[0];
+ max_val=globals.Constraints.err_max_vcc2[0];
+ cur_val=globals.ChannelState[0].vcc2;
+ break;
+ case 4:
+ min_val=globals.Constraints.err_min_vlogic[0];
+ max_val=globals.Constraints.err_max_vlogic[0];
+ cur_val=globals.ChannelState[0].vlogic;
+ break;
+ default:
+ return InvalidChannel;
+ break;
+ }
+
+ switch (command_type) {
+ case command_param_units:
+ if (status=Handle_Units(&new_ampl,units,"v")) {
+ return status;
+ }
+ /* no break */
+
+ case command_withparam:
+ if (status = process_float_param (parameter, &new_ampl, min_val, max_val, NORMAL_ZERO)) {
+ return status;
+ }
+ return Set_Amplitude(0,0,0,0,0,0,channel,new_ampl,0);
+ break;
+
+ case query_simple:
+
+ return query_float(response, cur_val);
+ break;
+
+ case query_param:
+
+ return query_min_max_float (response, parameter, min_val, max_val);
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_cal_100(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ int no_report, status;
+ CalStruct caldata;
+
+ if (!globals.Flash.self_cal) {
+ return Unrecognized;
+ }
+
+ no_report = 0;
+
+ switch (command_type) {
+ case command_simple:
+ no_report = 1;
+ // continue below
+
+ case query_simple:
+ status = do_full_self_cal(&caldata);
+ if (!no_report) {
+ query_string(response, caldata.response);
+ }
+ return status;
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+
+static int Go_cal_interval_101(gchar** response, int channel, char *parameter,char *units,int command_type)
+{
+ int eprom_loc, status, the_number;
+
+ if (!globals.Flash.self_cal) {
+ return Unrecognized;
+ }
+
+ switch (command_type) {
+ case command_withparam:
+ if (status = process_int_range (parameter, &the_number, 0, 365)) {
+ return status;
+ }
+
+ globals.Flash.self_cal_interval = the_number;
+ eprom_loc = (char *) &(globals.Flash.self_cal_interval) - (char *) &(globals.Flash.flash_start);
+ writeUserBlock(eprom_loc,&globals.Flash.flash_start + eprom_loc,sizeof(globals.Flash.self_cal_interval));
+ return OK;
+ break;
+
+ case query_simple:
+ return query_int (response, globals.Flash.self_cal_interval);
+ break;
+
+ case query_param:
+ return query_min_max_int(response, parameter, 0, 365);
+ break;
+
+ default:
+ return SyntaxError;
+ break;
+ }
+}
+
+