I am trying to save and read a structure using FDS, how do I go about it?
I have the structure:
Fullscreen
1
2
3
4
5
6
7
typedef struct
{
uint16_t total_runhours_flash;
float total_energy_consumed_flash;
}energy_struct;
energy_struct energy_variables;
Is this correct by populating the record as such?:
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
fds_record_t record;
fds_record_desc_t record_desc;
record.file_id = FILE_ID;
record.key = ENERGY_KEY;
record.data.p_data = &energy_variables;
record.data.length_words = sizeof(energy_variables);
fds_record_desc_t desc = {0};
rc = fds_record_update(&desc, &record);
APP_ERROR_CHECK(rc);
And to read is the main problem, I can't seem to match the types in which it would load data from the structure: (This is giving error)
Fullscreen
1
energy_variables = (struct energy_struct *) config.p_data;