Port

class brainstem.entity.Port(module, index)[source]

The Port Entity provides software control over the most basic items related to a USB Port. This includes everything from the complete enable and disable of the entire port to the individual control of specific pins. Voltage and Current measurements are also included for devices which support the Port Entity.

getAllocatedPower()[source]

Gets the currently allocated power This value is determined by the power manager which is responsible for budgeting the systems allocated power envelope.

Returns

value (int): Allocated power in milli-watts (mW) error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getAvailablePower()[source]

Gets the current available power. This value is determined by the power manager which is responsible for budgeting the systems available power envelope.

Returns

value (int): Available power in milli-watts (mW) error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getCC1Enabled()[source]

Gets the current enable value of the CC1 lines. Sub-component (CC1) of getEnabled.

Returns

value:
  • 1 = CC1 enabled

  • 0 = CC1 disabled.

error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getCC2Enabled()[source]

Gets the current enable value of the CC2 lines. Sub-component (CC2) of getEnabled.

Returns

value:
  • 1 = CC2 enabled

  • 0 = CC2 disabled.

error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getCCEnabled()[source]

Gets the current enable value of the CC lines. Sub-component (CC) of getEnabled.

Returns

value (int):
  • 1 = CC enabled

  • 0 = CC disabled.

error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getCurrentLimit()[source]

Gets the current limit of the port.

Returns

value: limit of the port in microAmps (uA) error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getCurrentLimitMode()[source]

Gets the current limit mode. The mode determines how the port will react to an over current condition.

Returns

value: An enumerated representation of the active current limit mode. error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getDataEnabled()[source]

Gets the current enable value of the data lines. Sub-component (Data) of getEnable.

Returns

value:
  • 1 = Data enabled

  • 0 = Data disabled.

error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getDataHS1Enabled()[source]

Gets the current enable value of the High Speed 1 side (HS1) data lines.: Sub-component of getDataHSEnable.

Returns

value:
  • 1 = Data enabled;

  • 0 = Data disabled.

error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getDataHS2Enabled()[source]

Gets the current enable value of the High Speed B side (HSB) data lines.: Sub-component of getDataHSEnable.

Returns

value:
  • 1 = Data enabled

  • 0 = Data disabled.

error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getDataHSEnabled()[source]

Gets the current enable value of the High Speed (HS) data lines. Sub-component of getDataEnable.

Returns

value:
  • 1 = Data enabled

  • 0 = Data disabled

error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getDataHSRoutingBehavior()[source]

Gets the HighSpeed Data Routing Behavior. The mode determines how the port will route the data lines.

Returns

value: An enumerated representation of the routing behavior. error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getDataRole()[source]

Gets the Port Data Role.

Returns

value: The current data role. See product datasheet for details. error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getDataSS1Enabled()[source]

Gets the current enable value of the Super Speed 1 side (SS1) data lines.: Sub-component of getDataSSEnable.

Returns

value:
  • 1 = Data enabled

  • 0 = Data disabled.

error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getDataSS2Enabled()[source]

Gets the current enable value of the Super Speed 2 side (SS2) data lines. Sub-component of getDataSSEnable.

Returns

value:
  • 1 = Data enabled;

  • 0 = Data disabled.

error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getDataSSEnabled()[source]

Gets the current enable value of the Super Speed (SS) data lines. Sub-component of getDataEnable.

Returns

value:
  • 1 = Data enabled;

  • 0 = Data disabled.

error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getDataSSRoutingBehavior()[source]

Gets the SuperSpeed Data Routing Behavior. The mode determines how the port will route the data lines.

Returns

value: An enumerated representation of the routing behavior. error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getDataSpeed()[source]

Gets the speed of the enumerated device.

Returns

value: Bit mapped value representing the devices speed. See product datasheet for details. error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getEnabled()[source]

Gets the current enable value of the port.

Returns

value:
  • 1 = Fully enabled port

  • 0 = One or more disabled sub-components.

error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getErrors()[source]

Returns any errors that are present on the port. Calling this function will clear the current errors. If the error persists it will be set again.

Returns

value: Bit mapped value representing the errors of the port See product datasheet for details. error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getHSBoost()[source]

Gets the ports USB 2.0 High Speed Boost Settings The setting determines how much additional drive the USB 2.0 signal will have in High Speed mode.

Returns

value: An enumerated representation of the boost range. error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getMode()[source]

Gets current mode of the port

Returns

value: Bit mapped value representing the ports mode. See product datasheet for details. error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getName()[source]

Gets a user defined name of the port. Helpful for identifying ports/devices in a static environment.

Returns

value: The current name of the port on success. error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getPowerEnabled()[source]

Gets the current enable value of the power lines. Sub-component (Power) of getEnable.

Returns

value:
  • 1 = Power enabled

  • 0 = Power disabled.

error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getPowerLimit()[source]

Gets the power limit of the port.

Returns

value: Active power limit in milli-watts (mW) error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getPowerLimitMode()[source]

