Hi guys,
I am using FDS module in nrf51822, sdk 11 to store and read data from flash. I have a problem about reading the data. In the documents, the function:
fds_record_open(&record_desc, &flash_record)
is used to read data from flash. However, I just can read the location of the data. From this, how can I read the data's value?
For example, I write to the flash:
fds_record_t record;
fds_record_chunk_t record_chunk;
// Set up data.
record_chunk.p_data = &m_deadbeef;
record_chunk.length_words = 1;
// Set up record.
record.file_id = FILE_ID;
record.key = REC_KEY;
record.data.p_chunks = &record_chunk;
record.data.num_chunks = 1;
SEGGER_RTT_printf(0, "variable value before: %d\n", record_chunk.p_data);
ret_code_t ret = fds_record_write(&record_desc1, &record);
The data display was: 139292. And then I read from it:
fds_flash_record_t flash_record;
fds_find_token_t ftok = {0};
// Loop until all records with the given key and file ID have been found.
while (fds_record_find(FILE_ID, REC_KEY, &record_desc1, &ftok) == FDS_SUCCESS)
{
if (fds_record_open(&record_desc1, &flash_record) != FDS_SUCCESS)
{
// Handle error.
}
SEGGER_RTT_printf(0, "variable value: %d\n", flash_record.p_data);
// Access the record through the flash_record structure.
// Close the record when done.
if (fds_record_close(&record_desc1) != FDS_SUCCESS)
{
SEGGER_RTT_WriteString(0, "CAN_NOT_CLOSE_FDS!\n");
// Handle error.
}
}
The display was: 260116 260132 260148 and so on...