2010/7/9 Xiaofan Chen <xiaof...@gmail.com>:
> On Sat, Jul 10, 2010 at 12:12 AM, Wander Lairson
> <wander.lair...@gmail.com> wrote:
>>> The problem was in a Copy&Paste error where i have defined the
>>> endpoint numbers as:
>>>
>>> TI_EP_BULK_UART1_OUT = 0x01
>>> TI_EP_BULK_UART1_OUT = 0x81
>>>
>>> And they should be:
>>>
>>> TI_EP_BULK_UART1_OUT = 0x01
>>> TI_EP_BULK_UART1_IN = 0x81
>>>
>>> and the tried to WRITE to an INPUT endpoint.
>>>
>>> Question: shouldnt this raise an exception on pyusb?
>>
>> Actually I dispatch the resquest to the underline library and trust on
>> it reporting this things.
>> But I can consider this kind of validation on PyUSB layer.
>>
>
> The only issue is with libusb-0.1 (now consider unsupported and
> won't fix by Daniel Drake) which masks the direction
> bit. libusb-win32 does not do that, libusb-1.0 does not do that.
>
> Reference:
> http://libusb.svn.sourceforge.net/viewvc/libusb/trunk/libusb/linux.c?revision=658&view=markup
>
> There are things like the following which Daniel Drake and many others
> consider bad thing to do.

I consider also, because it masks a misuse in the application layer.
But validating the
endpoint and returning an error might be a good ideia, like that:

int usb_interrupt_read(usb_dev_handle *dev, int ep, char *bytes, int size,
int timeout)
{
/* Ensure the endpoint address is correct */
if (ep & USB_ENDPOINT_IN) {
     errno = EINVAL;
     return -1;
}

Altough I prefer to trust on OS drivers doing this validation. If it
doesn't, it might have a good
reason to not do so.

>
> 310     int usb_interrupt_read(usb_dev_handle *dev, int ep, char *bytes, int 
> size,
> 311     int timeout)
> 312     {
> 313     /* Ensure the endpoint address is correct */
> 314     ep |= USB_ENDPOINT_IN;
> 315     return usb_urb_transfer(dev, ep, USB_URB_TYPE_INTERRUPT, bytes, size,
> 316     timeout);
> 317     }
>
> 288     int usb_bulk_read(usb_dev_handle *dev, int ep, char *bytes, int size,
> 289     int timeout)
> 290     {
> 291     /* Ensure the endpoint address is correct */
> 292     ep |= USB_ENDPOINT_IN;
> 293     return usb_urb_transfer(dev, ep, USB_URB_TYPE_BULK, bytes, size,
> 294     timeout);
> 295     }
>
>
>
> --
> Xiaofan http://sourceforge.net/projects/libusb-win32/
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> _______________________________________________
> pyusb-users mailing list
> pyusb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyusb-users
>



-- 
Best Regards,
Wander Lairson Costa

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users

Reply via email to