Pointer

class brainstem.stem.Pointer(module, index)[source]

Access the reflex scratchpad from a host computer.

The Pointers access the pad which is a shared memory area on a BrainStem module. The interface allows the use of the brainstem scratchpad from the host, and provides a mechanism for allowing the host application and brainstem relexes to communicate.

The Pointer allows access to the pad in a similar manner as a file pointer accesses the underlying file. The cursor position can be set via setOffset. A read of a character short or int can be made from that cursor position. In addition the mode of the pointer can be set so that the cursor position automatically increments or set so that it does not this allows for multiple reads of the same pad value, or reads of multi-record values, via and incrementing pointer.

Useful Constants:
  • POINTER_MODE_STATIC (0)
  • POINTER_MODE_INCREMENT (1)
getChar()[source]

Get the value of the pad at the current cursor position.

If the mode is increment this read will increment the cursor by 1 byte.

Returns:
Result object, containing NO_ERROR and the value
or a non zero Error code.
Return type:Result
getInt()[source]

Get the value of the pad at the current cursor position.

If the mode is increment this read will increment the cursor by 4 bytes.

Returns:
Result object, containing NO_ERROR and the value
or a non zero Error code.
Return type:Result
getMode()[source]

Get the pointer offset for this pointer.

Returns:
Result object, containing NO_ERROR and the current mode
or a non zero Error code.
Return type:Result
getOffset()[source]

Get the pointer offset for this pointer.

Returns:
Result object, containing NO_ERROR and the current offset
or a non zero Error code.
Return type:Result
getShort()[source]

Get the value of the pad at the current cursor position.

If the mode is increment this read will increment the cursor by 2 bytes.

Returns:
Result object, containing NO_ERROR and the value
or a non zero Error code.
Return type:Result
getTransferStore()[source]

Get the open slot handle for this pointer.

Returns:
Result object, containing NO_ERROR and the handle
or a non zero Error code.
Return type:Result
setChar(charVal)[source]

Set a value at the current cursor position within the pad.

If the mode is increment this write will increment the cursor by 1 byte.

Param:
charVal (char): The value to set into the pad at the current
pointer position.
Returns:Return NO_ERROR on success, or one of the common sets of return error codes on failure.
Return type:Result.error
setInt(intVal)[source]

Set a value at the current cursor position within the pad.

If the mode is increment this write will increment the cursor by 4 bytes.

Param:
short (short): The value to set into the pad at the current
pointer position.
Returns:Return NO_ERROR on success, or one of the common sets of return error codes on failure.
Return type:Result.error
setMode(mode)[source]

Set the pointer offset for this pointer.

Param:
mode (char): The mode. One of POINTER_MODE_STATIC or POINTER_MODE_INCREMENT
Returns:Return NO_ERROR on success, or one of the common sets of return error codes on failure.
Return type:Result.error
setOffset(offset)[source]

Set the pointer offset for this pointer.

Param:
offset (char): The byte offset within the pad (0 - 255).
Returns:Return NO_ERROR on success, or one of the common sets of return error codes on failure.
Return type:Result.error
setShort(shortVal)[source]

Set a value at the current cursor position within the pad.

If the mode is increment this write will increment the cursor by 2 bytes.

Param:
shortVal (short): The value to set into the pad at the current
pointer position.
Returns:Return NO_ERROR on success, or one of the common sets of return error codes on failure.
Return type:Result.error
setTransferStore(handle)[source]

Set store slot handle for the pad to store and store to pad transfer.

Param:
handle (char): The handle. Open slot handle id.
Returns:Return NO_ERROR on success, or one of the common sets of return error codes on failure.
Return type:Result.error
transferToStore(length)[source]

Transfer length bytes from the pad cursor position into the open store handle.

If the mode is increment the transfer will increment the cursor by length bytes.

Returns:Return NO_ERROR on success, or one of the common sets of return error codes on failure.
Return type:Result.error
transterFromStore(length)[source]

Transfer length bytes from the open store handle to the cursor position in the pad.

If the mode is increment the transfer will increment the cursor by length bytes.

Returns:Return NO_ERROR on success, or one of the common sets of return error codes on failure.
Return type:Result.error