Apps     Components     Interfaces     All Files     Source Tree     source: tos.interfaces.LogData.nc

Interface: LogData

This interface is used to provide efficient, byte level logging to a region of memory/flash/etc (the actual region is specified through some other mechanism, e.g., in ByteEEPROM by providing a parameterised LogData interface). Unlike the WriteData interface, the data written via append is only guaranteed to be present in the region once sync has completed. Note: this interface is purposefully restrictive to allow logging to be as fast as possible. Calls to LogData must not be interspersed with calls to WriteData on the same area of memory/flash/etc (ReadData is fine). WriteData can be called after syncDone returns. This interface is currently used by ByteEEPROM
Author: David Gay

Components providing this interface:
tos.platform.mica.ByteEEPROM
tos.platform.mica.ByteEEPROMC
tos.system.BufferedLog

Components requiring this interface:
apps.HighFrequencySampling.Sample
apps.TestEEPROM.ByteSpeed.ETimingM
tos.system.BufferedLog

Commands

Events

Commands - Details

erase

result_t erase(void)

Erase region, reset append pointer to beginning of region
Returns: FAIL if erase request was refused. Otherwise SUCCESS is returned and eraseDone will be signaled.

append

result_t append(uint8_t *data, uint32_t numBytes)

Append bytes to region (erase must be called first)
Returns: FAIL if appends are not allowed (erase failed or sync has been called). If the result is SUCCESS, appendDone will be signaled.

currentOffset

uint32_t currentOffset(void)

Report current append offset.
Returns: the current append offset, or (uint32_t)-1 if appends are not allowed (after sync or before erase)

sync

result_t sync(void)

Ensure all data written by append is committed to flash. Once sync is called, no more appends are allowed.
Returns: FAIL if sync request is refused. If the result is SUCCESS the syncDone event will be signaled.

Events - Details

eraseDone

result_t eraseDone(result_t success)

Report erase completion.

Parameters:

success - FAIL if erase failed, in which case appends are not allowed.

Returns: Ignored.

appendDone

result_t appendDone(uint8_t *data, uint32_t numBytes, result_t success)

Report append completion.

Parameters:

data - Address of data written

numBytesWrite - Number of bytes written

success - SUCCESS if write was successful, FAIL otherwise

Returns: Ignored.

syncDone

result_t syncDone(result_t success)

Report sync completion.

Parameters:

success - FAIL if sync failed, SUCCESS otherwise.

Returns: Ignored.