Crossplatform libusb

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
eslavko
Rank 1
Rank 1
Posts: 36
Joined: Sat Dec 18, 2010 6:37 pm

Crossplatform libusb

Post by eslavko » Tue May 20, 2014 9:43 am

Hello...

I want to write linux/win application in python. But I can't get win version working on linux works nice.
The minimum example to shov error is below. In both systems selecting right device works, but control write fain on windows with bad parametter error.

anny idea?

Code: Select all

import usb1, libusb1

bmRequestType=libusb1.LIBUSB_TYPE_CLASS | libusb1.LIBUSB_ENDPOINT_IN
bRequest=libusb1.LIBUSB_REQUEST_SET_CONFIGURATION
buf=chr(0)+chr(0)+chr(0)

context = usb1.USBContext()
deviceList=context.getDeviceList(skip_on_error=True)
for device in deviceList:
    if '16c0:05df' in str(device):
        deviceName=device.getProduct()
        if deviceName=='ISM_RTX':
            usbHandle=device.open()
            print usbHandle.controlWrite(bmRequestType, bRequest, 0, 0, buf,0)

eslavko
Rank 1
Rank 1
Posts: 36
Joined: Sat Dec 18, 2010 6:37 pm

Re: Crossplatform libusb

Post by eslavko » Tue May 20, 2014 11:52 am

Hello...
I do 'brute force' test to see what parameters pass.
And I found that in Win the bRequest can be only one of:
USBRQ_GET_CONFIGURATION 8
USBRQ_GET_INTERFACE 10
USBRQ_SET_INTERFACE 11

so there is no wanted HID request I want.
USBRQ_HID_GET_REPORT 0x01
USBRQ_HID_SET_REPORT 0x09

And bmRequestType works just with walues under 159. So USBRQ_TYPE_CLASS can't be used for write (and read too)..
I try with USBRQ_TYPE_STANDARD and modified vusb code like this

Code: Select all

uchar   usbFunctionSetup(uchar data[8])
{
    usbRequest_t *rq = (void *)data;
    if((rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_STANDARD){   
        if(rq->bRequest == USBRQ_GET_INTERFACE){ 
            return USB_NO_MSG;  /* use usbFunctionWrite() to receive data from host */
        }else if(rq->bRequest == USBRQ_SET_INTERFACE){
            return USB_NO_MSG;  /* use usbFunctionWrite() to receive data from host */
        }
    }
    return 0;
}


but no sucess. I don't get error now, but either thing doesn't work

Post Reply