6 years, 3 months ago.  This question has been closed. Reason: Unclear question

update a Userfile in an firmware AT of a Multitech mDot

Dear devellopers

I am implementing a function in the firmware of a Mdot that should update a value in a userfile stored on the EEPROM of the mDot module.

Actually extracting all the data of the file to the memory , modify what i want , and write it again to the file (read and write mode) leads to a code like this:

CommandTerminal::htipdata* config_data;

mDot::mdot_file file_handle = _dot->openUserFile(filename, mDot::FM_RDWR); int b=_dot->readUserFile(file_handle, config_data, 500);

(*config_data).trans_interval=15;

int a=_dot->writeUserFile(file_handle, config_data, 500); bool x=_dot->closeUserFile(file_handle);

The hitpdata structure is define by

typedef struct { char dev_cat[200]; char dev_stat[30]; bool htip_stat; int trans_interval; } htipdata ;

This code seem to work corectly but when one read the file after, one sees that the data was not modified. A reexecution of the command lead to a freeze out of the serial command terminal.

I am not sure what is wrong with this code, if you see please share it with me.

I went therefore to a more radical by removing the file when i just read it . I then recreate the file with the modified data. But doing so i realized that the main problem i face is that Icannot open and close the same file twice in the same function !!

So the following test code that just open an close the same file twice, lead to a screen freeze out on the command terminal after being executed completely :

CommandTerminal::htipdata* config_data;

char* filename = "htip_conf.txt";

mDot::mdot_file file_handle = _dot->openUserFile(filename, mDot::FM_RDONLY); _serial.writef("first opening \r\n"); int b=_dot->readUserFile(file_handle, config_data, 500); _serial.writef("first read :%d\r\n",b); bool x=_dot->closeUserFile(file_handle); _serial.writef("first close : %d\r\n",x);

_serial.writef("data :%d\r\n",(*config_data).trans_interval);

CommandTerminal::htipdata* config_data_2;

mDot::mdot_file file_handle_2 = _dot->openUserFile(filename, mDot::FM_RDONLY); _serial.writef("second opening \r\n"); int b2 = _dot->readUserFile(file_handle_2, config_data_2, 500); _serial.writef("second read :%d\r\n",b2); bool x2=_dot->closeUserFile(file_handle_2); _serial.writef("second close :%d\r\n",x2);

_serial.writef("data :%d\r\n",(*config_data_2).trans_interval);

return 0;

It display everything correctly at the command terminal

AT+UF first opening first read :500 first close : 1 data :15 second opening second read :500 second close :1 data :15

but not the final OK and makes a freeze out of the command terminal . This time i really don't know what i did wrong and i would really appreciate if someone could give me some explanation.

A code example would be at Best

Thank you for your Help and Best Regards

Gabriel