piconomix-fwlib  0.7.1
Cross-platform embedded library and documentation for 8/16/32-bit microcontrollers
px_log_fs.h : Record-based file system for Serial Flash

Description

Record-based file system for Serial Flash.

File(s):

1. Introduction

px_log_fs is a basic but resilient record-based file system to store log data on Serial Flash, for example Adesto AT45D DataFlash. A file is defined as a collection of fixed-size records that contain the log data. The records can be navigated forwards or backwards to read data, while being able to append new data at the same time. Record writing will stop when the file is full (PX_LOG_FS_CFG_TYPE_LINEAR option) or newest records will overwrite oldest records when the file is full (PX_LOG_FS_CFG_TYPE_CIRCULAR option). Multiple time-stamped files can be created sequentially, but only the oldest file can be deleted.

The maximum number of pages used for each file can be limited with the PX_LOG_FS_CFG_MAX_PAGES option (0 means no limit). The size of each record is configured with PX_LOG_FS_CFG_REC_DATA_SIZE. See 'px_log_fs_cfg_template.h'

First a code example to demonstrate the API, followed by implementation details...

2. Code example

#include <stdio.h>
#include "px_board.h"
#include "px_spi.h"
#include "px_at45d.h"
#include "px_log_fs.h"
// Define record data content
typedef struct
{
int16_t temperature;
} px_log_fs_data_t;
static px_log_fs_data_t px_log_fs_data;
static px_spi_handle_t px_at45d_spi_handle;
int main(void)
{
uint8_t i;
px_log_fs_err_t px_log_fs_err;
// Initialise modules
px_spi_open2(&px_at45d_spi_handle,
PX_SPI_PER_0,
PX_BOARD_SPI_CS_AT45D,
px_at45d_init(&px_at45d_spi_handle);
// Initialise file system
// Set file creation time
time.year = 16;
time.month = 10;
time.day = 24;
time.hour = 12;
time.min = 28;
time.sec = 0;
// Create a new log file
// Populate data
px_log_fs_data.temperature = 160; // 16.0 deg Celsius
// Write 8 records
for(i=0; i<8; i++)
{
// Write record
px_log_fs_record_wr(&px_log_fs_data, sizeof(px_log_fs_data));
// Increment temperature by 1.3 deg
px_log_fs_data.temperature += 13;
}
// Read first record
px_log_fs_err = px_log_fs_record_rd_first(&px_log_fs_data, sizeof(px_log_fs_data));
while(px_log_fs_err == PX_LOG_FS_ERR_NONE)
{
// Display record data
printf("%d\n", px_log_fs_data.temp);
// Read next record
px_log_fs_err = px_log_fs_record_rd_next(&px_log_fs_data, sizeof(px_log_fs_data));
}
}

3. Implementation details

The Serial Flash pages are treated like one big circular buffer. Files are stored sequentially and record writing will stop (or wrap to overwrite oldest records) when the start of the oldest file is reached. This simplified scheme implicitly allows for wear leveling, because each Serial Flash page is erased once per pass through the circular buffer.

The file system leverages a characteristic of Serial Flash. When a page is erased, all the data bits are reset to 1. When writing a byte, bits can be cleared (0), but not reset to 1 again. The following 8-bit marker values are used:

markers.png
8-bit markers

By inspecting the bits, it can be observed that a marker can be changed from FREE to FILE (or RECORD) to BAD, but not the other way around without erasing the whole page.

Each page starts with a page header (px_log_fs_page_header_t) which consists of an 8-bit marker, a 16-bit rolling FILE/RECORD number and an 8-bit CRC. For quick indexing or searching a whole page is used to mark the start of a file (marker = FILE). Thus only the first 4 bytes of each page is read to quickly index the whole file system during px_log_fs_init(). The rolling FILE number is used to figure out which is the oldest file and which is the newest during px_log_fs_init().

page_header.png
Page header structure

After the FILE page, records are stored in RECORD pages. The 16-bit rolling RECORD number (in each page header) is used to figure out which is the oldest record page and which is the newest record page if the PX_LOG_FS_CFG_TYPE_CIRCULAR option is used. Each record (px_log_fs_rec_block_t) contains an 8-bit RECORD marker, the record data (fixed size set with PX_LOG_FS_CFG_REC_DATA_SIZE) and an 8-bit CRC.

record.png
Record structure

A record will not span across pages, so there may be unused space at the end of each page. For example, if a page is 264 bytes and the page header takes up 4 bytes, then there are 260 bytes left over for records. If 4 data bytes are stored in each record, then the total record size is 6 bytes (including overhead). This means that 43 records can be stored in each page and 2 bytes will be unused (260 - 43*6 = 2).

When a file is created (and during writing), the file system ensures that there is always at least one FREE record space available that can be written to. Here is an example to illustrate how the file system with the PX_LOG_FS_CFG_TYPE_LINEAR option works, i.e. record writing will stop when the file system is full.

4. Linear file example (PX_LOG_FS_CFG_TYPE_LINEAR option)

linear01.png
1. File system empty. All Pages (0- 7) are FREE (data bytes set to 0xFF)

This example starts with the file system empty, i.e. all of the pages have been erased and the data bits reset to 1. This means that the 8-bit marker at the start of each page is FREE (0xFF).

linear02.png
2. File 00 created. FILE PAGE 00 written to page 2. Page 3 erased

With an empty file system the first file will start at page 0, but to illustrate the circular wrapping nature of the file system, this file starts at page 2. A file is created and the assigned rolling number is 00. Page 2 is written with a FILE page header and a timestamp. Page 3 is erased to ensure that there is at least one empty record space available that can be written to.

For this example the rolling number is two digits. It starts at 00 and increments up to 99 and wraps back to 00.

linear03.png
3. Page 3 header set to RECORD PAGE 00. Two RECORDS (0 & 1) written to page 3

Two records are written to the open file. A RECORD page header is written first, and then two records to page 3.

linear04.png
4. One RECORD (2) written to page 3 (page is now full). Page 4 erased

One more record is written to page 3 and now the page is full. The file system erases the next page to ensure that there is at least one free record space.

linear05.png
5. File 01 created. FILE PAGE 01 written to page 4. Page 5 erased

Logging to File 00 stops and a new file is created (with rolling number 01). Page 4 is written with a FILE page header and timestamp. Page 5 is erased to ensure that there is at least one free record space available that can be written to.

linear06.png
6. Fifteen RECORDS (0 - 14) written to page 5, 6, 7, 0 & 1. File is full

Fifteen records are now written to File 01. When record 8 is written to page 7, the file system wraps and erase page 0. When record 14 is written, the file system will not erase page 2, because it is a FILE page header and the file is considered to be full.

linear07.png
7. File 00 erased. Page 2 & 3 marker set to BAD (0x00)

To create space in this example, the oldest file (File 00) is now deleted. The first byte of each page (page marker) is set to BAD (0x00).

linear08.png
8. Page 2 erased and one RECORD (15) written to page 2

Another record is written to File 01. The file system erases page 2 and first writes a RECORD page header and then record 15. This demonstrates how the file system reclaims pages that have been marked as BAD (0x00).

5. Circular file example (PX_LOG_FS_CFG_TYPE_CIRCULAR option)

circular01.png
1. File system empty. All Pages (0- 7) are FREE (data bytes set to 0xFF)

This example again starts with the file system empty, i.e. all of the pages have been erased and the data bits reset to 1. This means that the 8-bit marker at the start of each page is FREE (0xFF).

circular02.png
2. File 00 created. FILE PAGE 00 written to page 4. Page 5 erased

With an empty file system the first file will start at page 0, but to illustrate the circular wrapping nature of the file system, this file starts at page 4. A file is created and the rolling number is 00. Page 4 is written with a FILE page header and a timestamp. Page 5 is erased to ensure that there is at least one free record space available that can be written to.

For this example the rolling number is two digits. It starts at 00 and increments up to 99 and wraps back to 00.

circular03.png
3. Eighteen RECORDS (0 - 17) written to page 5,6,7,0,1 & 2. Space available in file

Eighteen records are now written to File 00. When record 8 is written to page 7, the file system wraps and erase page 0. When record 17 is written, the file system erase page 3 to ensure that there is at least one free record space available that can be written to.

circular04.png
4. Three RECORDS (18 - 20) written to page 3. File is full. Page 5 is erased (marker set to FREE) and oldest RECORDS (0 - 2) are deleted

Three more records are written to page 3. When record 20 is written, the file system will not erase page 4, because it is a FILE page header and the file is considered to be full. The file system wraps and erases page 5 (page marker set to FREE). The oldest records (0 - 2) are deleted.

circular05.png
5. Two RECORDS (21 - 22) written to page 5. One FREE record location in page 5

Two records (21 - 22) are written to page 5. There is still one FREE record space in page 5 and that is why page 6 is not erased.

At this stage, it can be observed that the page 6 contains the oldest records (RECORD PAGE 01) and page 5 contains the newest records (RECORD PAGE 07).

circular06.png
6. Lots of records written to the file. Page 3 contains oldest records (297-299)

Lots of records are written to the file. Page 3 (RECORD PAGE 98) contains the oldest records (297-299). Page 2 (RECORD PAGE 04) contains the newest record (315).

6. Finding the start and end using a rolling (wrapping) number

To figure out which page contains the oldest entry (START) and which page contains the newest entry (END), a rolling (or wrapping) number is assigned to each entry. This means that each consecutive entry is labelled with an incrementing number. If the number exceeds the maximum, it starts again at zero (rolls over). For these examples, the rolling number starts at 00 up to 99 and then rolls back to 00.

Each entry's rolling number is compared with the next valid entry's rolling number. The largest difference in the rolling numbers indicates that the END has been found. The next valid entry is per implication the START.

To be exact, modulo unsigned integer arithmetic is used:

Diff = (rolling_number_next - rolling_number) mod 100

Here are a few select test cases to show that it works under various conditions:

start_end_01.png
1. END is at page 5 and START is at page 0 (largest diff is 95)
start_end_02.png
2. END is at page 9 and START is at page 4 (largest diff = 95)
start_end_03.png
3. END is at page 10 and START is at page 12 (largest diff = 86)
start_end_04.png
4. END is at page 14 and START is at page 0 (largest diff = 86)
start_end_05.png
5. END is at page 1 and START is at page 3 (largest diff = 86)
start_end_06.png
6. END is at page 2 and START is at page 4 (largest diff = 86)
start_end_07.png
7. END is at page 5 and START is at page 7 (largest diff = 86)
start_end_08.png
8. END is at page 14 and START is at page 0 (largest diff = 86)

Data Structures

struct  px_log_fs_time_stamp_t
 File creation date and time. More...
 
struct  px_log_fs_file_t
 File info. More...
 

Macros

#define PX_LOG_FS_CFG_PAGE_SIZE   PX_AT45D_PAGE_SIZE
 Page size for file system. More...
 
#define PX_LOG_FS_CFG_PAGE_START   0
 Start page for file system. More...
 
#define PX_LOG_FS_CFG_PAGE_END   (PX_AT45D_PAGES-1)
 End page for file system. More...
 
#define PX_LOG_FS_CFG_REC_DATA_SIZE   13
 Record data size. More...
 
#define PX_LOG_FS_CFG_TYPE   PX_LOG_FS_CFG_TYPE_LINEAR
 Log type. More...
 
#define PX_LOG_FS_CFG_MAX_PAGES   0
 Maximum number of pages allocated to file. 0 means no limit. More...
 

Typedefs

typedef uint16_t px_log_fs_page_t
 Page number size definition. More...
 
typedef uint16_t px_log_fs_offset_t
 Offset in page size definition. More...
 

Enumerations

enum  px_log_fs_err_t {
  PX_LOG_FS_ERR_NONE = 0, PX_LOG_FS_ERR_FILE_DOES_NOT_EXIST, PX_LOG_FS_ERR_FILE_ALREADY_EXISTS, PX_LOG_FS_ERR_FILE_INVALID,
  PX_LOG_FS_ERR_EMPTY, PX_LOG_FS_ERR_FULL, PX_LOG_FS_ERR_WRITE_FAIL, PX_LOG_FS_ERR_NO_FILE,
  PX_LOG_FS_ERR_NO_RECORD
}
 Error codes. More...
 

Functions

px_log_fs_err_t px_log_fs_init (void)
 Initialise log file system. More...
 
px_log_fs_err_t px_log_fs_create (const px_log_fs_time_stamp_t *time_stamp)
 Create a new file. More...
 
size_t px_log_fs_file_attr_data_wr (px_log_fs_offset_t offset, const void *data, size_t nr_of_bytes)
 Write file attribute data. More...
 
size_t px_log_fs_file_attr_data_rd (px_log_fs_offset_t offset, void *data, size_t nr_of_bytes)
 Read file attribute data. More...
 
size_t px_log_fs_file_attr_data_size (void)
 Return the maximum size of attribute data that can be read or written. More...
 
px_log_fs_err_t px_log_fs_file_find_first (px_log_fs_file_t *file)
 Find first (oldest) file. More...
 
px_log_fs_err_t px_log_fs_file_find_last (px_log_fs_file_t *file)
 Find last (newest) file. More...
 
px_log_fs_err_t px_log_fs_file_find_next (px_log_fs_file_t *file)
 Find next (newer) file. More...
 
px_log_fs_err_t px_log_fs_file_find_previous (px_log_fs_file_t *file)
 Find previous (older) file. More...
 
px_log_fs_err_t px_log_fs_open (const px_log_fs_file_t *file)
 Open existing file that has been found using px_log_fs_file_find_first() method. More...
 
px_log_fs_err_t px_log_fs_file_delete (const px_log_fs_file_t *file)
 Delete an existing file that has been found using px_log_fs_file_find_first() method. More...
 
px_log_fs_err_t px_log_fs_record_rd_first (void *data, size_t nr_of_bytes)
 Read first (oldest) record. More...
 
px_log_fs_err_t px_log_fs_record_rd_last (void *data, size_t nr_of_bytes)
 Read last (newest) record. More...
 
px_log_fs_err_t px_log_fs_record_rd_next (void *data, size_t nr_of_bytes)
 Read next (newer) record. More...
 
px_log_fs_err_t px_log_fs_record_rd_previous (void *data, size_t nr_of_bytes)
 Read previous (older) record. More...
 
px_log_fs_err_t px_log_fs_record_wr (const void *data, size_t nr_of_bytes)
 Write a record to the file. More...
 
void px_log_fs_info (void)
 Report log file system info. More...
 

Log type option selected in "px_log_fs_cfg.h"

#define PX_LOG_FS_CFG_TYPE_LINEAR   0
 Linear : Record writing will stop when file is full. More...
 
#define PX_LOG_FS_CFG_TYPE_CIRCULAR   1
 Circular : Newest records will overwrite oldest records when file is full. More...
 

Data Structure Documentation

◆ px_log_fs_time_stamp_t

struct px_log_fs_time_stamp_t

File creation date and time.

Definition at line 350 of file px_log_fs.h.

Data Fields
uint8_t year Years: 0 to 99 (2000 - 2099)
uint8_t month Months: 1 to 12.
uint8_t day Days: 1 to 31 (depending on month)
uint8_t hour Hours: 0 to 23.
uint8_t min Minutes: 0 to 59.
uint8_t sec Seconds: 0 to 59.

◆ px_log_fs_file_t

struct px_log_fs_file_t

File info.

Definition at line 361 of file px_log_fs.h.

Data Fields
px_log_fs_page_t start_page File start page.
px_log_fs_time_stamp_t time_stamp File creation time stamp (date and time)

Macro Definition Documentation

◆ PX_LOG_FS_CFG_TYPE_LINEAR

#define PX_LOG_FS_CFG_TYPE_LINEAR   0

Linear : Record writing will stop when file is full.

Definition at line 323 of file px_log_fs.h.

◆ PX_LOG_FS_CFG_TYPE_CIRCULAR

#define PX_LOG_FS_CFG_TYPE_CIRCULAR   1

Circular : Newest records will overwrite oldest records when file is full.

Definition at line 325 of file px_log_fs.h.

◆ PX_LOG_FS_CFG_PAGE_SIZE

#define PX_LOG_FS_CFG_PAGE_SIZE   PX_AT45D_PAGE_SIZE

Page size for file system.

Definition at line 49 of file px_log_fs_cfg_template.h.

◆ PX_LOG_FS_CFG_PAGE_START

#define PX_LOG_FS_CFG_PAGE_START   0

Start page for file system.

Definition at line 52 of file px_log_fs_cfg_template.h.

◆ PX_LOG_FS_CFG_PAGE_END

#define PX_LOG_FS_CFG_PAGE_END   (PX_AT45D_PAGES-1)

End page for file system.

Definition at line 55 of file px_log_fs_cfg_template.h.

◆ PX_LOG_FS_CFG_REC_DATA_SIZE

#define PX_LOG_FS_CFG_REC_DATA_SIZE   13

Record data size.

Definition at line 58 of file px_log_fs_cfg_template.h.

◆ PX_LOG_FS_CFG_TYPE

#define PX_LOG_FS_CFG_TYPE   PX_LOG_FS_CFG_TYPE_LINEAR

Log type.

Definition at line 61 of file px_log_fs_cfg_template.h.

◆ PX_LOG_FS_CFG_MAX_PAGES

#define PX_LOG_FS_CFG_MAX_PAGES   0

Maximum number of pages allocated to file. 0 means no limit.

Definition at line 64 of file px_log_fs_cfg_template.h.

Typedef Documentation

◆ px_log_fs_page_t

typedef uint16_t px_log_fs_page_t

Page number size definition.

Definition at line 344 of file px_log_fs.h.

◆ px_log_fs_offset_t

typedef uint16_t px_log_fs_offset_t

Offset in page size definition.

Definition at line 347 of file px_log_fs.h.

Enumeration Type Documentation

◆ px_log_fs_err_t

Error codes.

Enumerator
PX_LOG_FS_ERR_NONE 

No error.

PX_LOG_FS_ERR_FILE_DOES_NOT_EXIST 

File does not exist.

PX_LOG_FS_ERR_FILE_ALREADY_EXISTS 

File already exists.

PX_LOG_FS_ERR_FILE_INVALID 

Invalid file specified.

PX_LOG_FS_ERR_EMPTY 

File is empty.

PX_LOG_FS_ERR_FULL 

File is full.

PX_LOG_FS_ERR_WRITE_FAIL 

Failed to write.

PX_LOG_FS_ERR_NO_FILE 

No file found.

PX_LOG_FS_ERR_NO_RECORD 

No record found.

Definition at line 330 of file px_log_fs.h.

Function Documentation

◆ px_log_fs_init()

px_log_fs_err_t px_log_fs_init ( void  )

Initialise log file system.

Return values
PX_LOG_FS_ERR_NONEFile system was succesfully indexed

Definition at line 821 of file px_log_fs.c.

◆ px_log_fs_create()

px_log_fs_err_t px_log_fs_create ( const px_log_fs_time_stamp_t time_stamp)

Create a new file.

Parameters
time_stampUser supplied time stamp (date and time).
Return values
PX_LOG_FS_ERR_NONEFile succesfully created.
PX_LOG_FS_ERR_FULLFile sytem is full (at least 2 free pages are required for a new file).

Definition at line 926 of file px_log_fs.c.

◆ px_log_fs_file_attr_data_wr()

size_t px_log_fs_file_attr_data_wr ( px_log_fs_offset_t  offset,
const void *  data,
size_t  nr_of_bytes 
)

Write file attribute data.

A whole page is allocated to mark the start of a file, but only a few bytes are used. The rest of the page data can be used to store once-off, ancillary data. The content is reset to 0xff's when the file is created. Bits can be cleared (0), but not set (1).

Call px_log_fs_file_attr_data_size() to find out the maximum number of bytes that can be written.

Parameters
offsetOffset (0 to px_log_fs_file_attr_data_size()-1)
dataPointer to a buffer containing data to be written
nr_of_bytesNumber of bytes to write
Returns
size_t Number of bytes actually written

Definition at line 1050 of file px_log_fs.c.

◆ px_log_fs_file_attr_data_rd()

size_t px_log_fs_file_attr_data_rd ( px_log_fs_offset_t  offset,
void *  data,
size_t  nr_of_bytes 
)

Read file attribute data.

See px_log_fs_file_attr_data_wr().

Parameters
offsetOffset (0 to px_log_fs_file_attr_data_size()-1)
dataPointer to a buffer where the received data must be stored
nr_of_bytesNumber of bytes to read
Returns
size_t Number of bytes actually written

Definition at line 1075 of file px_log_fs.c.

◆ px_log_fs_file_attr_data_size()

size_t px_log_fs_file_attr_data_size ( void  )

Return the maximum size of attribute data that can be read or written.

Returns
size_t Size (in bytes) of attribute data

Definition at line 1100 of file px_log_fs.c.

◆ px_log_fs_file_find_first()

px_log_fs_err_t px_log_fs_file_find_first ( px_log_fs_file_t file)

Find first (oldest) file.

Parameters
filePointer to buffer that will contain file data (if found)
Return values
PX_LOG_FS_ERR_NONEValid file found
PX_LOG_FS_ERR_NO_FILENo files in file system
PX_LOG_FS_ERR_FILE_INVALIDFile system corrupt. File page was valid during px_log_fs_init().

Definition at line 1105 of file px_log_fs.c.

◆ px_log_fs_file_find_last()

px_log_fs_err_t px_log_fs_file_find_last ( px_log_fs_file_t file)

Find last (newest) file.

Parameters
filePointer to buffer that will contain file data (if found)
Return values
PX_LOG_FS_ERR_NONEValid file found
PX_LOG_FS_ERR_NO_FILENo files in file system
PX_LOG_FS_ERR_FILE_INVALIDFile system corrupt. File page was valid during px_log_fs_init().

Definition at line 1128 of file px_log_fs.c.

◆ px_log_fs_file_find_next()

px_log_fs_err_t px_log_fs_file_find_next ( px_log_fs_file_t file)

Find next (newer) file.

Parameters
filePointer to buffer that will contain file data (if found)
Return values
PX_LOG_FS_ERR_NONEValid file found
PX_LOG_FS_ERR_NO_FILENo more files

Definition at line 1150 of file px_log_fs.c.

◆ px_log_fs_file_find_previous()

px_log_fs_err_t px_log_fs_file_find_previous ( px_log_fs_file_t file)

Find previous (older) file.

Parameters
filePointer to buffer that will contain file data (if found)
Return values
PX_LOG_FS_ERR_NONEValid file found
PX_LOG_FS_ERR_NO_FILENo more files

Definition at line 1192 of file px_log_fs.c.

◆ px_log_fs_open()

px_log_fs_err_t px_log_fs_open ( const px_log_fs_file_t file)

Open existing file that has been found using px_log_fs_file_find_first() method.

Parameters
fileFile data of valid file
Return values
PX_LOG_FS_ERR_NONEFile opened
PX_LOG_FS_ERR_FILE_INVALIDFile system corrupt

Definition at line 1234 of file px_log_fs.c.

◆ px_log_fs_file_delete()

px_log_fs_err_t px_log_fs_file_delete ( const px_log_fs_file_t file)

Delete an existing file that has been found using px_log_fs_file_find_first() method.

Only the first (oldest) file may be deleted to avoid fragmentation, which is not catered for by this file system.

Parameters
fileFile data of valid file
Return values
PX_LOG_FS_ERR_NONEFile was succesfully opened
PX_LOG_FS_ERR_FILE_INVALIDNot the oldest file, or file page is invalid

Definition at line 1485 of file px_log_fs.c.

◆ px_log_fs_record_rd_first()

px_log_fs_err_t px_log_fs_record_rd_first ( void *  data,
size_t  nr_of_bytes 
)

Read first (oldest) record.

Parameters
dataPointer to buffer where record data must be copied to
nr_of_bytesNumber of bytes to copy from record
Return values
PX_LOG_FS_ERR_NONEValid record data found and copied into structure
PX_LOG_FS_ERR_NO_RECORDNo record found

Definition at line 1550 of file px_log_fs.c.

◆ px_log_fs_record_rd_last()

px_log_fs_err_t px_log_fs_record_rd_last ( void *  data,
size_t  nr_of_bytes 
)

Read last (newest) record.

Parameters
dataPointer to buffer where record data must be copied to
nr_of_bytesNumber of bytes to copy from record
Return values
PX_LOG_FS_ERR_NONEValid record data found and copied into structure
PX_LOG_FS_ERR_NO_RECORDNo record found

Definition at line 1566 of file px_log_fs.c.

◆ px_log_fs_record_rd_next()

px_log_fs_err_t px_log_fs_record_rd_next ( void *  data,
size_t  nr_of_bytes 
)

Read next (newer) record.

Parameters
dataPointer to buffer where record data must be copied to
nr_of_bytesNumber of bytes to copy from record
Return values
PX_LOG_FS_ERR_NONEValid record data found and copied into structure
PX_LOG_FS_ERR_NO_RECORDNo record found

Definition at line 1582 of file px_log_fs.c.

◆ px_log_fs_record_rd_previous()

px_log_fs_err_t px_log_fs_record_rd_previous ( void *  data,
size_t  nr_of_bytes 
)

Read previous (older) record.

Parameters
dataPointer to buffer where record data must be copied to
nr_of_bytesNumber of bytes to copy from record
Return values
PX_LOG_FS_ERR_NONEValid record data found and copied into structure
PX_LOG_FS_ERR_NO_RECORDNo record found

Definition at line 1687 of file px_log_fs.c.

◆ px_log_fs_record_wr()

px_log_fs_err_t px_log_fs_record_wr ( const void *  data,
size_t  nr_of_bytes 
)

Write a record to the file.

A new record is appended to the end of the list of records. The maximum number of bytes that can be stored in the record is specified by PX_LOG_FS_CFG_DATA_SIZE.

Parameters
dataPointer to buffer containing data that must be stored in the record
nr_of_bytesNumber of bytes that must be written
Return values
PX_LOG_FS_ERR_NONESuccess
PX_LOG_FS_ERR_FULLFile (or file system) is full
PX_LOG_FS_ERR_WRITE_FAILFailed to write record (verify failed)

Definition at line 1767 of file px_log_fs.c.

◆ px_log_fs_info()

void px_log_fs_info ( void  )

Report log file system info.

Definition at line 1958 of file px_log_fs.c.