Port

API Documentation: [cpp] [python] [.NET] [LabVIEW]

The Port Entity provides control over the most basic items related to a USB Port. This includes actions ranging from a complete port enable and disable to the individual interface control. Voltage and current measurements are also included for devices which support the Port Entity.


Port Control

The USBHub2x4 has a Port Entity for every port on the device; however, not all ports have the same capabilities. These ports can be referenced by their instance (port[x]) index.

Port Label

Index (port[x])

0

0

1

1

2

2

3

3

Up0

4

Up1

5

One of the most powerful features of the USBHub2x4 is its ability to turn ports on and off which is available on Ports 0-3.

stem.hub.port[x].setEnabled() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getEnabled() [cpp] [python] [NET] [LabVIEW]

Manipulating just the USB Vbus line for a single port can be done by calling the following method on Ports 0-3.

stem.hub.port[x].setPowerEnabled() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getPowerEnabled() [cpp] [python] [NET] [LabVIEW]

Manipulating data lines while not affecting the Vbus lines simultaneously for a single port can be done by calling the following method for Ports 0-3. (For USBHub2x4 the only data lines happen to be USB 2.0 Hi-Speed)

stem.hub.port[x].setDataEnabled() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getDataEnabled()[cpp] [python] [NET] [LabVIEW]

Manipulating just the USB 2.0 Hi-Speed data lines for a single port can be done by calling the following for Ports 0-3.

stem.hub.port[x].setDataHSEnabled() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getDataHSEnabled() [cpp] [python] [NET] [LabVIEW]

Voltage and Current Measurements

The USBHub2x4 provides Voltage and Current measurements for Vbus. These values can be acquired for all 4 ports through the following APIs

stem.hub.port[x].getVbusVoltage() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getVbusCurrent() [cpp] [python] [NET] [LabVIEW]

Power Modes

The ports of the USBHub2x4 are capable of providing power in multiple formats. The default is Charging Downstream Port (CDP), but that can be changed to things like: Standard Downstream Port (SDP), Charging Downstream Port (CDP) / Dedicated Charging Port (DCP). These modes can be set through:

stem.hub.port[x].setPowerMode() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getPowerMode() [cpp] [python] [NET] [LabVIEW]

Power Mode

Value

Define

None

0

portPowerMode_none_Value

SDP

1

portPowerMode_sdp_Value

CDP/DCP

2

portPowerMode_cdp_dcp_Value

Warning

The USBHub2x4 does not have a dedicated control port, therefore all control is done through the upstream. If you change upstreams while controlling it, the control connection will be lost and the new host will have to take over.

Port Mode

As outlined in the “Port Control” section the USBHub2x4 can individually manipulate almost every pin on the connector; however, depending on your application that might require multiple function calls in order to configure the port how you want it. Port Mode on the other hand is a one stop shop that allows you to pick and choose which lines you want enabled or disabled through a single call. Additionally, it has a few other features tucked away inside of it.

stem.hub.port[x].setMode() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getMode() [cpp] [python] [NET] [LabVIEW]

Port Mode Item

Bit

Value

Define

Power Enable

0

0/1

portPortMode_powerEnabled_Bit

HS 1 Enable

1

0/1

portPortMode_HS1Enabled_Bit

Power Mode: Offset

16

portPortMode_portPowerMode_Offset

Power Mode: Mask

0x7

portPortMode_portPowerMode_Mask

Power Mode: None

16-18

0

portPortMode_portPowerMode_none_Value

Power Mode: SDP

16-18

1

portPortMode_portPowerMode_sdp_Value

Power Mode: CDP/DCP

16-18

2

portPortMode_cdp_dcp_Value

Data Role

The data role describes the current configuration of the port in regards to its data direction. In most cases this evaluates to an Upstream Facing Port (UFP) or a Downstream Facing Port (DFP). Upstream in this case means the host side of the port and Downstream refers to the device side. The Data Role can be aquired through:

stem.hub.port[x].getDataRole() [cpp] [python] [NET] [LabVIEW]

Data Role

Value

Define

Disabled

0

portDataRole_Disabled_Value

Upstream

1

portDataRole_Upstream_Value

Downstream

2

portDataRole_Downstream_Value

Control

3

portDataRole_Control_Value

Port Limits and Modes

At the Port level the user has the ability to define current limit.

stem.hub.port[x].setCurrentLimit() [cpp] [python] [NET] [LabVIEW]
stem.hub.port[x].getCurrentLimit() [cpp] [python] [NET] [LabVIEW]

Downstream Data Speed

The USBHub2x4 can detect if a device has been enumerated. Additionally, it can detect at what speed a device has enumerated at.

stem.hub.port[x].getDataSpeed() [cpp] [python] [NET] [LabVIEW]

Data Speed

Bit

Value

Define

1.5 Mbit/s

0

0/1

portDataSpeed_ls_1p5M_Bit

12 Mbit/s

1

0/1

portDataSpeed_fs_12M_Bit

480 Mbit/s

2

0/1

portDataSpeed_hs_480M_Bit

5 Gbit/s

3

0/1

portDataSpeed_ss_5G_Bit

10 Gbit/s

4

0/1

portDataSpeed_ss_10G_Bit

USB 2.0

6

0/1

portDataSpeed_Connected_2p0_Bit

USB 3.0

7

0/1

portDataSpeed_Connected_3p0_Bit