summaryrefslogtreecommitdiff
path: root/usrp/host
diff options
context:
space:
mode:
authoreb2006-12-19 22:54:23 +0000
committereb2006-12-19 22:54:23 +0000
commit781eb41b703f3b15c3106167e02e01cf0b336ffd (patch)
tree62a1825b131af37fd31d7a45cf05907aa525683f /usrp/host
parentf7400ffb7619ad96e5d23830408179093818568f (diff)
downloadgnuradio-781eb41b703f3b15c3106167e02e01cf0b336ffd.tar.gz
gnuradio-781eb41b703f3b15c3106167e02e01cf0b336ffd.tar.bz2
gnuradio-781eb41b703f3b15c3106167e02e01cf0b336ffd.zip
applied patch for ticket:115
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@4153 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'usrp/host')
-rw-r--r--usrp/host/lib/fusb_win32.cc74
1 files changed, 37 insertions, 37 deletions
diff --git a/usrp/host/lib/fusb_win32.cc b/usrp/host/lib/fusb_win32.cc
index 43c2d8baf..c6e3c972e 100644
--- a/usrp/host/lib/fusb_win32.cc
+++ b/usrp/host/lib/fusb_win32.cc
@@ -168,32 +168,32 @@ fusb_ephandle_win32::write (const void *buffer, int nbytes)
if (d_output_short == 0)
usb_submit_async(d_context[d_curr],
&d_buffer[d_curr*d_block_size], d_block_size);
-
- if (bytes_to_write == 0)
- return nbytes;
-
- assert(d_output_short == 0);
}
- d_curr = (d_curr+1)%d_nblocks;
- buf = &d_buffer[d_curr*d_block_size];
-
- if (d_outstanding_write != d_nblocks) {
- d_outstanding_write++;
- } else {
- retval = usb_reap_async(d_context[d_curr], USB_TIMEOUT);
- if (retval < 0) {
- fprintf(stderr, "%s: usb_reap_async: %s\n",
- __FUNCTION__, usb_strerror());
- return retval;
- }
- }
+ while (bytes_to_write > 0) {
+ d_curr = (d_curr+1)%d_nblocks;
+ buf = &d_buffer[d_curr*d_block_size];
+
+ if (d_outstanding_write != d_nblocks) {
+ d_outstanding_write++;
+ } else {
+ retval = usb_reap_async(d_context[d_curr], USB_TIMEOUT);
+ if (retval < 0) {
+ fprintf(stderr, "%s: usb_reap_async: %s\n",
+ __FUNCTION__, usb_strerror());
+ return retval;
+ }
+ }
- memcpy(buf, (void *) &(((char*)buffer)[a]), bytes_to_write);
+ int ncopy = std::min(bytes_to_write, d_block_size);
+ memcpy(buf, (void *) &(((char*)buffer)[a]), ncopy);
+ bytes_to_write -= ncopy;
+ a += ncopy;
- d_output_short = d_block_size - bytes_to_write;
- if (d_output_short == 0)
- usb_submit_async(d_context[d_curr], buf, d_block_size);
+ d_output_short = d_block_size - ncopy;
+ if (d_output_short == 0)
+ usb_submit_async(d_context[d_curr], buf, d_block_size);
+ }
return retval < 0 ? retval : nbytes;
}
@@ -224,27 +224,27 @@ fusb_ephandle_win32::read (void *buffer, int nbytes)
if (d_input_leftover == 0)
usb_submit_async(d_context[d_curr],
&d_buffer[d_curr*d_block_size], d_block_size);
-
- if (bytes_to_read == 0)
- return nbytes;
-
- assert(d_input_leftover == 0);
}
+ while (bytes_to_read > 0) {
- d_curr = (d_curr+1)%d_nblocks;
- buf = &d_buffer[d_curr*d_block_size];
+ d_curr = (d_curr+1)%d_nblocks;
+ buf = &d_buffer[d_curr*d_block_size];
- retval = usb_reap_async(d_context[d_curr], USB_TIMEOUT);
- if (retval < 0)
- fprintf(stderr, "%s: usb_reap_async: %s\n",
- __FUNCTION__, usb_strerror());
+ retval = usb_reap_async(d_context[d_curr], USB_TIMEOUT);
+ if (retval < 0)
+ fprintf(stderr, "%s: usb_reap_async: %s\n",
+ __FUNCTION__, usb_strerror());
- memcpy((void *) &(((char*)buffer)[a]), buf, bytes_to_read);
+ int ncopy = std::min(bytes_to_read, d_block_size);
+ memcpy((void *) &(((char*)buffer)[a]), buf, ncopy);
+ bytes_to_read -= ncopy;
+ a += ncopy;
- d_input_leftover = d_block_size - bytes_to_read;
- if (d_input_leftover == 0)
- usb_submit_async(d_context[d_curr], buf, d_block_size);
+ d_input_leftover = d_block_size - ncopy;
+ if (d_input_leftover == 0)
+ usb_submit_async(d_context[d_curr], buf, d_block_size);
+ }
return retval < 0 ? retval : nbytes;
}