simple FS  v0.1.0
Functions | Variables
SFS_User_API

high level API to File System More...

Collaboration diagram for SFS_User_API:

Functions

void FS_init (void *hw_obj1, void *hw_obj2, uint16_t hw_obj3)
 Init the sensorFS filesystem.
 
uint8_t FS_create_file ()
 Begin file creation procedure. More...
 
SimpleFS_tFS_open_file (uint8_t id_file)
 Try open to file with given ID. More...
 
SimpleFS_tFS_open_last_file (void)
 Open last file on sensorFS. More...
 
FS_state FS_write_preamble (void)
 Write preamble aprt in sensorFS, if not exists. More...
 
uint8_t FS_num_files (void)
 Return number of files, that is stored in internal info structure. More...
 
uint8_t FS_detect_num_files (void)
 Return number of files. More...
 
FS_state FS_commit_file_header (void)
 Finish write information about created file. More...
 
uint8_t FS_is_empty (void)
 Check, that sensorFS/FLASH is empty. More...
 
SensorInterface_tFS_sensor_driver (uint8_t sensor_part)
 Return driver for attached sensor. More...
 
FS_state file_add_sensor (uint8_t index, uint8_t index_in_driver, SensorInterface_t *sensor)
 Add new sensor to created file. More...
 
uint8_t file_get_num_parts (SimpleFS_t *fs)
 Return number parts of opened file. More...
 
uint32_t file_data_row_begin (SimpleFS_t *fs)
 Initialize internal data structures for new data record. More...
 
FS_state file_store_data (SimpleFS_t *fs, uint8_t index, SensorValue_t *value)
 Prepare measured value to file buffer. More...
 
void file_data_row_commit (SimpleFS_t *fs)
 Write prepared measured values (by file_store_data} function) to FLASH. More...
 
uint16_t file_record_length (SimpleFS_t *fileP)
 Return length of record. More...
 
RecordDescriptor_t file_column_format (SimpleFS_t *fileP, uint8_t index_part)
 Return format of i-th sensor inf datafile. More...
 
uint32_t file_size (SimpleFS_t *fs)
 Return file size in Bytes. More...
 
void file_data_prepare (void)
 Start value measure on all sensors. More...
 
void file_dump_memory (void)
 

Variables

SimpleFS_t sensorFS
 Internal representation of opened file.
 
FS_Header_t fsInfo
 
SensorInterface_tSensorDrivers [NUM_DRIVERS]
 

Detailed Description

high level API to File System

Function Documentation

◆ file_add_sensor()

FS_state file_add_sensor ( uint8_t  index,
uint8_t  index_in_driver,
SensorInterface_t sensor 
)

Add new sensor to created file.

Parameters
indexglobal index of sensor. This value have to be increased, when is added new sensor.
index_in_driverindex of sensor in used driver. Every driver count their sensors from 0
sensordriver dor sensors.
Returns
state: STATE_OK / STATE_ERR
Note
: no write to MEM is performed. Only data preprading.

◆ file_column_format()

RecordDescriptor_t file_column_format ( SimpleFS_t fileP,
uint8_t  index_part 
)

Return format of i-th sensor inf datafile.

Parameters
filePpointer to file
index_partindex of sensor part.
Returns
Format of desired sensor.

◆ file_data_prepare()

void file_data_prepare ( void  )

Start value measure on all sensors.

Calling this function is unnecessary when external sensors as a data source are used. The automatic call of dataMeasure() on all existing sensor is executed, in this function.

◆ file_data_row_begin()

uint32_t file_data_row_begin ( SimpleFS_t fs)

Initialize internal data structures for new data record.

Parameters
fspointer to open file
Returns
address of first free place in opened file

◆ file_data_row_commit()

void file_data_row_commit ( SimpleFS_t fs)

Write prepared measured values (by file_store_data} function) to FLASH.

Parameters
fspointer to open file

◆ file_get_num_parts()

uint8_t file_get_num_parts ( SimpleFS_t fs)

Return number parts of opened file.

Parameters
fspointer to open file
Returns
number parts in data area/number of sensors in data record in file.

◆ file_record_length()

uint16_t file_record_length ( SimpleFS_t fileP)

Return length of record.

Parameters
filePpointer to open file
Returns
number of bytes for data record.

◆ file_size()

uint32_t file_size ( SimpleFS_t fs)

Return file size in Bytes.

Parameters
fspointer to open file
Returns
Number of bytes.
Here is the call graph for this function:

◆ file_store_data()

FS_state file_store_data ( SimpleFS_t fs,
uint8_t  index,
SensorValue_t value 
)

Prepare measured value to file buffer.

The new file record have to be initialized by file_data_row_begin. Values are written to buffer. No write is performed. After add all values, the file_data_row_commit have to be called.

See also
file_data_row_commit()
Parameters
fspointer to open file.
indexindex of sensor - as was added.
valuemeasured value
Returns
STATE_OK success, else STATE_ERR.
Here is the call graph for this function:

◆ FS_commit_file_header()

FS_state FS_commit_file_header ( void  )

Finish write information about created file.

After this operation, no sensors van be added to file.

Returns
state: STATE_OK
Here is the call graph for this function:

◆ FS_create_file()

uint8_t FS_create_file ( )

Begin file creation procedure.

No write to FLASH is perform. Only initialize internal structures. file_name will be generated automatically according FLASH ID

Returns
unique ID of file. ID can be 1..MAX_FILES (22)

◆ FS_detect_num_files()

uint8_t FS_detect_num_files ( void  )

Return number of files.

Information is from FLASH memory (HW access is performed).

Returns
Number of files
Here is the call graph for this function:

◆ FS_is_empty()

uint8_t FS_is_empty ( void  )

Check, that sensorFS/FLASH is empty.

Check only preamble for valid data.

Returns
1 - is empty, 0 - not empty

◆ FS_num_files()

uint8_t FS_num_files ( void  )

Return number of files, that is stored in internal info structure.

No HW access is performed.

Returns
Number of files

◆ FS_open_file()

SimpleFS_t * FS_open_file ( uint8_t  id_file)

Try open to file with given ID.

Parameters
id_fileID of file. Valid ID is from 1 to MAXIMUM_FS_FILES (31)
Returns
pointer to open file or NULL

◆ FS_open_last_file()

SimpleFS_t * FS_open_last_file ( void  )

Open last file on sensorFS.

Returns
Pointer to File, or NULL.

◆ FS_sensor_driver()

SensorInterface_t * FS_sensor_driver ( uint8_t  sensor_part)

Return driver for attached sensor.

Parameters
sensor_part
Returns
pointer to driver for specific sensor.

◆ FS_write_preamble()

FS_state FS_write_preamble ( void  )

Write preamble aprt in sensorFS, if not exists.

Returns
STATE_OK - if was writed, STATE_ERR - if preamble already exists.
Here is the call graph for this function: