Apps     Components     Interfaces     All Files     Source Tree     source: tos.lib.FS.FileRead.nc

Interface: FileRead

File reading interface, supports sequential reads.

Components providing this interface:
tos.lib.FS.Matchbox
tos.lib.FS.Read

Components requiring this interface:
apps.TestMatchbox.Timing.TimingM
tos.lib.FS.Remote

Commands

Events

Commands - Details

open

result_t open(const char *filename)

open a file for sequential reads.

Parameters:

filename - Name of file to open. Must not be stack allocated.

Returns: SUCCESS: attempt proceeds, opened will be signaled
FAIL: filesystem is busy or another file is open for reading

read

result_t read(void *buffer, filesize_t n)

Read bytes sequentially from open file.

Parameters:

buffer - Target to read into

n - Number of bytes to read

Returns: SUCCESS: attempt proceeds, readDone will be signaled
FAIL: no file was open for reading, or a read is in progress

getRemaining

result_t getRemaining(void)

Return number of bytes remaining in file.
Returns: SUCCESS: attempt proceeds, remaining will be signaled
FAIL: no file was open for reading, or a read is in progress

Events - Details

readDone

result_t readDone(void *buffer, filesize_t nRead, fileresult_t result)

Signaled when a read completes

Parameters:

buffer - Buffer that was passed to read

nRead - Number of bytes actually read , but result will still be FS_OK)

result - FS_OK: read was successful (if end-of-file is reached, nRead will be less than the number of bytes requested)
FS_ERROR_xxx: read failure cause.

Returns: Ignored