From 40787da734a2cf522a10268467014f5ac14ec76b Mon Sep 17 00:00:00 2001 From: Will Dickson Date: Wed, 20 Oct 2010 19:55:09 -0700 Subject: [PATCH] Added a count and minimum to get_analog_input_buffer_rawLE to ensure that the usb endpoint is read a minimum number of times. The minimum is currently set to 2. --- motmot/fview_ext_trig/ttrigger.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/motmot/fview_ext_trig/ttrigger.py b/motmot/fview_ext_trig/ttrigger.py index 6531e0b..a2de555 100644 --- a/motmot/fview_ext_trig/ttrigger.py +++ b/motmot/fview_ext_trig/ttrigger.py @@ -429,6 +429,10 @@ def get_analog_input_buffer_rawLE(self): bufs = [] got_bytes = False timeout = 50 # msec + + cnt = 0 # Count number of times endpoint has been read + min_cnt = 2 # Minimum number of times end point should be read + while 1: # keep pumping until no more data try: @@ -436,12 +440,14 @@ def get_analog_input_buffer_rawLE(self): n_bytes = usb.bulk_read(self._libusb_handle, (ENDPOINT_DIR_IN|ANALOG_EPNUM), INPUT_BUFFER, timeout) except usb.USBNoDataAvailableError: break + cnt += 1 n_elements = n_bytes//2 buf = np.fromstring(INPUT_BUFFER.raw,dtype='= min_cnt): break # don't bother waiting for data to dribble in + if len(bufs): outbuf = np.hstack(bufs) else: