-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, 7 Mar 2003 18:24, Shiva_Shankar wrote:
> Thanks for your response. I have tried to talk to the device directly using
> /proc/bus/XXX/YYY but it is returning "device busy" because the usb device
> has only one endpoint which gives the mouse data as well as my control
> packet. I have tried but with no success.
It would help if you could post your test code. Without that, it is almost 
impossible to tell what you are doing wrong.

> Now I have got the packet but I want to communicate to the user application
> can anyone suggest me a way I can do it.
Here is some test code, for a Logitech mouse. This tests whether the mouse is 
in 400cpi or 800cpi mode, by sending a vendor specific command, and getting 
back one byte. 

This code needs Johannes' libusb (http://libusb.sf.net) to be installed, and 
naturally you need to compile it with -lusb.

HTH

Brad


/*
 * Dump resolution on logitech dual optical mice.
 */

#include <stdio.h>
#include <usb.h>

int main(void)
{
    struct usb_bus *bus;
    struct usb_device *dev;
    usb_dev_handle *usb_h;
    char resolution = 0;
    int result = 0;

    usb_init();

    usb_find_busses();
    usb_find_devices();

    printf("bus/device  idVendor/idProduct\n");
    for (bus = usb_busses; bus; bus = bus->next) {
        for (dev = bus->devices; dev; dev = dev->next) {

            printf("%s/%s     %04X/%04X\n", bus->dirname, dev->filename,
                   dev->descriptor.idVendor, dev->descriptor.idProduct);

            if ( (0x046d == dev->descriptor.idVendor) &&
                 (0xC506 == dev->descriptor.idProduct) ) {
                usb_h = usb_open(dev);
                result = usb_control_msg(usb_h, 0xC0, 0x01, 0x0017, 0x0000,
                                         &resolution,  0x0001, 1);
                printf("   Resolution: %x (%x)", resolution, result);
                switch (resolution)
                    {
                    case 0: printf("(You probably aren't root)\n");
                        break;
                    case 3: printf("(400cpi)\n");
                        break;
                    case 4: printf("(800cpi)\n");
                        break;
                    default: printf("(Unknown result)\n");
                        break;
                    }
                usb_close(usb_h);
            }

        }
    }

    return 0;

}
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE+awfOW6pHgIdAuOMRAgq1AKC4EXX90KP4RY+WFkkxq9e6GbbRrwCePcQB
pOl6Zgib4VyWs1NubmDBcgg=
=RV9k
-----END PGP SIGNATURE-----



-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger 
for complex code. Debugging C/C++ programs can leave you feeling lost and 
disoriented. TotalView can help you find your way. Available on major UNIX 
and Linux platforms. Try it free. www.etnus.com
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-users

Reply via email to