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.

BrainStem2CLI::aErr getBuild (unsigned int% build)

Get the modules firmware build number The build number is a unique hash assigned to a specific firmware.

Parameters:

build – Variable the build will be placed in.

BrainStem2CLI::aErr hasUEI(const unsigned char command, const unsigned char option, const unsigned char index, const unsigned char flags)

Queries the module to determine if it implements a UEI. Each UEI has a command, option or variant, index and flag. The hasUEI method queries for a fully specified UEI. Returns aErrNone if the variation is supported and an appropriate error if not. This call is blocking for up to the nMSTimeout period.

Parameters:
  • command – One of the UEI commands (cmdXXX).

  • option – The option or variant of the command.

  • index – The entity index.

  • flags – The flags (ueiOPTION_SET or ueiOPTION_GET).

BrainStem2CLI::aErr classQuantity (const unsigned char command, unsigned char% count)

Queries the module to determine how many entities of the specified class are implemented by the module. Zero is a valid return value. For example, calling classQuantity with the command parameter of cmdANALOG would return the number of analog entities implemented by the module.

Parameters:
  • command – One of UEI commands (cmdXXX).

  • count – When the request is successful count is updated with the number of entities found.

BrainStem2CLI::aErr subClassQuantity (const unsigned char command, const unsigned char index, unsigned char% count)

Queries the module to determine how many subclass entities of the specified class are implemented by the module for a given entity index. This is used for entities which may be 2-dimensional. E.g. cmdMUX subclasses are the number of channels supported by a particular mux type (index); as a specific example, a module may support 4 UART channels, so subClassQuantity(cmdMUX, aMUX_UART…) could return 4. Zero is a valid return value.

Parameters:
  • command – One of the UEI commands (cmdXXX).

  • index – The entity index.

  • count – The number of subclasses found.

BrainStem2CLI::aErr entityGroup (const unsigned char command, const unsigned char index, unsigned char% group)

Queries the module the group assigned to an entity and index. Entities groups are used to specify when certain hardware features are fundamentally related. E.g. certain hardware modules may have some digital pins associated with an adjustable voltage rail; these digitals would be in the same group as the rail. Zero is the default group.

Parameters:
  • command – One of the UEI commands (cmdXXX).

  • index – The entity index.

  • group – Upon success, group is filled with the entities group value.

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.