summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flash.c22
-rw-r--r--parser.c10
2 files changed, 17 insertions, 15 deletions
diff --git a/flash.c b/flash.c
index 9861b84..f358ee2 100644
--- a/flash.c
+++ b/flash.c
@@ -284,24 +284,26 @@ int readUserBlock(FlashStruct *mem)
void writeUserBlock(FlashStruct *mem, int addr, int numbytes)
{
-
// *** There is a potential issue here.. if the mainfile is corrupt ***
// *** and this gets called before readUserBlock then the ***
// *** potentially workable backup will be lost .. we could check ***
// *** that the main file is valid before backing it up I guess... ***
// *** but I don't think this situation should arise. ***
- // backup the main copy of the file
- if (persistence_copyfile(MAINFILE, BACKUPFILE)) {
- if (!persistence_freeze(MAINFILE, mem, addr, numbytes, sizeof(*mem), 0)) {
- if (errno != PERSIST_ERR_COULDNTWRITE) {
- printf("Error while trying to write, %d. **Write did not happen!!!**\n", errno);
- } else {
- printf("Error while writing data to disk. **File is potentially corrupt!**\n");
+ if (!globals.flash_writes_suspended) {
+
+ // backup the main copy of the file
+ if (persistence_copyfile(MAINFILE, BACKUPFILE)) {
+ if (!persistence_freeze(MAINFILE, mem, addr, numbytes, sizeof(*mem), 0)) {
+ if (errno != PERSIST_ERR_COULDNTWRITE) {
+ printf("Error while trying to write, %d. **Write did not happen!!!**\n", errno);
+ } else {
+ printf("Error while writing data to disk. **File is potentially corrupt!**\n");
+ }
}
+ } else {
+ printf("Could not backup current file. **Write did not happen!!!**\n");
}
- } else {
- printf("Could not backup current file. **Write did not happen!!!**\n");
}
}
diff --git a/parser.c b/parser.c
index f92ca2f..9356d10 100644
--- a/parser.c
+++ b/parser.c
@@ -1261,7 +1261,6 @@ static int Go_Float_eprom51(gchar** response, int channel, char *loc_string,char
the_number=atof(store_string);
*(float *)(&globals.Flash.flash_start + eprom_loc)=the_number;
writeUserBlock(&globals.Flash, eprom_loc, sizeof(the_number));
-
return OK;
break;
@@ -3084,10 +3083,7 @@ static int Go_mon_step_74(gchar** response, int channel, char *parameter,char *u
globals.Flash.monitor_step[channel]=mon_val;
eprom_loc = (char *) &(globals.Flash.monitor_step) - (char *) &(globals.Flash.flash_start);
- if (!globals.flash_writes_suspended) {
- writeUserBlock(eprom_loc,&globals.Flash.flash_start + eprom_loc,sizeof(globals.Flash.monitor_step));
- }
-
+ writeUserBlock(eprom_loc,&globals.Flash.flash_start + eprom_loc,sizeof(globals.Flash.monitor_step));
break;
case query_simple:
@@ -3718,6 +3714,10 @@ static int Go_eprom_sus_93(gchar** response, int channel, char *parameter,int co
return OK;
break;
+ case query_simple:
+ return query_int (response, globals.flash_writes_suspended);
+ break;
+
default:
return SyntaxError;
break;