Advanced Control with USBHub3+: Managing Power and Data Connections

2024 March 15

More control than just on and off

Enable and disable VBus, all Data, High Speed or Super Speed connections

In addition to turning ports on and off, the USBHub3+ can also independently enable and disable Voltage and Data:

  • Vbus
  • All Data
  • High Speed data (480 Mbps)
  • Super Speed data (5 Gbps)

We'll be working interactively using the Brainstem API in a Python console so you can see the results line-by-line. 

First, power on the hub and connect one of the host ports to your computer

All of the VBus LEDs on the front panel should be on. If you haven’t already, install the brainstem package (See the Quickstart Guide for more detail)

>>> !pip install brainstem --upgrade

Then import the brainstem library

>>> import brainstem

Create an instance of the USBHub3p called "hub"

>>> hub = brainstem.stem.USBHub3p()

Discover and connect to the hub

>>> hub.discoverAndConnect(brainstem.link.Spec.USB)
0

(A return value of 0 means no error)

Let's plug a SuperSpeed USB 3 device (in this case an iPad Pro with a USB3-to-C cable) into port 0.  A green LED should turn on next to port 0.

Let's check the port state:

>>> result=hub.usb.getPortState(0) 
>>> format(result.value, 'b') 
'100000000001000000001011'

Bits 0,1,3,12,23 are high.  Checking this table, we see:

  • Vbus enabled
  • USB2 data enabled
  • USB3 data enabled
  • USB3 device Attached
  • Device attached

Now let's disable Vbus while keeping the data connection on

>>> hub.usb.setPowerDisable(0)

Many devices will drop the data connection when Vbus is disabled and the hub data LED will be off as well

getPortState returns '1010', meaning

  • Vbus disabled
  • USB2 data enabled
  • USB3 data enabled

Re-enable Vbus:

>>> hub.usb.setPowerEnable(0)

The iPad Pro reconnected automatically, while the audio interface required an unplug-replug (or port disable / reenable) to make a data connection.

Let's turn off the data connection on port 0:

>>> hub.usb.setDataDisable(0)

The data LED is off, and Vbus is on.  (the device is charging, but has no data connection)

Reenable data:

>>> hub.usb.setDataEnable(0)

Not let's disable just SuperSpeed:

>>> hub.usb.setSuperSpeedDataDisable(0)

If your device supports both Super Speed and High speed, the data LED will switch to yellow indicating high speed connection.

getPortState returns '100000000000100000000011' meaning 

  • Vbus enabled
  • USB2 data enabled
  • USB2 device Attached
  • Device attached

Re-enable Super Speed:

>>> hub.usb.setSuperSpeedDataEnable(0)

The device may not reconnect until Vbus is toggled (by physically unplugging, disabling and re-enabling the port or just VBus)

We can also disable High Speed USB lines

>>> hub.usb.setHiSpeedDataDisable(0)

Super Speed devices should be unaffected, while High Speed devices will disconnect.

Re-enable High Speed lines:

>>> hub.usb.setHiSpeedDataEnable(0)

What else could you do with USBHub3+?

Add New Comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
CAPTCHA