Gets the power limit mode. The mode determines how the port will react to an over power condition.

Returns

value: An enumerated representation of the power limit mode Available modes are product specific. See the reference documentation. error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getPowerMode()[source]

Gets the Port Power Mode: Convenience Function of get/setPortMode

Returns

value: The current power mode. See product datasheet for details. error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getState()[source]

A bit mapped representation of the current state of the port. Reflects what he port IS which may differ from what was requested.

Returns

value: Bit mapped value representing the ports state. See product datasheet for details. error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getVbusAccumulatedPower()[source]

Gets the accumulated Vbus Power.

Returns

value: The accumulated power in mWattHours (1 == 1e-3 Wh) currently consumed on VBUS. error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getVbusCurrent()[source]

Gets the Vbus Current.

Returns

value: The current in microamps (1 == 1e-6A) currently present on VBUS. error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getVbusVoltage()[source]

Gets the Vbus Voltage.

Returns

value: The voltage in microvolts (1 == 1e-6V) currently present on Vbus. error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getVconn1Enabled()[source]

Gets the current enable value of the Vconn1 lines. Sub-component of getVconnEnabled.

Returns

value:
  • 1 = Vconn1 enabled

  • 0 = Vconn1 disabled.

error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getVconn2Enabled()[source]

Gets the current enable value of the Vconn2 lines. Sub-component of getVconnEnabled.

Returns

value:
  • 1 = Vconn2 enabled

  • 0 = Vconn2 disabled.

error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getVconnAccumulatedPower()[source]

Gets the accumulated Vconn Power.

Returns

value: The accumulated power in mWattHours (1 == 1e-3 Wh) currently consumed on Vconn. error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getVconnCurrent()[source]

Gets the Vconn Current.

Returns

value: The current in microamps (1 == 1e-6A) currently present on Vconn. error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getVconnEnabled()[source]

Gets the current enable value of the Vconn lines. Sub-component (Vconn) of getEnabled.

Returns

value:
  • 1 = Vconn enabled

  • 0 = Vconn disabled.

error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getVconnVoltage()[source]

Gets the Vconn Voltage.

Returns

value: The voltage in microvolts (1 == 1e-6v) currently present on Vconn. error: Non-zero BrainStem error code on failure.

Return type

Result (object)

getVoltageSetpoint()[source]

Gets the current voltage setpoint value of the port.

Returns

value:

The voltage setpoint in uV

error: Non-zero BrainStem error code on failure.

Return type

Result (object)

resetEntityToFactoryDefaults()[source]

Resets the PortClass Entity to it factory default configuration.

Returns (int):

Non-zero BrainStem error code on failure.

resetVbusAccumulatedPower()[source]

Resets the Vbus accumulated power.

Returns (int):

Non-zero BrainStem error code on failure.

resetVconnAccumulatedPower()[source]

Resets the Vconn accumulated power.

Returns (int):

Non-zero BrainStem error code on failure.

setCC1Enabled(enable)[source]

Enables or disables the CC1 lines. Sub-component (CC1) of setEnabled.

Parameters

enable (bool) –

  • 1 = Enable CC1 lines

  • 0 = Disable CC1 lines.

Returns (int):

Non-zero BrainStem error code on failure.

setCC2Enabled(enable)[source]

Enables or disables the CC2 lines. Sub-component (CC2) of setEnabled.

Parameters

enable (bool) –

  • 1 = Enable CC2 lines

  • 0 = Disable CC2 lines.

Returns (int):

Non-zero BrainStem error code on failure.

setCCEnabled(enable)[source]

Enables or disables the CC lines. Sub-component (CC) of setEnabled.

Parameters

enable (bool) –

  • 1 = Enable CC lines

  • 0 = Disable CC lines.

Returns (int):

Non-zero BrainStem error code on failure.

setCurrentLimit(limit)[source]

Sets the current limit of the port.

Parameters

limit (int) – limit to be applied in microAmps (uA)

Returns (int):

Non-zero BrainStem error code on failure.

setCurrentLimitMode(mode)[source]

Sets the current limit mode. The mode determines how the port will react to an over current condition.

Parameters

mode (int) – An enumerated representation of the current limit mode.

Returns (int):

Non-zero BrainStem error code on failure.

setDataEnabled(enable)[source]

Enables or disables the data lines. Sub-component (Data) of setEnable.

Parameters

enable (bool) –

  • 1 = Enable data

  • 0 = Disable data

Returns (int):

Non-zero BrainStem error code on failure.

setDataHS1Enabled(enable)[source]

Enables or disables the High Speed 1 side (HS1) data lines. Sub-component of setDataHSEnable.

Parameters

enable (bool) –

  • 1 = Enable data

  • 0 = Disable data

Returns (int):

Non-zero BrainStem error code on failure.

setDataHS2Enabled(enable)[source]

Enables or disables the High Speed 2 side (HS2) data lines. Sub-component of setDataHSEnable.

