diff options
Diffstat (limited to 'parser.c')
-rw-r--r-- | parser.c | 137 |
1 files changed, 46 insertions, 91 deletions
@@ -2733,44 +2733,25 @@ static int Go_gpib_addr_59(gchar** response, int channel, char *parameter,char * static int Go_ser_baud_60(gchar** response, int channel, char *parameter,char *units,int command_type) { - int value, status; + int new_baud, status; + int valid_choices[] = {1200, 2400, 4800, 9600}; switch (command_type) { case command_withparam: - if (status=process_four_ints (parameter, &value, 1200, 2400, 4800, 9600)) { + // FIXME - expand this list + // FIXME - hardcoded "4" + if (status = process_int_param (parameter, &new_baud, 4, valid_choices, NO_ON_OFF)) { 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; + return IO_Setup_RS232(new_baud, globals.Flash.parity, globals.Flash.stopbits, globals.Flash.databits, globals.Flash.hardhand, globals.Flash.echo); 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); + return query_int (response, globals.Flash.baud); break; case query_param: + // FIXME - extract min, max from a new baud list return query_min_max_int (response, parameter, 1200, 9600); break; @@ -2785,29 +2766,30 @@ static int Go_ser_baud_60(gchar** response, int channel, char *parameter,char *u static int Go_ser_par_61(gchar** response, int channel, char *parameter,char *units,int command_type) { + + int new_parity; + switch (command_type) { case command_withparam: if (!strcmp(parameter,"even")) { - globals.RS232.parity = rs232_parity_even; + new_parity = rs232_parity_even; } else if (!strcmp(parameter,"odd")) { - globals.RS232.parity = rs232_parity_odd; + new_parity = rs232_parity_odd; } else if (!strcmp(parameter,"none")) { - globals.RS232.parity = rs232_parity_none; + new_parity = rs232_parity_none; } else { return IllegalParameter; } - IO_Setup_RS232(); - - return OK; + return IO_Setup_RS232(globals.Flash.baud, (char) new_parity, globals.Flash.stopbits, globals.Flash.databits, globals.Flash.hardhand, globals.Flash.echo); break; case query_simple: - if (globals.RS232.parity==rs232_parity_even) { + if (globals.Flash.parity==rs232_parity_even) { return query_string(response, "EVEN"); - } else if (globals.RS232.parity==rs232_parity_odd) { + } else if (globals.Flash.parity==rs232_parity_odd) { return query_string(response, "ODD"); - } else if (globals.RS232.parity==rs232_parity_none) { + } else if (globals.Flash.parity==rs232_parity_none) { return query_string(response, "NONE"); } return OK; @@ -2824,33 +2806,20 @@ static int Go_ser_par_61(gchar** response, int channel, char *parameter,char *un static int Go_ser_bits_62(gchar** response, int channel, char *parameter,char *units,int command_type) { - int value, status; + int new_databits; + int status; switch (command_type) { case command_withparam: - if (status=process_two_ints (parameter, &value, 7, 8)) { + if (status=process_two_ints (parameter, &new_databits, 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; + return IO_Setup_RS232(globals.Flash.baud, globals.Flash.parity, globals.Flash.stopbits, (char) new_databits, globals.Flash.hardhand, globals.Flash.echo); 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); + return query_int (response, globals.Flash.databits); break; case query_param: @@ -2868,33 +2837,20 @@ static int Go_ser_bits_62(gchar** response, int channel, char *parameter,char *u static int Go_ser_sbits_63(gchar** response, int channel, char *parameter,char *units,int command_type) { - int value, status; + int new_stopbits; + int status; switch (command_type) { case command_withparam: - if (status=process_two_ints (parameter, &value, 1, 2)) { + if (status=process_two_ints (parameter, &new_stopbits, 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; + return IO_Setup_RS232(globals.Flash.baud, globals.Flash.parity, (char) new_stopbits, globals.Flash.databits, globals.Flash.hardhand, globals.Flash.echo); 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); + return query_int (response, globals.Flash.stopbits); break; case query_param: @@ -2912,26 +2868,31 @@ static int Go_ser_sbits_63(gchar** response, int channel, char *parameter,char * static int Go_ser_rts_64(gchar** response, int channel, char *parameter,char *units,int command_type) { + char new_hardhand; + switch (command_type) { case command_withparam: if (!strcmp(parameter,"rfr") || !strcmp(parameter,"ibf") || !strcmp(parameter,"ibfull")) { - globals.RS232.hardhand = rs232_hard_on; + // these are valid hardware handshake modes + new_hardhand = 1; } else if (!strcmp(parameter,"on")) { - globals.RS232.hardhand = rs232_hard_off; + // FIXME - confusing: in absence of handware handshaking, + // RTS is supposed to be always ON? Confirm + new_hardhand = 0; } else { return IllegalParameter; } - IO_Setup_RS232(); - - return OK; + return IO_Setup_RS232(globals.Flash.baud, globals.Flash.parity, globals.Flash.stopbits, globals.Flash.databits, new_hardhand, globals.Flash.echo); break; case query_simple: - if (globals.RS232.hardhand==rs232_hard_on) { + if (globals.Flash.hardhand) { return query_string(response, "IBF"); - } else if (globals.RS232.hardhand==rs232_hard_off) { + } else { + // FIXME: confirm RTS is always high in BB ports if + // hardware handshaking is not used return query_string(response, "ON"); } return OK; @@ -2948,27 +2909,21 @@ static int Go_ser_rts_64(gchar** response, int channel, char *parameter,char *un static int Go_ser_echo_65(gchar** response, int channel, char *parameter,char *units,int command_type) { - int on_off, status; + int new_echo; + int status; switch (command_type) { case command_withparam: - if (status=process_on_off (parameter, &on_off)) { + if (status=process_on_off (parameter, &new_echo)) { return status; } - - if (on_off) { - globals.RS232.echo = rs232_echo_on; - } else { - globals.RS232.echo = rs232_echo_off; - } - - return OK; + return IO_Setup_RS232(globals.Flash.baud, globals.Flash.parity, globals.Flash.stopbits, globals.Flash.databits, globals.Flash.hardhand, (char) new_echo); break; case query_simple: - if (globals.RS232.echo==rs232_echo_on) { + if (globals.Flash.echo) { return query_int (response, 1); - } else if (globals.RS232.echo==rs232_echo_off) { + } else { return query_int (response, 0); } return OK; |