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;
}

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.
We are bots. Are you?