Module Class

class ModuleClass

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

Public Functions

ModuleClass(const unsigned char address, const unsigned char model)

Constructors.

~ModuleClass()

Destructor.

!ModuleClass ()

Finalizer.

BrainStem2CLI::aErr discoverAndConnect(m_linkType transport)

A discovery-based connect. This member function will attempt to connect to the first BrainStem module found. If this module does not match the object type the connection will fail.

Parameters:

transport – - Transport on which to search for available BrainStem link modules. See the m_linkType “transport” enum for supported transports.

Returns:

aErr::aErrBusy - if the module is already in use.

Returns:

aErr::aErrParam - if the transport type is undefined.

Returns:

aErr::aErrNotFound - if the module cannot be found.

Returns:

aErr::aErrNone If the connect was successful.

BrainStem2CLI::aErr discoverAndConnect(m_linkType transport, unsigned int serialNum)

A discovery-based connect. This member function will connect to the first available BrainStem found on the given transport. If the serial number is passed, it will only connect to the module with that serial number. Passing 0 as the serial number will create a link to the first link module found on the specified transport. If a link module is found on the specified transport, a connection will

Parameters:
  • transport – - Transport on which to search for available BrainStem link modules. See the m_linkType “transport” enum for supported transports.

  • serialNum – - Specify a serial number to connect to a specific link module. Use 0 to connect to the first link module found.

Returns:

aErr::aErrBusy - if the module is already in use.

Returns:

aErr::aErrParam - if the transport type is undefined.

Returns:

aErr::aErrNotFound - if the module cannot be found.

Returns:

aErr::aErrNone If the connect was successful.

BrainStem2CLI::aErr connectFromSpec(m_linkSpec spec)

Connect to a link with a fully defined specifier.

Parameters:

spec – - Connect to module with specifier.

Returns:

aErr::aErrInitialization - If there is currently no link object.

Returns:

aErr::aErrBusy - If the link is currently connected.

Returns:

aErr::aErrParam - if the specifier is incorrect.

Returns:

aErr::aErrNotFound - if the module cannot be found.

Returns:

aErr::aErrNone If the connect was successful.

BrainStem2CLI::aErr connect(m_linkType transport)

Connect using the current link specifier.

Parameters:

transport – - Transport on which to search for available BrainStem link modules. See the m_linkType “transport” enum for supported transports.

Returns:

aErr::aErrBusy - if the module is already in use.

Returns:

aErr::aErrParam - if the type is incorrect or serialNum is not specified

Returns:

aErr::aErrNotFound - if the module cannot be found.

Returns:

aErr::aErrNone If the connect was successful.

BrainStem2CLI::aErr connect(m_linkType transport, unsigned int serialNum)

Connect using the current link specifier.

Parameters:
  • transport – - Transport on which to search for available BrainStem link modules. See the m_linkType “transport” enum for supported transports.

  • serialNum – - Specify a serial number to connect to a specific link module. Use 0 to connect to the first link module found.

Returns:

aErr::aErrBusy - if the module is already in use.

Returns:

aErr::aErrParam - if the type is incorrect or serialNum is not specified

Returns:

aErr::aErrNotFound - if the module cannot be found.

Returns:

aErr::aErrNone If the connect was successful.

BrainStem2CLI::aErr connectThroughLinkModule(BrainStem2CLI::ModuleClass %%module)

Connect using link from another Module. This member function will connect to the same BrainStem used by given Module. If a link module is found on the specified transport, a connection will

Parameters:

module – - Pointer to a valid Module class object.

Returns:

aErr::aErrParam - if the module is undefined.

Returns:

aErr::aErrNone - if the connect was successful.

BrainStem2CLI::aErr disconnect()

Disconnect from the BrainStem module.

Returns:

aErr::aErrResource - If the there is no valid connection.

Returns:

aErr::aErrConnection - If the disconnect failed, due to a communication issue.

Returns:

aErr::aErrNone If the disconnect was successful.

BrainStem2CLI::aErr reconnect()

Reconnect using the current link specifier.

Returns:

aErr::aErrBusy - if the module is already in use.

Returns:

aErr::aErrParam - if the specifier is incorrect.

Returns:

aErr::aErrNotFound - if the module cannot be found.

Returns:

aErr::aErrNone If the connect was successful.

bool isConnected()

Is the link connected to the BrainStem Module.

BrainStem2CLI::linkStatus getStatus()

Check the status of the module connection.

Returns:

linkStatus (see aLink.h for status values)

BrainStem2CLI::aErr getConfig(BrainStem2CLI::aEtherConfig %%config)

Gets the links current aEther configuration

Parameters:

config – Variable to be filled with the config

Returns:

aErrNone on success. aErrNotReady if the module does not have a link aErrParam if config is NULL

cli::array<unsigned int> %%getIPv4Interfaces(void)

Populates a list with all of the available IPv4 Interfaces.

Returns:

An array of network interfaces.

BrainStem2CLI::aErr setConfig(BrainStem2CLI::aEtherConfig %%config)

Sets the links aEther configuration. Configuration must be applied BEFORE connecting

Parameters:

config – Configuration to be applied

Returns:

aErrNone on success. aErrPermission if the module is currently connected. aErrNotReady if the module does not have a link

void setModuleAddress(const unsigned char address)

Accessor to set the address of the BrainStem module associated with the instance on the host machine. (Not to be confused with the System entity which effects the device hardware.)

Parameters:

address – The module address.

unsigned char getModuleAddress()

Accessor to get the address of the BrainStem module associated with the instance on the host machine. (Not to be confused with the System entity which effects the device hardware.)

Returns:

The module address.

void setNetworkingMode(const bool mode)

Sets the networking mode of the module object. By default the module object is configure to automatically adjust its address based on the devices current module address. So that, if the device has a software or hardware offset it will still be able to communication with the device. If advanced networking is required the auto networking mode can be turned off.

Parameters:

mode – True/1 for Auto Networking, False/0 for manual networking

Public Static Functions

static BrainStem2CLI::m_linkSpec findFirstModule (BrainStem2CLI::m_linkType type, [Optional] Nullable< unsigned int > networkInterface)

Finds the first module found on the given transport

Parameters:

type – The transport type on which to search for devices. Valid m_linkType “linktypes” are accepted.

Returns:

If found, the linkspec will be populated with the devices information. Values will be all zeros otherwise.

static BrainStem2CLI::m_linkSpec findModule (BrainStem2CLI::m_linkType type, unsigned int serialNum, [Optional] Nullable< unsigned int > networkInterface)

Finds the module with the given serial number on the given transport type.

Parameters:
  • type – The trasport type on which search for devices. Valid m_linkType “linktypes” are accepted

  • serialNum – - Specify a serial number to connect to a specific link module. Use 0 to connect to the first link module found.

Returns:

If found the linkspec will be populated with the devices information. Values will be all zeros otherwise.

static BrainStem2CLI::aErr sDiscover (BrainStem2CLI::m_linkType type, List< m_linkSpec > ^specList, [Optional] Nullable< unsigned int > networkInterface)

Discover is called with a specified transport to search for link modules on that transport. The devices list is filled with device scecifiers. sDiscover returns aErrNone if the discovery process is successful, regardless of whether any links are found. An error is only returned if the link discovery process fails. Discovery can take some time.

Parameters:
  • type – Transport to search for available BrainStem link modules on. See the m_linkType “transport” enum for supported transports.

  • specList – an empty list of specifiers that will be filled in.

Returns:

aErr::aErrNotFound if no devices were found.

Returns:

aErr::aErrNone on success.