Store

See the Store Entity for generic information.

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

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.

Parameters:

slot (unsigned char) – The slot number.

Returns:

Object containing error code and returned value on success.
errorunsigned byte

An error result from the list of defined error codes

valueunsigned int

The slot capacity.

Return type:

brainstem.result.Result

getSlotLocked(slot)[source]

Gets the current lock state of the slot Allows for write protection on a slot.

Parameters:

slot (unsigned char) – The slot number

Returns:

Object containing error code and returned value on success.
errorunsigned byte

An error result from the list of defined error codes

valuebool

Variable to be filed with the locked state.

Return type:

brainstem.result.Result

getSlotSize(slot)[source]

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

Parameters:

slot (unsigned char) – The slot number.

Returns:

Object containing error code and returned value on success.
errorunsigned byte

An error result from the list of defined error codes

valueunsigned int

The slot size.

Return type:

brainstem.result.Result

getSlotState(slot)[source]

Get slot state.

Parameters:

slot (unsigned char) – The slot number.

Returns:

Object containing error code and returned value on success.
errorunsigned byte

An error result from the list of defined error codes

valuebool

true: enabled, false: disabled.

Return type:

brainstem.result.Result

loadSlot(slot, buffer)[source]

Load the slot.

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

  • buffer (unsigned char) – The data.

Returns:

An error result from the list of defined error codes in brainstem.result.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 (unsigned char) – The slot number

  • lock (bool) – state to be set.

Returns:

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

Return type:

unsigned byte

slotDisable(slot)[source]

Disable slot.

Parameters:

slot (unsigned char) – The slot number.

Returns:

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

Return type:

unsigned byte

slotEnable(slot)[source]

Enable slot.

Parameters:

slot (unsigned char) – The slot number.

Returns:

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

Return type:

unsigned byte

unloadSlot(slot, buffer_length=65536)[source]

Unload the slot data.

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

  • buffer_length (unsigned int) – The length of buffer buffer in bytes. This is the maximum number of bytes that should be unloaded.

Returns:

Object containing error code and returned value on success.
errorunsigned byte

An error result from the list of defined error codes

valuelist(unsigned char)

Byte array that the unloaded data will be placed into.

Return type:

brainstem.result.Result