diff options
author | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-11-02 09:09:29 -0400 |
---|---|---|
committer | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-11-02 09:09:29 -0400 |
commit | cdbd46762b944ccc310315e11d865c2ea7cac922 (patch) | |
tree | dcd94f778505b4795c0b25dcd541005615c795ad /instr-daemon.c | |
parent | 2ee3c13800b11a609229df8f16c7028f52340571 (diff) |
Add a flag to signal completion of startup. To be expanded.
Diffstat (limited to 'instr-daemon.c')
-rw-r--r-- | instr-daemon.c | 58 |
1 files changed, 33 insertions, 25 deletions
diff --git a/instr-daemon.c b/instr-daemon.c index d79916d..24bfe45 100644 --- a/instr-daemon.c +++ b/instr-daemon.c @@ -238,12 +238,13 @@ int main(int argc, char **argv) LCD_write(3,0,"Warming up, please wait... "); globals.Timers.startup_timer_value = sec_timer (); - long timer_count; - long on_delay = (long)globals.Flash.turn_on_dly; + + Main_Rst(); #define MIN_STARTUP_DELAY 2 #define MAX_STARTUP_DELAY 120 + long on_delay = (long)globals.Flash.turn_on_dly; if (on_delay < MIN_STARTUP_DELAY) { on_delay = MIN_STARTUP_DELAY; } @@ -251,6 +252,7 @@ int main(int argc, char **argv) on_delay = MAX_STARTUP_DELAY; } + long timer_count; while ((timer_count=sec_timer()-globals.Timers.startup_timer_value) < on_delay) { message = g_strdup_printf ("%ld ", on_delay - timer_count); LCD_write(3,27,message); @@ -260,9 +262,10 @@ int main(int argc, char **argv) I2C_Setup_Monitor(); - Main_Rst(); Show_Main_Menu(); + globals.Flags.startup_complete = 1; + // FIXME - self-cal here - or in thread beside user sessions? //register stdin channel @@ -319,7 +322,7 @@ int main(int argc, char **argv) static gboolean periodic_poll (void) { - if (bus_getpin (POWER_FAIL)) { + if (globals.HWDetect.beaglebone && bus_getpin (POWER_FAIL)) { globals.Flags.shutdown_started = TRUE; @@ -350,36 +353,41 @@ static gboolean periodic_poll (void) exit(0); } - int i, output_on_time_so_far; - for (i=0; i<(globals.Flash.ChanKey_output_state?globals.Flash.channels:1); ++i) { - output_on_time_so_far = (int) (sec_timer()-globals.Timers.last_activity_at[i]); - if ((globals.Flash.output_timer[i]>0) && (globals.Timers.last_activity_at[i]>0) && (output_on_time_so_far > globals.Flash.output_timer[i])) { - Set_Output_State(i,output_off); - Show_Main_Menu(); + if (globals.Flags.startup_complete) { + int i, output_on_time_so_far; + + for (i=0; i<(globals.Flash.ChanKey_output_state?globals.Flash.channels:1); ++i) { + output_on_time_so_far = (int) (sec_timer()-globals.Timers.last_activity_at[i]); + if ( (globals.Flash.output_timer[i]>0) && + (globals.Timers.last_activity_at[i]>0) && + (output_on_time_so_far > globals.Flash.output_timer[i])) { + Set_Output_State(i,output_off); + Show_Main_Menu(); + } } - } - Update_Main_Menu_If_Visible(); + Update_Main_Menu_If_Visible(); - Menu_Check_Buttons (); + Menu_Check_Buttons (); - for (i=0; i<max_channels; i++) { - if (globals.Flash.monitor_enabled[i]) { - I2C_Check_Monitors(); + for (i=0; i<max_channels; i++) { + if (globals.Flash.monitor_enabled[i]) { + I2C_Check_Monitors(); + } } - } - Update_Main_Menu_If_Visible(); + Update_Main_Menu_If_Visible(); - GPIB_check_for_device_clear_signal(); - if (GPIB_check_for_messages(globals.Registers.gpib_buffer)) { - if (GPIB_handle_new_input(globals.Registers.gpib_buffer)) { - Parser_main(globals.Registers.gpib_buffer, 0, GPIB_send_query_response, NULL); + GPIB_check_for_device_clear_signal(); + if (GPIB_check_for_messages(globals.Registers.gpib_buffer)) { + if (GPIB_handle_new_input(globals.Registers.gpib_buffer)) { + Parser_main(globals.Registers.gpib_buffer, 0, GPIB_send_query_response, NULL); + } } - } - GPIB_check_for_device_clear_signal(); + GPIB_check_for_device_clear_signal(); - Update_Main_Menu_If_Visible(); + Update_Main_Menu_If_Visible(); + } return TRUE; } |