From: Tim R. <ti...@pr...> - 2006-09-25 18:04:33
|
Szasz Pal wrote: >Is it possible to read data in packet mode? >Ie. right now if I read using bulk_read, it reads the required amount of > data, which might be split in several packets. But I want to limit the >read to 1 packet only. Is it possible somehow? (The reason is the device >adds two bytes at the beginning of each packet. So if the data I should >get is "MESSAGE", I might got 1 packet: > >0x11 0x22 "MESSAGE" > >but I might got 2 packets: >0x11 0x22 "MESS" >0x11 0x22 "AGE" > >And if I read using bulkread, i will read >0x11 0x22 "MESSAGE" >in the first casem and in the second case: >0x11 0x22 "MESS" 0x11 0x22 "AGE" > When you say "packet", do you really mean "USB packet"? It's up to you to know how large each packet is. If your pipe is configured for 64-byte packets, then just do the reads 64 bytes at a time. If your device really sends back variable-length USB packets, then you may have to scan for the cookie yourself. You may be able to set a short timeout and handle one packet at a time, but your performance is going to be very poor. -- Tim Roberts, ti...@pr... Providenza & Boekelheide, Inc. |