diff options
author | root <root@fedora-arm.domain.avtechpulse.com> | 1999-12-31 20:28:31 -0500 |
---|---|---|
committer | root <root@fedora-arm.domain.avtechpulse.com> | 1999-12-31 20:28:31 -0500 |
commit | 839c01f7c250431644bd827e21f7363314ef3f13 (patch) | |
tree | 6b3ad3b3a4bf811651c1055074d2f184a8c89a3e | |
parent | f58de74bf0fc34cc1e5547324e21772f83b09923 (diff) |
prepare to arrange responses as callbacks
-rw-r--r-- | parser.c | 37 | ||||
-rw-r--r-- | parser.h | 4 | ||||
-rw-r--r-- | response.c | 8 |
3 files changed, 23 insertions, 26 deletions
@@ -528,7 +528,7 @@ static int Parser_get_unit(char *parameter,char *units) return units_present;
}
-void Parser_main (char *in, gchar** response, int allow_unrequested_responses, int *error_num)
+void Parser_main (char *in, gchar** response, int allow_unrequested_responses)
{
int in_pos; /* this identifies the single character of in being processed */
int command_depth; /* how many command words have been parsed */
@@ -683,16 +683,16 @@ void Parser_main (char *in, gchar** response, int allow_unrequested_responses, i ++command_depth;
/* add end of tokens marker (0) */
- *error_num=OK;
+ int error_num=OK;
response[0]=0;
if (parameter_found) {
units_found = Parser_get_unit(parameter,units);
- *error_num=String_trim_excess_digits(parameter);
- *error_num=String_trim_excess_digits(units);
+ error_num=String_trim_excess_digits(parameter);
+ error_num=String_trim_excess_digits(units);
}
- if (!*error_num) {
+ if (!error_num) {
if (!units_found) {
units[0]='\0';
}
@@ -703,7 +703,7 @@ void Parser_main (char *in, gchar** response, int allow_unrequested_responses, i routine_num = Parser_find_commands(commands,command_depth);
/* check for valid channel number, based on position in command */
- if ( (*error_num=Parser_channel(&channel,with_id_code,routine_num)) )
+ if ( (error_num=Parser_channel(&channel,with_id_code,routine_num)) )
/* not a valid command due to improper channel suffix */
{
routine_num=9999;
@@ -716,17 +716,17 @@ void Parser_main (char *in, gchar** response, int allow_unrequested_responses, i switch (routine_num) {
case 0:
*response = g_strdup_printf("routine_num: %d, channel: %d, parameter: %s, units: %s, command type: %d\n\r",routine_num,channel,parameter,units,command_type);
- *error_num=Unrecognized;
+ error_num=Unrecognized;
break;
case 11:
- *error_num=Go_syst_err_11(response,channel,parameter,units,command_type);
+ error_num=Go_syst_err_11(response,channel,parameter,units,command_type);
break;
case 32:
case 33:
- *error_num=Go_freq_32_33(response,channel,parameter,units,command_type);
+ error_num=Go_freq_32_33(response,channel,parameter,units,command_type);
break;
case 66:
- *error_num=Go_syst_errcnt66(*response,channel,parameter,units,command_type);
+ error_num=Go_syst_errcnt66(*response,channel,parameter,units,command_type);
break;
case 9999:
@@ -741,15 +741,16 @@ void Parser_main (char *in, gchar** response, int allow_unrequested_responses, i }
}
-// int control_mode = 0; //CUSTOM
-
-// FIXME
- if (*error_num) {
+ // FIXME
+ if (error_num) {
g_free (*response);
- queue_error_from_parser(response, *error_num);
- } // else {
-// IO_output_to_comm_bus(response,control_mode);
-// }
+ queue_error_from_parser(response, error_num);
+ if (allow_unrequested_responses) {
+ ; // SEND ERROR RESPONSE TO CLIENT NOW!
+ }
+ } else {
+ ; // SEND RESPONSE TO CLIENT NOW!
+ }
if (!is_query) {
Main_update_shift_registers(); /* update values in pulse generator circuit */
@@ -29,6 +29,6 @@ #define USE_ON_OFF 0 #define NO_ON_OFF 1 -void Parser_main (char *in, gchar** response, int allow_unrequested_responses, int* errors); +void Parser_main (char *in, gchar** response, int allow_unrequested_responses); -#endif
\ No newline at end of file +#endif @@ -114,7 +114,6 @@ void responseCb(gpointer instance, GObject *arg1, gpointer user_data) gchar* str = data->data; gssize written = 0; - int errors=OK; gchar* out = NULL; @@ -126,11 +125,8 @@ void responseCb(gpointer instance, GObject *arg1, gpointer user_data) LCD_display_error_message(lcd_str); // I2C/LCD test functions - stop - Parser_main(str, &out, 1, &errors); - - if(errors) { - - } + // FIXME - Parser_main may generate multiple responses + Parser_main(str, &out, 1); if(out==NULL) out=g_strdup(" "); |