diff options
author | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-08-16 09:23:01 -0400 |
---|---|---|
committer | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-08-16 09:23:01 -0400 |
commit | b4217b23f5b8ba5eedf0bc7354cea76d0575de3a (patch) | |
tree | eb48d72209899c8962356fb54bf3ae279f94845f | |
parent | c210f9167be5bb4b8ac63faf1817e086c8d94ed7 (diff) |
make flash struct an argument to the flash read/write functions
-rw-r--r-- | dummy_functions.c | 23 | ||||
-rw-r--r-- | dummy_functions.h | 5 | ||||
-rw-r--r-- | parser.c | 14 |
3 files changed, 33 insertions, 9 deletions
diff --git a/dummy_functions.c b/dummy_functions.c index 98d0afb..9f3abb3 100644 --- a/dummy_functions.c +++ b/dummy_functions.c @@ -1,4 +1,5 @@ #include "dummy_functions.h" +#include "globals.h" void Menu_Refresh() {} void Menu_Update_Display() {} @@ -8,4 +9,24 @@ void GPIB_Set_Device_Dependent_Error() {} void GPIB_Set_Execution_Error() {} void Main_update_shift_registers() { } void Error_check(void* p) { } -void writeUserBlock(int addr, int numbytes) {} + +int readUserBlock(FlashStruct mem) +{ + // read the flash.copy file into the FlashStruct + // and return the number of bytes read in + + // if the file does not exist, then "return 0"; + return 0; +} + +void writeUserBlock(FlashStruct mem, int addr, int numbytes) +{ + // check if flash.copy file exists + // - if it does, update the requested address and + // number of bytes + + // - if does not, create the file and + // set addr = 0, numbytes = sizeof (mem) + // so that entire struct will be written, + // instead of just the requested range +} diff --git a/dummy_functions.h b/dummy_functions.h index f72ba6a..a00569f 100644 --- a/dummy_functions.h +++ b/dummy_functions.h @@ -1,6 +1,8 @@ #ifndef DUMMY_FUNCTIONS_H_ #define DUMMY_FUNCTIONS_H_ +#include "globals.h" + void Menu_Refresh(); void Menu_Update_Display(); void GPIB_Set_Command_Error(); @@ -9,5 +11,6 @@ void GPIB_Set_Device_Dependent_Error(); void GPIB_Set_Execution_Error(); void Main_update_shift_registers(); void Error_check(void*); -void writeUserBlock(int addr, int numbytes); +int readUserBlock(FlashStruct mem); +void writeUserBlock(FlashStruct mem, int addr, int numbytes); #endif @@ -902,7 +902,7 @@ static int Go_Str_eprom_47(gchar** response, int channel, char *loc_string,char *(char *)(&globals.Flash.flash_start + eprom_loc+i)=store_string[i]; } *(char *)(&globals.Flash.flash_start + eprom_loc + i)=(char) 0; /* end of string */ - writeUserBlock(eprom_loc,strlen(store_string)+1); + writeUserBlock(globals.Flash, eprom_loc, strlen(store_string)+1); return OK; } else { return OutOfRange; @@ -925,7 +925,7 @@ static int Go_int_eprom_48(gchar** response, int channel, char *loc_string,char /* diag:eprom:int - 48 */ int eprom_loc; int i; - int the_number; + short the_number; eprom_loc = atoi(loc_string); /* convert location string to a number */ @@ -936,9 +936,9 @@ static int Go_int_eprom_48(gchar** response, int channel, char *loc_string,char switch (command_type) { case command_param_units: - the_number=atoi(store_string); - *(short *)(&globals.Flash.flash_start + eprom_loc)=(short) the_number; - writeUserBlock(eprom_loc,sizeof(the_number)); + the_number=(short) atoi(store_string); + *(short *)(&globals.Flash.flash_start + eprom_loc) = the_number; + writeUserBlock(globals.Flash, eprom_loc, sizeof (the_number)); return OK; break; @@ -972,7 +972,7 @@ static int Go_Float_eprom51(gchar** response, int channel, char *loc_string,char case command_param_units: the_number=atof(store_string); *(float *)(&globals.Flash.flash_start + eprom_loc)=the_number; - writeUserBlock(eprom_loc,sizeof(the_number)); + writeUserBlock(globals.Flash, eprom_loc, sizeof(the_number)); return OK; break; @@ -1006,7 +1006,7 @@ static int Go_char_eprom_70(gchar** response, int channel, char *loc_string,char case command_param_units: the_number=(char) atoi(store_string); *(char *)(&globals.Flash.flash_start + eprom_loc)=the_number; - writeUserBlock(eprom_loc,sizeof(the_number)); + writeUserBlock(globals.Flash, eprom_loc, sizeof(the_number)); return OK; break; |