USB¶
- class brainstem.entity.USB(module, index)[source]¶
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.
- clearPortErrorStatus(channel)[source]¶
Clear the error status for the given port.
- Parameters:
channel (const unsigned char) – The port to clear error status for.
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- getAltModeConfig(channel)[source]¶
Get USB Alt Mode Configuration. The USB configuration for the given channel.
- Parameters:
channel (const unsigned char) – The USB sub channel
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getCC1Current(channel)[source]¶
Get the current through the CC1 for a port. The USB channel current in micro-amps (1 == 1e-6A).
- Parameters:
channel (const unsigned char) – The USB sub channel.
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getCC1Enable(channel)[source]¶
Get Enable/Disable on the CC1 line. State to be filled - Disabled: 0 - Enabled: 1
- Parameters:
channel (const unsigned char) – USB channel.
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getCC1Voltage(channel)[source]¶
Get the voltage of CC1 for a port. The USB channel voltage in micro-volts (1 == 1e-6V).
- Parameters:
channel (const unsigned char) – The USB sub channel.
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getCC2Current(channel)[source]¶
Get the current through the CC2 for a port. The USB channel current in micro-amps (1 == 1e-6A).
- Parameters:
channel (const unsigned char) – The USB sub channel.
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getCC2Enable(channel)[source]¶
Get Enable/Disable on the CC1 line. - State to be filled - Disabled: 0 - Enabled: 1
- Parameters:
channel (const unsigned char) –
USB channel.
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getCC2Voltage(channel)[source]¶
Get the voltage of CC2 for a port. The USB channel voltage in micro-volts (1 == 1e-6V).
- Parameters:
channel (const unsigned char) – The USB sub channel.
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getCableFlip(channel)[source]¶
Get Cable flip setting. The enable/disable status of cable flip.
- Parameters:
channel (const unsigned char) – The USB sub channel.
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getConnectMode(channel)[source]¶
Gets the connect mode of the switch. The current connect mode
- Parameters:
channel (const unsigned char) – The USB sub channel.
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getDownstreamBoostMode()[source]¶
Get the downstream boost mode. Possible modes are 0 - no boost, 1 - 4% boost, 2 - 8% boost, 3 - 12% boost. The current Downstream boost setting 0, 1, 2, or 3.
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getDownstreamDataSpeed(channel)[source]¶
Get the current data transfer speed for the downstream port. The data speed can be Hi-Speed (2.0) or SuperSpeed (3.0) depending on what the downstream device attached is using Filled with the current port data speed - N/A: usbDownstreamDataSpeed_na = 0 - Hi Speed: usbDownstreamDataSpeed_hs = 1 - SuperSpeed: usbDownstreamDataSpeed_ss = 2
- Parameters:
channel (const unsigned char) – USB downstream channel to check.
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getEnumerationDelay()[source]¶
Get the inter-port enumeration delay in milliseconds. Millisecond delay in 100mS increments (100, 200, 300 etc.)
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getHubMode()[source]¶
Get a bit mapped representation of the hubs mode; see the product datasheet for mode mapping and meaning. The USB hub mode.
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getPortCurrent(channel)[source]¶
Get the current through the power line for a port. The USB channel current in micro-amps (1 == 1e-6A).
- Parameters:
channel (const unsigned char) – The USB sub channel.
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getPortCurrentLimit(channel)[source]¶
Get the current limit for the port. The current limit setting.
- Parameters:
channel (const unsigned char) – USB downstream channel to limit.
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getPortError(channel)[source]¶
Get the current error for the Port. The port mode setting. Mode will be filled with the current setting. Mode bits that are not used will be marked as don’t care
- Parameters:
channel (const unsigned char) – USB downstream channel.
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getPortMode(channel)[source]¶
Get the current mode for the Port. The mode is a bitmapped representation of the capabilities of the usb port. These capabilities change for each of the BrainStem devices which implement the usb entity. See your device reference page for a complete list of capabilities. Some devices implement a common bit mapping for port mode at
- ef usbPortMode
The port mode setting. Mode will be filled with the current setting. Mode bits that are not used will be marked as don’t care
- param channel:
USB downstream channel.
- type channel:
const unsigned char
- return:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- rtype:
Result
- getPortState(channel)[source]¶
Get the current State for the Port. The port mode setting. Mode will be filled with the current setting. Mode bits that are not used will be marked as don’t care
- Parameters:
channel (const unsigned char) – USB downstream channel.
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getPortVoltage(channel)[source]¶
Get the voltage on the power line for a port. The USB channel voltage in microvolts (1 == 1e-6V).
- Parameters:
channel (const unsigned char) – The USB sub channel.
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getSBU1Voltage(channel)[source]¶
Get the voltage of SBU1 for a port. The USB channel voltage in micro-volts (1 == 1e-6V).
- Parameters:
channel (const unsigned char) – The USB sub channel.
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getSBU2Voltage(channel)[source]¶
Get the voltage of SBU2 for a port. The USB channel voltage in micro-volts (1 == 1e-6V).
- Parameters:
channel (const unsigned char) – The USB sub channel.
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getSBUEnable(channel)[source]¶
Get the Enable/Disable status of the SBU The enable/disable status of the SBU
- Parameters:
channel (const unsigned char) – The USB sub channel.
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getUpstreamBoostMode()[source]¶
Get the upstream boost mode. Possible modes are 0 - no boost, 1 - 4% boost, 2 - 8% boost, 3 - 12% boost. The current Upstream boost setting 0, 1, 2, or 3.
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getUpstreamMode()[source]¶
Get the upstream switch mode for the USB upstream ports. Returns auto, port 0 or port 1. The Upstream port mode.
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- getUpstreamState()[source]¶
Get the upstream switch state for the USB upstream ports. Returns 2 if no ports plugged in, 0 if the mode is set correctly and a cable is plugged into port 0, and 1 if the mode is set correctly and a cable is plugged into port 1. The Upstream port state.
- Returns:
Result object containing the requested value when the results error is set to NO_ERROR(0)
- Return type:
- setAltModeConfig(channel, configuration)[source]¶
Set USB Alt Mode Configuration.
- Parameters:
channel (const unsigned char) – The USB sub channel
configuration (const unsigned int) – The USB configuration to be set for the given channel.
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- setCC1Enable(channel, bEnable)[source]¶
Set Enable/Disable on the CC1 line.
- Parameters:
channel (const unsigned char) – USB channel.
bEnable (const unsigned char) – State to be set - Disabled: 0 - Enabled: 1
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- setCC2Enable(channel, bEnable)[source]¶
Set Enable/Disable on the CC2 line.
- Parameters:
channel (const unsigned char) – USB channel.
bEnable (const unsigned char) – State to be filled - Disabled: 0 - Enabled: 1
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- setCableFlip(channel, bEnable)[source]¶
Set Cable flip. This will flip SBU, CC and SS data lines.
- Parameters:
channel (const unsigned char) – The USB sub channel.
bEnable (const unsigned char) – The state to be set The state to be set - Disabled: 0 - Enabled: 1
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- setConnectMode(channel, mode)[source]¶
Sets the connect mode of the switch.
- Parameters:
channel (const unsigned char) – The USB sub channel.
mode (const unsigned char) – The connect mode - usbManualConnect = 0 - usbAutoConnect = 1
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- setDataDisable(channel)[source]¶
Disable only the data lines for a port without changing the state of the power line.
- Parameters:
channel (const unsigned char) – The USB sub channel.
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- setDataEnable(channel)[source]¶
Enable the only the data lines for a port without changing the state of the power line.
- Parameters:
channel (const unsigned char) – The USB sub channel.
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- setDownstreamBoostMode(setting)[source]¶
Set the downstream boost mode. Boost mode increases the drive strength of the USB data signals (power signals are not changed). Boosting the data signal strength may help to overcome connectivity issues when using long cables or connecting through “pogo” pins. Possible modes are 0 - no boost, 1 - 4% boost, 2 - 8% boost, 3 - 12% boost. This setting is not applied until a stem.system.save() call and power cycle of the hub. Setting is then persistent until changed or the hub is reset. After reset, default value of 0% boost is restored.
- Parameters:
setting (const unsigned char) – Downstream boost setting 0, 1, 2, or 3.
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- setEnumerationDelay(ms_delay)[source]¶
Set the inter-port enumeration delay in milliseconds.
- Parameters:
ms_delay (const unsigned int) – Millisecond delay in 100mS increments (100, 200, 300 etc.)
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- setHiSpeedDataDisable(channel)[source]¶
Disable only the data lines for a port without changing the state of the power line, Hi-Speed (2.0) only.
- Parameters:
channel (const unsigned char) – The USB sub channel.
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- setHiSpeedDataEnable(channel)[source]¶
Enable the only the data lines for a port without changing the state of the power line, Hi-Speed (2.0) only.
- Parameters:
channel (const unsigned char) – The USB sub channel.
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- setHubMode(mode)[source]¶
Set a bit mapped hub state; see the product datasheet for state mapping and meaning.
- Parameters:
mode (const unsigned int) – The USB hub mode.
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- setPortCurrentLimit(channel, microamps)[source]¶
Set the current limit for the port. If the set limit is not achievable, devices will round down to the nearest available current limit setting. This setting can be saved with a stem.system.save() call.
- Parameters:
channel (const unsigned char) – USB downstream channel to limit.
microamps (const unsigned int) – The current limit setting.
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- setPortDisable(channel)[source]¶
Disable both power and data lines for a port.
- Parameters:
channel (const unsigned char) – The USB sub channel.
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- setPortEnable(channel)[source]¶
Enable both power and data lines for a port.
- Parameters:
channel (const unsigned char) – The USB sub channel.
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- setPortMode(channel, mode)[source]¶
Set the mode for the Port. The mode is a bitmapped representation of the capabilities of the usb port. These capabilities change for each of the BrainStem devices which implement the usb entity. See your device reference page for a complete list of capabilities. Some devices use a common bit mapping for port mode at
ef usbPortMode
- param channel:
USB downstream channel to set the mode on.
- type channel:
const unsigned char
- param mode:
The port mode setting as packed bit field.
- type mode:
const unsigned int
- return:
An error result from the list of defined error codes in brainstem.result
- rtype:
unsigned byte
- setPowerDisable(channel)[source]¶
Disable only the power line for a port without changing the state of the data lines.
- Parameters:
channel (const unsigned char) – The USB sub channel.
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- setPowerEnable(channel)[source]¶
Enable only the power line for a port without changing the state of the data lines.
- Parameters:
channel (const unsigned char) – The USB sub channel.
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- setSBUEnable(channel, bEnable)[source]¶
Enable/Disable only the SBU1/2 based on the configuration of the usbPortMode settings.
- Parameters:
channel (const unsigned char) – The USB sub channel.
bEnable (const unsigned char) – The state to be set - Disabled: 0 - Enabled: 1
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- setSuperSpeedDataDisable(channel)[source]¶
Disable only the data lines for a port without changing the state of the power line, SuperSpeed (3.0) only.
- Parameters:
channel (const unsigned char) – The USB sub channel.
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- setSuperSpeedDataEnable(channel)[source]¶
Enable the only the data lines for a port without changing the state of the power line, SuperSpeed (3.0) only.
- Parameters:
channel (const unsigned char) – The USB sub channel.
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- setUpstreamBoostMode(setting)[source]¶
Set the upstream boost mode. Boost mode increases the drive strength of the USB data signals (power signals are not changed). Boosting the data signal strength may help to overcome connectivity issues when using long cables or connecting through “pogo” pins. Possible modes are 0 - no boost, 1 - 4% boost, 2 - 8% boost, 3 - 12% boost. This setting is not applied until a stem.system.save() call and power cycle of the hub. Setting is then persistent until changed or the hub is reset. After reset, default value of 0% boost is restored.
- Parameters:
setting (const unsigned char) – Upstream boost setting 0, 1, 2, or 3.
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte
- setUpstreamMode(mode)[source]¶
Set the upstream switch mode for the USB upstream ports. Values are usbUpstreamModeAuto, usbUpstreamModePort0, usbUpstreamModePort1, and usbUpstreamModeNone.
- Parameters:
mode (const unsigned char) – The Upstream port mode.
- Returns:
An error result from the list of defined error codes in brainstem.result
- Return type:
unsigned byte