diff options
author | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-11-14 11:15:58 -0500 |
---|---|---|
committer | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-11-14 11:15:58 -0500 |
commit | b49a4e3d3f5e4005c4b1070979b7510011862233 (patch) | |
tree | 574be7edd3afa7db3c654457d14ed9dbd8f411e4 /device-functions.c | |
parent | 5e8c4720b8406764b5911d74898c63649d5d5802 (diff) |
use GStrings instead of fixed length strings in self-cal
Diffstat (limited to 'device-functions.c')
-rw-r--r-- | device-functions.c | 14 |
1 files changed, 10 insertions, 4 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); |