Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added count and minimum to get_analog_input_rawLE #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion motmot/fview_ext_trig/ttrigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,19 +429,25 @@ 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:
with self._lock:
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='<u2') # unsigned 2 byte little endian
buf = buf[:n_elements]
bufs.append(buf)
if n_bytes < EP_LEN:
if (n_bytes < EP_LEN) and (cnt >= min_cnt):
break # don't bother waiting for data to dribble in

if len(bufs):
outbuf = np.hstack(bufs)
else:
Expand Down