summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bus.c4
-rw-r--r--error_utils.c5
-rw-r--r--globals.h2
-rw-r--r--instr-daemon.c58
-rw-r--r--parser.c4
5 files changed, 45 insertions, 28 deletions
diff --git a/bus.c b/bus.c
index c539d16..3f0dbc6 100644
--- a/bus.c
+++ b/bus.c
@@ -369,9 +369,7 @@ void bus_init()
if (!globals.HWDetect.beaglebone) {
printf("This doesn't seem to be a beaglebone.. bus stuff disabled!\n");
- }
-
- if (globals.HWDetect.beaglebone) {
+ } else {
gpmc_setup();
extbus = (uint8_t*) util_mapmemoryblock(0x01000000, 0x100);
diff --git a/error_utils.c b/error_utils.c
index bb2cd32..d1f8283 100644
--- a/error_utils.c
+++ b/error_utils.c
@@ -60,6 +60,7 @@ void set_gpib_error_flags (int error_num)
case Soft_Limit_Exceeded:
case SelfCalError:
case NetworkNotFound:
+ case Startup_Not_Finished:
GPIB_Set_Device_Dependent_Error();
break;
default:
@@ -519,6 +520,10 @@ void get_error_text(gchar **response, int error_num)
format_error_text(response,-200,"Invalid execution path. Programming error.");
break;
+ case Startup_Not_Finished:
+ format_error_text(response,-300,"Not ready for commands yet. Still booting up.");
+ break;
+
default:
format_error_text(response,-200,"Specific problem unknown.");
}
diff --git a/globals.h b/globals.h
index d7529f0..2fe6de7 100644
--- a/globals.h
+++ b/globals.h
@@ -87,6 +87,7 @@
#define SelfCalError 73
#define NetworkNotFound 74
#define ThisShouldntHappen 75
+#define Startup_Not_Finished 76
#define YES 1
#define NO 0
@@ -748,6 +749,7 @@ typedef struct {
int force_output_fully_off;
int shutdown_started;
int flash_write_in_progress;
+ int startup_complete;
} FlagStruct;
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;
}
diff --git a/parser.c b/parser.c
index 081d6c6..800909c 100644
--- a/parser.c
+++ b/parser.c
@@ -783,6 +783,10 @@ void Parser_main (char *raw_in, int interactive_terminal, void(*cbfunc)(gpointer
units_found = Parser_get_unit(&parameter,&units);
+ if (!globals.Flags.startup_complete) {
+ error_num=Startup_Not_Finished;
+ }
+
if (!error_num) {
command_type=(is_query<<2) | (parameter_found?2:0) | units_found;