This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to store Float array in nRF51 using FDS

hi NORDIC,

is it possible to store float array in fds. i am able to store intrger values but unable to store float values. i am using example in this link :- github.com/.../nRF52-fds-example

i am writing float m_deadbeef[20][3]; //////(LIKE this i need to store 5 arrays and i should retrieve it back) in to flash.

i dont know it is writing or not but writing is successful.

but while reading back the data i am getting empty spaces.

here is how i am reading back data from FDS

float *data;

uint32_t err_code;

    NRF_LOG_PRINTF("Start searching... \r\n");

// Loop until all records with the given key and file ID have been found.

while (fds_record_find(FILE_ID, REC_KEY, &record_desc, &ftok) == FDS_SUCCESS)

{

err_code = fds_record_open(&record_desc, &flash_record);

if ( err_code != FDS_SUCCESS)

{

return err_code;

}

NRF_LOG_PRINTF("Found Record ID = %d\r\n",record_desc.record_id);

NRF_LOG_PRINTF("Data = ");

 data = (float *) flash_record.p_data;
-------------------------------------

for (uint8_t i=0;i<flash_record.p_header->tl.length_words;i++)

{

NRF_LOG_PRINTF("%f ",data[i]);

}

NRF_LOG_PRINTF("\r\n");

i am getting emty data. please help me how to store float array in FDS.

> [EDIT]:

here is my write function...

static ret_code_t fds_test_write()

{

		#define FILE_ID     0x1111

		#define REC_KEY     0x2223


			fds_record_t        record;

			fds_record_desc_t   record_desc;

			fds_record_chunk_t  record_chunk;

			// Set up data.

				record_chunk.p_data         = m_deadbeef;

	record_chunk.length_words = sizeof(m_deadbeef)/sizeof(m_deadbeef[0][0]);

		// Set up record.

		record.file_id              = FILE_ID;

		record.key              	= REC_KEY;

		record.data.p_chunks       = &record_chunk;

		record.data.num_chunks   = 1;

		ret_code_t ret = fds_record_write(&record_desc, &record);

		if (ret != FDS_SUCCESS)

		{

				return ret;

		}

		 NRF_LOG_PRINTF("Writing Record ID = %d \r\n",record_desc.record_id);

		return NRF_SUCCESS;
}
Parents
  • here is my float data:------

    float m_deadbeef[20][3] = {
    
    		{2.002139,      4.295340,       12.436197,      },
    
    		{2.575441,      4.983300,       12.436197,      },
    
    		{2.804763,      4.753978,       12.206882,      },
    
    		{2.690099,      4.524662,       12.436197,      },
    
    		{3.034079,      4.295340,       11.748239,      },
    
    		{3.263401,      4.066018,       11.977560,      },
    
    		{3.148742,      4.066018,       12.550861,      },
    
    		{2.919421,      3.836702,       13.009499,      },
    
    		{2.804763,      3.722038,       13.124157,      },
    
    		{2.919421,      3.492722,       13.009499,      },
    
    		{3.263401,      3.722038,       12.665519,      },
    
    		{3.492722,      4.409998,       13.582801,      },
    
    		{1.887481,      3.951360,       13.124157,      },
    
    		{2.346119,      4.409998,       12.206882,      },
    
    		{1.658159,      4.180682,       12.436197,      },
    
    		{1.887481,      4.180682,       12.780177,      },
    
    		{2.690099,      3.951360,       12.550861,      },
    
    		{3.263401,      3.722038,       12.321539,      },
    
    		{3.836702,      3.722038,       12.206882,      },
    
    		{3.148742,      3.263401,       12.665519,      },
    };
    
Reply
  • here is my float data:------

    float m_deadbeef[20][3] = {
    
    		{2.002139,      4.295340,       12.436197,      },
    
    		{2.575441,      4.983300,       12.436197,      },
    
    		{2.804763,      4.753978,       12.206882,      },
    
    		{2.690099,      4.524662,       12.436197,      },
    
    		{3.034079,      4.295340,       11.748239,      },
    
    		{3.263401,      4.066018,       11.977560,      },
    
    		{3.148742,      4.066018,       12.550861,      },
    
    		{2.919421,      3.836702,       13.009499,      },
    
    		{2.804763,      3.722038,       13.124157,      },
    
    		{2.919421,      3.492722,       13.009499,      },
    
    		{3.263401,      3.722038,       12.665519,      },
    
    		{3.492722,      4.409998,       13.582801,      },
    
    		{1.887481,      3.951360,       13.124157,      },
    
    		{2.346119,      4.409998,       12.206882,      },
    
    		{1.658159,      4.180682,       12.436197,      },
    
    		{1.887481,      4.180682,       12.780177,      },
    
    		{2.690099,      3.951360,       12.550861,      },
    
    		{3.263401,      3.722038,       12.321539,      },
    
    		{3.836702,      3.722038,       12.206882,      },
    
    		{3.148742,      3.263401,       12.665519,      },
    };
    
Children
No Data
Related