Parameters

enable (bool) –

  • 1 = Enable data

  • 0 = Disable data.

Returns (int):

Non-zero BrainStem error code on failure.

setDataHSEnabled(enable)[source]

Enables or disables the High Speed (HS) data lines. Sub-component of setDataEnable.

Parameters

enable (bool) –

  • 1 = Enable data

  • 0 = Disable data.

Returns (int):

Non-zero BrainStem error code on failure.

setDataHSRoutingBehavior(mode)[source]

Sets the HighSpeed Data Routing Behavior. The mode determines how the port will route the data lines.

Parameters

mode (int) – An enumerated representation of the routing behavior.

Returns (int):

Non-zero BrainStem error code on failure.

setDataSS1Enabled(enable)[source]

Enables or disables the Super Speed 1 side (SS1) data lines. Sub-component of setDataEnable.

Parameters

enable (bool) –

  • 1 = Enable data

  • 0 = Disable data.

Returns (int):

Non-zero BrainStem error code on failure.

setDataSS2Enabled(enable)[source]

Enables or disables the Super Speed 2 side (SS2) data lines. Sub-component of setDataSSEnable.

Parameters

enable (bool) –

  • 1 = Enable data

  • 0 = Disable data.

Returns (int):

Non-zero BrainStem error code on failure.

setDataSSEnabled(enable)[source]

Enables or disables the Super Speed (SS) data lines. Sub-component of setDataEnable.

Parameters

enable (bool) –

  • 1 = Enable data

  • 0 = Disable data.

Returns (int):

Non-zero BrainStem error code on failure.

setDataSSRoutingBehavior(mode)[source]

Sets the SuperSpeed Data Routing Behavior. The mode determines how the port will route the data lines.

Parameters

mode (int) – An enumerated representation of the routing behavior.

Returns (int):

Non-zero BrainStem error code on failure.

setEnabled(enable)[source]

Enables or disables the entire port.

Parameters

enable (bool) –

  • 1 = Enable the port

  • 0 = Disable the port

Returns (int):

Non-zero BrainStem error code on failure.

setHSBoost(boost)[source]

Sets the ports USB 2.0 High Speed Boost Settings The setting determines how much additional drive the USB 2.0 signal will have in High Speed mode.

Parameters

boost (int) – An enumerated representation of the boost range.

Returns (int):

Non-zero BrainStem error code on failure.

setMode(mode)[source]

Sets the mode of the port.

Parameters

mode (int) – Port mode to be set. See product datasheet for details.

Returns (int):

Non-zero BrainStem error code on failure.

setName(name)[source]

Sets a user defined name of the port. Helpful for identifying ports/devices in a static environment.

Parameters

name (string) – User defined name to be set.

Returns (int):

Non-zero BrainStem error code on failure.

setPowerEnabled(enable)[source]

Enables or Disables the power lines. Sub-component (Power) of setEnable.

Parameters

enable (bool) –

  • 1 = Enable power

  • 0 = Disable disable.

Returns (int):

Non-zero BrainStem error code on failure.

setPowerLimit(limit)[source]

Sets the power limit of the port.

Parameters

limit (int) – Limit to be applied in milli-watts (mW)

Returns (int):

Non-zero BrainStem error code on failure.

setPowerLimitMode(mode)[source]

Sets the power limit mode. The mode determines how the port will react to an over power condition.

Parameters
  • mode (int) – An enumerated representation of the power limit mode to be applied.

  • modes are product specific. See the reference documentation. (Available) –

Returns (int):

Non-zero BrainStem error code on failure.

setPowerMode(powerMode)[source]

Sets the Port Power Mode: Convenience Function of get/setPortMode

Parameters

powerMode (int) – Power mode to be set. See product datasheet for details.

Returns (int):

Non-zero BrainStem error code on failure.

setVconn1Enabled(enable)[source]

Enables or disables the Vconn1 lines. Sub-component of setVconnEnabled.

Parameters

enable (bool) –

  • 1 = Enable Vconn1 lines

  • 0 = Disable Vconn1 lines.

Returns (int):

Non-zero BrainStem error code on failure.

setVconn2Enabled(enable)[source]

Enables or disables the Vconn2 lines. Sub-component of setVconnEnabled.

Parameters

enable (bool) –

  • 1 = Enable Vconn2 lines

  • 0 = Disable Vconn2 lines

Returns (int):

Non-zero BrainStem error code on failure.

setVconnEnabled(enable)[source]

Enables or disables the Vconn lines. Sub-component (Vconn) of setEnabled.

Parameters

enable (bool) –

  • 1 = Enable Vconn lines

  • 0 = Disable Vconn lines.

Returns (int):

Non-zero BrainStem error code on failure.

setVoltageSetpoint(value)[source]

Sets the current voltage setpoint value of the port

Parameters

value (int) – The voltage setpoint in uV

Returns (int):

Non-zero BrainStem error code on failure.