AnsweredAssumed Answered

stm32f2 libusb and custom usb request - something strange

Question asked by komkov.pavel on Nov 18, 2012
Latest reply on Nov 21, 2012 by komkov.pavel
Tried to implement custom device control over vendor specific requests. 
Usb device library v1.1.0, usb otg library v2.1.0 and stm32f207 on device side, 
libusb 1.011, debian gnu linux on host side.
 For experiment i modify custom hid example - added some code to USBD_HID_Setup() func. 
On host side i'm just use example from libusb package - hid-custom-irq commandline. device is recognized, handle open successfully. But something wrong - when i issue set-led on all is ok - no errors from libusb and led is on and when i issue set-led off - led is still turn on and libusb shows time-out.
code on mcu:
case USB_REQ_TYPE_VENDOR:
    {
    switch (req->bRequest)
        {
            case CUSTOM_MC_JOB:
                HidCCommand=req->bRequest;
                USBD_CtlPrepareRx(pdev,
                        CBuffer,
                        req->wLength);
                break;
            case CUSTOM_RQ_SET_STATUS:
                ctmp=(req->wValue);
                if(ctmp)
                {
                    LEDOn(LED3);
                }
                else
                    LEDOff(LED3);
                //GPIOC->BSRRL |= ((uint16_t)ctmp&0x0f)<<6;
                //GPIOC->BSRRH |= ((~ctmp)&0x0f)<<6;
                break;
        }
code on PC (unmodified example except changed vid&pid and so on)
}else if((isOn = (strcasecmp(argv[1], "on") == 0)) || strcasecmp(argv[1], "off") == 0){
        cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_STATUS, isOn, 0, buffer, 0, 5000);
if(cnt < 0){
            fprintf(stderr, "USB error: %s\n", usb_strerror());
        }
}
experiment a bit with wValue on pc side - it seems that if i send somethig else than 1 - got same error.
anybody experience anything similar?

Outcomes