Ticket #115 (defect)

Opened 2 years ago

Last modified 2 years ago

usrp read fails on Windows when nbytes > block_size

Status: closed (fixed)

Reported by: dward Assigned to: eb
Priority: normal Milestone: release-3.0.3
Component: usrp Version: 3.0svn
Keywords: windows cygwin mingw Cc: don2387ward@sprynet.com

usrp_spectrum_sense.py with default options fails on Windows with either Cygwin or MSYS/MinGW (Python exits with no messages). I have traced the execution to fusb_ephandle_win32::read() where it reads d_block_size (4096 in this case) bytes then copies nbytes (bytes requested in call---16384 in this case) into the return buffer and sets

  d_input_leftover = d_block_size - bytes_to_read;

In the next call, if (d_input_leftover != 0) it then copies more already-read bytes. But when bytes_to_read (==nbytes) is greater than d_block_size, garbage is copied on the first read, d_input_leftover is set to a negative value, and the program exits (don't know why) before returning from the second read.

I would be happy to work on fixing this, but I would need to know whether fusb_ephandle_win32::read() is allowed to return fewer bytes than requested or if must (or should, for efficiency) return the requested count.

Attachments

fusb_win32.patch (3.0 kB) - added by dward on 12/18/06 08:44:54.
patch fusb_win32.cc to fix ticket 115

Change History

12/15/06 18:39:26: Modified by eb

  • owner changed from matt to eb.
  • status changed from new to assigned.

Hi Don, It is OK for read to return fewer bytes than requested. Definitely better than copying bogus data!

It will probably trigger this message in usrp1_source_base.cc

    fprintf (stderr, "usrp1_source: short read.  Expected %d, got %d\n",
	       nbytes, result_nbytes);

This message should probably be disabled.

Thanks for working on this. Please generate a patch. Eric

12/18/06 08:44:54: Modified by dward

  • attachment fusb_win32.patch added.

patch fusb_win32.cc to fix ticket 115

12/18/06 08:54:18: Modified by dward

With the attached patch, enough blocks are read to return the requested number of bytes. The patch also fixes a similar problem with writing data. While this patch allows small packets to be used, I find that they require much more cpu time (on Windows) than large packets, and using enough small packets to prevent overruns can cause long delays (many seconds; for system cleanup?) after the program exits.

The patch has been tested on Cygwin and MinGW/MSYS.

12/19/06 15:55:17: Modified by eb

  • status changed from assigned to closed.
  • resolution set to fixed.

Patch applied in r4153.

02/07/07 13:14:54: Modified by jcorgan

  • milestone changed from to-be-decided to release-3.0.3.