Turn On/Off USB ports in QNX 6.5SP1

Any sample codes available for turning ON/Off USB ports on a smart hub? (in QNX 6.5SP1)

With your version of QNX, do you have “/pps/qnx/device/usb_ctrl” in your root path ?
(The USB stack must be running).

I think usblauncher must be running too.

Can it be toggled using issuing usbd_feature() to the smart hub.

My target is not based out of pps service

Yes, this is possible but it’s quite complex.

Can you elaborate?

Thanks!

With PPS system, the command to turn USB ports ON/OFF is just one line.

Without PPS, you have to create your own USB port manager.

You can find the USB DDK documentation here : qnx.com/developers/docs/6.5. … b/api.html

I can’t provide you with the code I have but here is an abstract of things you have to do :

- usbd_connect()             using USBD_CONNECT_WILDCARD for all usbd_device_ident_t structure fields (unless you know the exact device ?)
- for all 64 possible devices : 
    - usbd_attach()
    - if success 
        - usbd_hub_descriptor()
        - if success
            - usbd_device_extra()
            - if success
                - set_port_feature(port, feature) or clear_port_feature(port, feature)  // ON or OFF (feature = USB_HUB_FEATURE_PORT_POWER)
        - usbd_detach()

set_port_feature() :
- usbd_alloc_urb()
- usbd_setup_vendor()
    - Flags        = URB_DIR_OUT;
    - bRequest     = USB_SET_FEATURE;
    - request_type = 0x23;
        usbd_setup_vendor(urb,                  // An opaque handle (from usbd_alloc_urb()).
                          Flags,                // URB_DIR_OUT—specify outgoing (PC-to-device) transfer.
                          bRequest,             // A device-specific request.
                          request_type,         // The type of request
                          Feature,              // wValue  -> This varies, depending on the request.
                          Port,                 // wIndex  -> This varies, depending on the request.
                          NULL,                 // Data    -> The address for the start of the transfer.
                          0);                   // wLength -> The length (in bytes) of the data transfer.
- usbd_io()
- usbd_free_urb()

clear_port_feature() :
- usbd_alloc_urb()
- usbd_setup_vendor()
    - Flags        = URB_DIR_OUT;
    - bRequest     = USB_CLEAR_FEATURE;
    - request_type = 0x23;
        usbd_setup_vendor(urb,                  // An opaque handle (from usbd_alloc_urb()).
                          Flags,                // URB_DIR_OUT—specify outgoing (PC-to-device) transfer.
                          bRequest,             // A device-specific request.
                          request_type,         // The type of request
                          Feature,              // wValue  -> This varies, depending on the request
                          Port,                 // wIndex  -> This varies, depending on the request
                          NULL,                 // Data    -> The address for the start of the transfer
                          0);                   // wLength -> The length (in bytes) of the data transfer.
- usbd_io()
- usbd_free_urb()