From: Kevin G. <ele...@my...> - 2021-01-31 13:36:52
|
On 2021-01-31 12:58, Kevin Grant wrote: > Hello, > > I am re-using a subject line from the mailing list archive, by user > Marcin, in an attempt to append to that thread. > > https://sourceforge.net/p/pyusb/mailman/pyusb-users/thread/15e9538f-386f-a637-ce2b-5eea3d04bd76%40gmail.com/ > > I had a simlar issue recently with a simple test application which > opened a device and sent some OUT packets (to 512 size endpoint) thus: > > ..open device.. > for i in range(n): > dev.write(2,bytearray(os.urandom(512)) > ..close device.. > > On windows, this worked fine for any 'n' but on Linux only even 'n' > worked correctly. For odd 'n' one packet was always dropped/stuck. > As Marcin suggested, ending with dev.reset() seemed to flush this stuck > packet and fixed the issue. > But using reset in this way seems wrong. > After opening the device calling > dev.clear_halt(2) > Seemed to fix the issue. > > Regards > Kevin Ah, perhaps a better solution is to write a zero-length packet to signify end of data stream... ..open device.. for i in range(n): dev.write(2,bytearray(os.urandom(512)) dev.write(0x02, bytearray()) #ZLP end of data ..close device.. Regards Kevin |