2013/1/14 Alan Jhonn Aguiar Schwyn <alan...@hotmail.com>:
>> From: wander.lair...@gmail.com
>> Date: Mon, 14 Jan 2013 21:37:02 -0200
>
>> To: pyusb-users@lists.sourceforge.net
>> Subject: Re: [pyusb-users] Overflow in bulkRead
>>
>> 2013/1/14 Alan Jhonn Aguiar Schwyn <alan...@hotmail.com>:
>> >
>> > I found the problem: I try to read 2 bytes, and the device was sending
>> > 3..
>> >
>> > And I test that: if you request 3 (and the device gives 2) no generates
>> > any
>> > problem.. the size of returned package is 2..
>> >
>> > Why in the other case yes?
>> >
>>
>> The device USB controller has already built a packet with 3 bytes, if
>> you request less than that, the device cannot breaks the package down,
>> so it fails.
>
> Yes. When I say "2 bytes" i'm saying: 2 bytes + 3 bytes of header)
> In my code:
>
> dev.read(READ_HEADER_SIZE + lenght)
>
>>If you are not sure about how many bytes you should
>> receive, it is often better to try to read "a packet size" bytes.
>
> Ever read 3 bytes? And check if there are 3 or only 2?
>

Every endpoint has a bMaxPacketSize field, which is the size of one
packet. Try to read bMaxPacketSize bytes.


-- 
Best Regards,
Wander Lairson Costa

------------------------------------------------------------------------------
Master SQL Server Development, Administration, T-SQL, SSAS, SSIS, SSRS
and more. Get SQL Server skills now (including 2012) with LearnDevNow -
200+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only - learn more at:
http://p.sf.net/sfu/learnmore_122512
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users

Reply via email to