summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flash.c18
-rw-r--r--globals.h13
-rw-r--r--instr-daemon.c8
-rw-r--r--parser.c2
4 files changed, 24 insertions, 17 deletions
diff --git a/flash.c b/flash.c
index 30a198c..8222c8d 100644
--- a/flash.c
+++ b/flash.c
@@ -272,10 +272,10 @@ static int readUserBlock(FlashStruct *mem)
// hopefully we can use the backup..
if (persistence_unfreeze(BACKUPFILE, mem, sizeof(*mem), 0)) {
// if the backup was good overwrite the main file
- if (!globals.Flags.shutdown_started) {
- globals.Flags.flash_write_in_progress = TRUE;
+ if (!globals.Sys.shutdown_started) {
+ globals.Sys.flash_write_in_progress = TRUE;
persistence_copyfile(BACKUPFILE, MAINFILE);
- globals.Flags.flash_write_in_progress = FALSE;
+ globals.Sys.flash_write_in_progress = FALSE;
}
return sizeof(*mem);
}
@@ -301,14 +301,14 @@ void writeUserBlock(FlashStruct *mem, int addr, int numbytes)
if (!globals.Flags.flash_writes_suspended) {
// backup the main copy of the file
- if (!globals.Flags.shutdown_started) {
+ if (!globals.Sys.shutdown_started) {
- globals.Flags.flash_write_in_progress = TRUE;
+ globals.Sys.flash_write_in_progress = TRUE;
bool backup_ok = persistence_copyfile(MAINFILE, BACKUPFILE);
- globals.Flags.flash_write_in_progress = FALSE;
+ globals.Sys.flash_write_in_progress = FALSE;
- if (backup_ok && !globals.Flags.shutdown_started) {
- globals.Flags.flash_write_in_progress = TRUE;
+ if (backup_ok && !globals.Sys.shutdown_started) {
+ globals.Sys.flash_write_in_progress = TRUE;
if (!persistence_freeze(MAINFILE, mem, addr, numbytes, sizeof(*mem), 0)) {
if (errno != PERSIST_ERR_COULDNTWRITE) {
@@ -317,7 +317,7 @@ void writeUserBlock(FlashStruct *mem, int addr, int numbytes)
printf("Error while writing data to disk. **File is potentially corrupt!**\n");
}
}
- globals.Flags.flash_write_in_progress = FALSE;
+ globals.Sys.flash_write_in_progress = FALSE;
} else {
printf("Could not backup current file. **Write did not happen!!!**\n");
}
diff --git a/globals.h b/globals.h
index 2fe6de7..96cab87 100644
--- a/globals.h
+++ b/globals.h
@@ -742,17 +742,23 @@ typedef struct {
// note flags with non-zero default/reset values in globals.c
// for example, do_check_settings=1 by default
+// These flags are reset by Main_Rst
typedef struct {
int extended_ampl_min_max;
int do_check_settings;
int flash_writes_suspended;
int force_output_fully_off;
- int shutdown_started;
- int flash_write_in_progress;
- int startup_complete;
} FlagStruct;
+// These flags are NOT reset by Main_Rst, and default to 0
+typedef struct {
+ int shutdown_started;
+ int flash_write_in_progress;
+ int startup_complete;
+} SysFlagStruct;
+
+
typedef struct {
long startup_timer_value;
long last_activity_at[max_channels];
@@ -782,6 +788,7 @@ typedef struct {
ErrorStruct Errors;
FlagStruct Flags;
FlagStruct DefaultFlags;
+ SysFlagStruct Sys;
TimeStruct Timers;
MenuStatusStruct MenuStatus;
RemoteStruct Remote;
diff --git a/instr-daemon.c b/instr-daemon.c
index 58bff70..ea5f2b6 100644
--- a/instr-daemon.c
+++ b/instr-daemon.c
@@ -327,7 +327,7 @@ static gboolean finish_boot (void)
// FIXME - self-cal here - or in thread beside user sessions?
- globals.Flags.startup_complete = 1;
+ globals.Sys.startup_complete = 1;
return FALSE; // no more calls to this function are needed
}
@@ -336,9 +336,9 @@ static gboolean periodic_poll (void)
{
if (globals.HWDetect.beaglebone && bus_getpin (POWER_FAIL)) {
- globals.Flags.shutdown_started = TRUE;
+ globals.Sys.shutdown_started = TRUE;
- while (globals.Flags.flash_write_in_progress) {
+ while (globals.Sys.flash_write_in_progress) {
g_usleep(1000);
}
@@ -367,7 +367,7 @@ static gboolean periodic_poll (void)
exit(0);
}
- if (globals.Flags.startup_complete) {
+ if (globals.Sys.startup_complete) {
int i, output_on_time_so_far;
for (i=0; i<(globals.Flash.ChanKey_output_state?globals.Flash.channels:1); ++i) {
diff --git a/parser.c b/parser.c
index 800909c..2df2b18 100644
--- a/parser.c
+++ b/parser.c
@@ -783,7 +783,7 @@ void Parser_main (char *raw_in, int interactive_terminal, void(*cbfunc)(gpointer
units_found = Parser_get_unit(&parameter,&units);
- if (!globals.Flags.startup_complete) {
+ if (!globals.Sys.startup_complete) {
error_num=Startup_Not_Finished;
}