How long to keep FDS file open and fds_record_desc_t

mokincha gravatar image

asked 2017-03-20 23:56:05 +0100

In our code we use NV storage for system settings and calibration data.

I'm trying to understand when to open/close files and which structs to keep bwtween reads/writes. I've looked at the GIT example code, but it only briefly reads or write files.

For our system settings, which change regularly, should we open the file on start-up and keep it open? Or just open, read/write, and then immediately close the file? If we should keep it open, which structs (fds_record_desc_t, p_flash_record, etc.) need to be kept between accesses?

Second, the calibration data file is rarely written but read often. The total required calibration data is a known size, and will be kept in multiple records. Why would we want to use fds_reserve()? Again, should the file be kept open or opened and closed only as required?

edit retag flag offensive close delete report spam

1 answer

Sort by » oldest newest most voted
Kristin gravatar image

answered 2017-03-22 08:55:54 +0100

In FDS, when reading data, the data is never copied from flash, but it is read directly from flash. The purpose of fds_record_open() is to make sure that you will be able to read the data, without the reading operation being disturbed by the garbage collection operation. The garbage collection operation will erase pages and move records around. Therefore, read operation and garbage collection cannot happen at the same time. And purpose of fds_record_open() and fds_record_close() is to tell FDS is garbage collection can be performed/is an allowed operation or not.

I would therefore recommend you to only have a record "open" when needed.

I cannot see any specific reason to use fds_reserve().

edit flag offensive delete publish link more



As a suggestion, it would be useful to be able to query the number of writes in the queue. Something like uint8_t fds_get_queue_entries( void ). The only way to know if the queue is full is to try to write and see if it fails. If a function has queued a lot of writes, it would be useful to know when the queue is full (and it should wait) or is empty (and the function can exit). This can be sort-of achieved with callbacks, but it's cumbersome.

mokincha ( 2017-03-24 05:50:45 +0100 )editconvert to answer

The function fds_stat() can give you some information? But not information on when the queue is full.. I will report this feature request internally.

Kristin ( 2017-03-27 13:02:46 +0100 )editconvert to answer

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer. Do not ask a new question or reply to an answer here.

[hide preview]

Question Tools



Asked: 2017-03-20 23:56:05 +0100

Seen: 165 times

Last updated: mars 22 '17

Related questions