C++ API Reference

Welcome to the BrainStem C++ API reference documentation. This documentation covers the c++ Acroname BrainStem library. This reference assumes that you understand the BrainStem system. If you would like to get started using BrainStem, please see the following sections of the Reference documentation.

The Getting started guide is particularly useful for learning how to use the application tools we provide to communicate with your hardware.


Errors

group aErrors

Unified list of Error codes for BrainStem module Interation.

aError.h provides a unified list of error codes. These error codes apply accross all API’s. Library functions will return one of these error codes when appropriate.

Classes

class Link

The Link class provides an interface to a BrainStem link. The link is used to create interfaces to modules on a BrainStem network. The link represents a connection to the BrainStem network from a host computer. The link is always associated with a transport (e.g.: USB, Ethernet, etc.) and a link module, but there are several ways to make this association.

  1. The link can be fully specified with a transport and module serial number
  2. The link can be created by searching a transport and connecting to the first module found.

Calling connect on a link will start a connection to the module based on The link specification. Calling disconnect will disconnect the link from the the current connection.

class Module

The Module class provides a generic interface to a BrainStem hardware module. The Module class is the parent class for all BrainStem modules. Each module inherits from Module and implements its hardware specific features.

class EntityClass

Subclassed by Acroname::BrainStem::AnalogClass, Acroname::BrainStem::AppClass, Acroname::BrainStem::ClockClass, Acroname::BrainStem::DigitalClass, Acroname::BrainStem::I2CClass, Acroname::BrainStem::MuxClass, Acroname::BrainStem::PointerClass, Acroname::BrainStem::RailClass, Acroname::BrainStem::RCServoClass, Acroname::BrainStem::RelayClass, Acroname::BrainStem::SignalClass, Acroname::BrainStem::StoreClass, Acroname::BrainStem::SystemClass, Acroname::BrainStem::TemperatureClass, Acroname::BrainStem::TimerClass, Acroname::BrainStem::UARTClass, Acroname::BrainStem::USBClass

class AnalogClass : public Acroname::BrainStem::EntityClass

The AnalogClass is the interface to analog entities on BrainStem modules. Analog entities may be configured as a input or output depending on hardware capabilities. Some modules are capable of providing actual voltage readings, while other simply return the raw analog-to-digital converter (ADC) output value. The resolution of the voltage or number of useful bits is also hardware dependent.

class AppClass : public Acroname::BrainStem::EntityClass

The AppClass is used to send a cmAPP packet to the BrainStem network. These commands are used for either host-to-stem or stem-to-stem interactions. BrainStem modules can implement a reflex origin to complete an action when a cmdAPP packet is addressed to the module.

class ClockClass : public Acroname::BrainStem::EntityClass

ClockClass. Provides an interface to a real-time clock entity on a BrainStem module. The clock entity may be used to get and set the real time of the system. The clock entity has a one second resolution.

Note
Clock time must be reset if power to the BrainStem module is lost.

class DigitalClass : public Acroname::BrainStem::EntityClass

The DigitalClass is the interface to digital entities on BrainStem modules. Digital entities have the following 5 possabilities: Digital Input, Digital Output, RCServo Input, RCServo Output, and HighZ. Other capabilities may be available and not all pins support all configurations. Please see the product datasheet.

class I2CClass : public Acroname::BrainStem::EntityClass

The I2CClass is the interface the I2C busses on BrainStem modules. The class provides a way to send read and write commands to I2C devices on the entitie’s bus.

class MuxClass : public Acroname::BrainStem::EntityClass

MuxClass. A MUX is a multiplexer that takes one or more similar inputs (bus, connection, or signal) and allows switching to one or more outputs. An analogy would be the switchboard of a telephone operator. Calls (inputs) come in and by re-connecting the input to an output, the operator (multiplexor) can direct that input to on or more outputs.

One possible output is to not connect the input to anything which essentially disables that input’s connection to anything.

Not every MUX has multiple inputs. Some may simply be a single input that can be enabled (connected to a single output) or disabled (not connected to anything).

class PointerClass : public Acroname::BrainStem::EntityClass

PointerClass. 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.

class SignalClass : public Acroname::BrainStem::EntityClass

SignalClass is the interface to digital pins configured to produce square wave signals.

This class is designed to allow for square waves at various frequencies and duty cycles. Control is defined by specifying the wave period as (T3Time) and the active portion of the cycle as (T2Time). See the entity overview section of the reference for more detail regarding the timiing.

class StoreClass : public Acroname::BrainStem::EntityClass

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.

class SystemClass : public Acroname::BrainStem::EntityClass

SystemClass. The System class provides access to the core settings, configuration and system information of the BrainStem module. The class provides access to the model type, serial number and other static information as well as the ability to set boot reflexes, toggle the user LED, as well as affect module and router addresses etc. The most common brainstem example uses the system entity to blink the User LED.

class TemperatureClass : public Acroname::BrainStem::EntityClass

TemperatureClass. This entitiy is only available on certain modules, and provides a temperature reading in microcelsius.

class TimerClass : public Acroname::BrainStem::EntityClass

TimerClass. The Timer Class provides access to a simple scheduler. Reflex routines can be written which will be executed upon expiration of the timer entity. The timer can be set to fire only once, or to repeat at a certain interval.

class UARTClass : public Acroname::BrainStem::EntityClass

UARTClass. A UART is a “Universal Asynchronous Receiver/Transmitter. Many times referred to as a COM (communication), Serial, or TTY (teletypewriter) port.

The UART Class allows the enabling and disabling of the UART data lines.

class USBClass : public Acroname::BrainStem::EntityClass

USBClass. The USB class provides methods to interact with a USB hub and USB switches. Different USB hub products have varying support; check the datasheet to understand the capabilities of each product.

class RailClass : public Acroname::BrainStem::EntityClass

RailClass. Provides power rail functionality on certain modules. This entity is only available on certain modules. The RailClass can be used to control power to downstream devices, I has the ability to take current and voltage measurements, and depending on hardware, may have additional modes and capabilities.

class RCServoClass : public Acroname::BrainStem::EntityClass

The RCServoClass is the interface to servo entities on BrainStem modules. Servo entities are built upon the digital input/output pins and therefore can also be inputs or outputs. Please see the product datasheet on the configuration limitations.

class RelayClass : public Acroname::BrainStem::EntityClass

The RelayClass is the interface to relay entities on BrainStem modules. Relay entities can be set, and the voltage read. Other capabilities may be available, please see the product datasheet.