Hi,
I extended the listdevs example with libusb_get_config_descriptor() and in most 
cases I get the error "LIBUSB_ERROR_NOT_FOUND". As far as I know, every USB 
device should support this feature.
Try it yourself.
I'm using Windows XP and libusbx 1.0.14.10586.

Best regards
Stefano
/*
 * libusbx example program to list devices on the bus
 * Copyright © 2007 Daniel Drake <d...@gentoo.org>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#include <stdio.h>
#include <sys/types.h>

#include "libusb.h"

static void print_devs(libusb_device **devs)
{
        libusb_device *dev;
        int i = 0;

        while ((dev = devs[i++]) != NULL) {
                struct libusb_device_descriptor desc;
                struct libusb_config_descriptor *config;

                int r = libusb_get_device_descriptor(dev, &desc);
                if (r < 0) {
                        fprintf(stderr, "failed to get device descriptor");
                        return;
                }

                printf("%04x:%04x (bus %d, device %d)\n",
                        desc.idVendor, desc.idProduct,
                        libusb_get_bus_number(dev), 
libusb_get_device_address(dev));

                r = libusb_get_config_descriptor(dev, 0, &config);
                
                if (r != 0) {
                        fprintf(stderr, "failed to get config descriptor: 
%s\n", libusb_error_name(r));
                        //return;
                } else {
                        printf("Max Power: %u mA\n", config->MaxPower * 2);
                        libusb_free_config_descriptor(config);
                }
        }
}

int main(void)
{
        libusb_device **devs;
        int r, i;
        ssize_t cnt;

        r = libusb_init(NULL);
        //libusb_set_debug(NULL, LIBUSB_LOG_LEVEL_DEBUG);

        if (r < 0) {
                libusb_error_name(r);
                return r;
        }

        cnt = libusb_get_device_list(NULL, &devs);
        if (cnt < 0)
                return (int) cnt;

        print_devs(devs);
        libusb_free_device_list(devs, 1);

        libusb_exit(NULL);
        return 0;
}
------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel

Reply via email to