Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

You are here: Forum Home → ANT+ Forums → ANT-FS → Thread

   

PC ANTFSHost::Download fails if non-zero offset is used

Rank

Total Posts: 1

Joined 0

PM

I am attempting to use the low level ANTFSHOST code to support a command line interface that pulls files from any AntFS enabled device. I can access all files so long as I use a large enough buffer so that my starting download offset is always zero. However, if I use a smaller, fixed size buffer and then make repeated ANTFSHOST::download calls while incrementing my starting offset, the download fails.

The trace seems to indicate that the download processing does not understand how to properly calculate the end point when the starting offset is greater than zero. It fails to account for the initial offset and attempts to read past the end. The device (FR70 in this test case) does not respond with burst data. ANTFSHOST treats this as a download failure.

Has anyone else had this problem?      
Avatar
RankRankRankRank

Total Posts: 662

Joined 2012-10-09

PM

What version of the libraries are you using?

Is there a particular reason you need to download from specific offsets, rather than downloading the whole file (i.e., why do you need to limit the buffer size)?

Please post the debug logs generated by ANT-FS (ao_debug_... and Device0.txt), along with the snippet of code where you are calling the download.      
Rank

Total Posts: 1

Joined 0

PM

Attached is my sample driver code and corresponding trace.

Upon further research, it is definitely a problem with the last read in the set. So assume I am reading 256 byte chunks. For a 656 byte file, I read a chunk at offset 0, I read a second chunk at offset 256, and I read the third chunk at offset 512.
If I trim back the buffer size for the third chunk to exactly 144 (which matches the file size), then it all seems to work. But if I leave the buffer size at 256, and expect the system to truncate the request back to the last 144 bytes, then it fails. The system already knows the available file size, so I would think it would be reasonable for it to account for the size of the last request.

I am attempting to create a simple, minimal footprint app that uses a fixed buffer length and then dumps each buffer into a file (or out a socket, or into any other arbitrary data sink). I would prefer NOT to have to allocate a single buffer to handle the largest conceivable file, since I am working with a test device that has files of 32K.

Version info:
#define SW_VER_PPP "AKX"
#define SW_VER_NUM "0.3"
#define SW_VER_DEV "09"
#define SW_VER_BRANCH " " [file name=TestCase.zip size=10245]http://www.thisisant.com/images/fbfiles/files/TestCase.zip[/file]      
Avatar
RankRankRankRank

Total Posts: 662

Joined 2012-10-09

PM

From the log files, it looks like there are two problems here:
1) The host seems to have problems processing the last packet, where the length of the data block received from the client is shorter than what was requested. Even though the client responded correctly, the host is asking to download 0x70 bytes starting at offset 0x290. This seems like a bug in the host, as it should have reported download success instead; we will need to look into this. Thanks for bringing this to our attention.


2) The client is getting stuck in busy state instead of responding with a download response stating the request is invalid. This seems like a bug in the client (FR70).

One thing to note tho, the ANTFSHostChannel allocates the memory for the download data until it receives the download response from the client. GetTransferData just copies the data into another buffer, and you can use this function as well to figure out the size of the download before allocating memory for this buffer.