diff options
-rw-r--r-- | device-functions.c | 14 | ||||
-rw-r--r-- | globals.h | 2 | ||||
-rw-r--r-- | parser.c | 3 |
3 files changed, 13 insertions, 6 deletions
diff --git a/device-functions.c b/device-functions.c index f2b3cd3..aca5cd3 100644 --- a/device-functions.c +++ b/device-functions.c @@ -4037,7 +4037,7 @@ int go_cal(CalStruct *caldata) void cal_string(char *parameter, CalStruct *caldata) { gchar *string = g_strdup_printf ("CH%d %s cal: %d errors. Adj: %6.2f%% max, %6.2f%% avg.\r\n", caldata->channel+1,parameter, caldata->error, caldata->max_change, caldata->avg_change); - strcat (caldata->response, string); + g_string_append (caldata->response, string); g_free (string); } @@ -4045,7 +4045,12 @@ void cal_string(char *parameter, CalStruct *caldata) int self_cal() { CalStruct caldata; - return do_full_self_cal(&caldata); + + int status = do_full_self_cal(&caldata); + + g_string_free (caldata.response, TRUE); + + return status; } @@ -4055,6 +4060,8 @@ int do_full_self_cal(CalStruct *caldata) long start_timer, diff_timer; int eprom_loc; + caldata->response = g_string_new (""); + Menu_Clear_Buttons(); LCD_clear(); /*0123456789012345678901234567890123456789*/ LCD_write(0,0,"Self-calibration in progress."); @@ -4073,7 +4080,6 @@ int do_full_self_cal(CalStruct *caldata) } start_timer = sec_timer(); - caldata->response[0] = 0; caldata->total_errors = 0; caldata->total_max_change = 0.0; @@ -4127,7 +4133,7 @@ int do_full_self_cal(CalStruct *caldata) globals.Flash.self_cal_typical_time_sec = (int) (diff_timer % 60); string = g_strdup_printf ("Completed in %d minutes and %d seconds\r\n", globals.Flash.self_cal_typical_time_min, globals.Flash.self_cal_typical_time_sec); - strcat (caldata->response, string); + g_string_append (caldata->response, string); g_free (string); eprom_loc = (char *) &(globals.Flash.self_cal_typical_time_min) - (char *) &(globals.Flash.flash_start); @@ -304,7 +304,7 @@ typedef struct { float avg_change; int total_errors; float total_max_change; - char response[max_output_length]; + GString *response; } CalStruct; @@ -3985,7 +3985,8 @@ static int Go_cal_100(gchar** response, int channel, char *parameter,char *units case query_simple: status = do_full_self_cal(&caldata); if (!no_report) { - query_string(response, caldata.response); + query_string(response, caldata.response->str); + g_string_free (caldata.response, TRUE); } return status; break; |