Store

class brainstem.entity.Store(module, index)[source]

StoreClass: The store provides a flat file system on modules that have storage capacity. Files are referred to as slots and they have simple zero-based numbers for access. Store slots can be used for generalized storage and commonly contain compiled reflex code (files ending in .map) or templates used by the system. Slots simply contain bytes with no expected organization but the code or use of the slot may impose a structure. Stores have fixed indices based on type. Not every module contains a store of each type. Consult the module datasheet for details on which specific stores are implemented, if any, and the capacities of implemented stores.

getSlotCapacity(slot)[source]

Get the slot capacity. Returns the Capacity of the slot, i.e. The number of bytes it can hold. The slot capacity.

Parameters:

slot (const unsigned char) – The slot number.

Returns:

Result object containing the requested value when the results error is set to NO_ERROR(0)

Return type:

Result

getSlotLocked(slot)[source]

Gets the current lock state of the slot Allows for write protection on a slot. Variable to be filed with the locked state.

Parameters:

slot (const unsigned char) – The slot number

Returns:

Result object containing the requested value when the results error is set to NO_ERROR(0)

Return type:

Result

getSlotSize(slot)[source]

Get the slot size. The slot size represents the size of the data currently filling the slot in bytes. The slot size.

Parameters:

slot (const unsigned char) – The slot number.

Returns:

Result object containing the requested value when the results error is set to NO_ERROR(0)

Return type:

Result

getSlotState(slot)[source]

Get slot state. true: enabled, false: disabled.

Parameters:

slot (const unsigned char) – The slot number.

Returns:

Result object containing the requested value when the results error is set to NO_ERROR(0)

Return type:

Result

loadSlot(slot, buffer)[source]

Load the slot.

Parameters:

slot (const unsigned char) – The slot number.

Returns:

An error result from the list of defined error codes in brainstem.result

Return type:

unsigned byte

setSlotLocked(slot, lock)[source]

Sets the locked state of the slot Allows for write protection on a slot.

Parameters:
  • slot (const unsigned char) – The slot number

  • lock (const unsigned char) – state to be set.

Returns:

An error result from the list of defined error codes in brainstem.result

Return type:

unsigned byte

slotDisable(slot)[source]

Disable slot.

Parameters:

slot (const unsigned char) – The slot number.

Returns:

An error result from the list of defined error codes in brainstem.result

Return type:

unsigned byte

slotEnable(slot)[source]

Enable slot.

Parameters:

slot (const unsigned char) – The slot number.

Returns:

An error result from the list of defined error codes in brainstem.result

Return type:

unsigned byte

unloadSlot(slot, buffer_length=65536)[source]

Unload the slot data. Length of data that was unloaded. Unloaded length will never be larger than dataLength.

Parameters:
  • slot (const unsigned char) – The slot number.

  • buffer_length

    • The length of pData buffer in bytes. This is the maximum number of bytes that should be unloaded.

Returns:

Result object containing the requested value when the results error is set to NO_ERROR(0)

Return type:

Result