Acroname USB Hub 2x4 Android Demo

2015 August 27
Acroname USB Hub 2x4 Android Demo

Controlling data and power lines independently with HubTool application

Notice that when the power line is enabled, the Android device indicates it as "charged". After enabling the data lines, the device then indicates that it enumerates as a media device from the USB Hub. Doing this sort of test with HubTool is a useful and informative way to see how your device responds to USB events.

It is just as easy to do the same sort of test using your own program. Below is example C++ code which connects to the Acroname USBHub2x4, and disables device (downstream) port 0 and then re-enables it. This example shows how to programmatically control both power and data lines individually or simultaneously using the BrainStem API.

The API documentation for the USB class gives more information about the details of each of the functions used below.

#include "BrainStem2/BrainStem-all.h"

int main(int argc, const char * argv[]) {
    // variables for errors and hub module class
    aErr err=aErrNone;
    aUSBHub2x4 hub;
     
    // look for devices on USB
    err = hub.linkDiscoverAndConnect(USB);
     
    // disable power and data on port 0
    hub.usb.setDataDisable(0);
    hub.usb.setPowerDisable(0);
     
    // enable power and data on port 0 (single call)
    hub.usb.setPortEnable(0);
     
    return 0;
}