Store Entity

API Documentation: [cpp] [python] [.NET] [LabVIEW]

Every BrainStem module has one or more stores. Stores are the BrainStem equivalent of a filesystem. Stores are broken up into a number of slots, each of which can be thought of as a file. A Store generally represents a specific type of storage. Flash or internal, RAM, or SD if the BrainStem includes an SD slot. The most common usage of slots and stores is for the storage of reflex code that will run on the BrainStem module. Additionally Bulk capture of Analog data can write to a slot within a store. Slots within the internal store can be set up as boot slots by setting the appropriate slot number in the system configuration. See the :doc:` System <system>` entity for more information about setting a boot slot.

The number and type of stores is Model specific. Details about the number of slots per store, and available stores can be found in the data sheets for specific models.

There are a number of commands for manipulating stores, which are detailed below. Many of the store commands are only accessible from host API’s and UI applications, however commands relating to enabling reflex files in slots are accessible from the reflex language.

Get Slot State (Get)

store [ index ] . getSlotState <= (unsigned char) state

For slots which hold reflexes, this read only command returns whether the slot is currently enabled or not. 1 is enabled 0 is disabled. This command can be called from a reflex.

Load Slot (Write)

store [ index ] . loadSlot => (slot, byte buffer, buffer length)

This command writes a data buffer into a slot for the given store. It is only available from host side API’s.

Unload Slot (Read)

store [ index ] . unloadSlot <= (slot, byte buffer, max buffer size, length read)
This command reads the slot in the given store into the byte buffer. The length

will never be more than the max buffer size given, but may be less if the slot contents were shorter than max buffer length.

Slot Enable (Set)

store [ index ] . slotEnable => (unsigned char) slot

This command enables the reflex file in the given store and slot. This command is accessible from the reflex language.

Slot Disable (Set)

store [ index ] . slotDisable => (unsigned char) slot

This command disables the reflex file in the given store and slot. This command is accessible from the reflex language.

Slot Capacity (Get)

store [ index ] . slotCapacity (unsigned char) slot  <= (unsigned short) capacity

This command gets the maximum capacity of the given slot for the store. This command is accessible from the reflex language.

Slot Size (Get)

store [ index ] . slotSize (unsigned char) slot <= (unsigned short) size

This command gets the current size of the data in the given slot for the store. This can be the size in bytes of the reflex byte code file, or the data size for a bulk capture.

Code Examples

C++

// All commands return aErr values when errors are encountered and aErrNone on
// success.

stem.store[0].getSlotState(3, state); // gets the state of slot 3 in the internal store.
stem.store[0].loadSlot(3, buffer, length); // loads the data in buffer.
stem.store[1].unloadSlot(0, buffer, 300, length); // unloads at most 300 bytes from the 1st RAM slot.
stem.store[0].enableSlot(1);
stem.store[0].disableSlot(1);
stem.store[0].getSlotCapacity(1, size); // gets the max size of the slot.
Stem.store[0].getSlotSize(1, size); // gets the current size of the data in the slot.

Reflex

stem.store[0].getSlotState(3, state);
stem.store[0].enableSlot(3);
stem.store[0].disableSlot(3);
stem.store[0].getCapacity(1, capacity);
stem.store[0].getSize(1, size);

Python

res = stem.store[0].getSlotState(3) #res.value is the state of slot 3 in the internal store
stem.store[0].loadSlot(3, buffer, length) # loads length bytes from buffer to slot 3
res = stem.store[1].unloadSlot(0) # res.value is a tuple of (str|bytes|int) of the data in slot 0 and the length
stem.store[0].enableSlot(3)
stem.store[0].disableSlot(3)
res = stem.store[0].getCapacity(1) #res.value is the max size of the slot
res = stem.store[0].getSize(1) #res.value is the current size of the data in slot 1