Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

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

   

Can’t not create instance ANTFS_Directory correctly

Rank

Total Posts: 29

Joined 0

PM

Hi Forks,
I encounter a strange problem, I use the ANT_NET library try to download the data from an ant watch. When I donwload the directory from the watch by using and using ANTFS_Directory (byte[] data) to construct the directory object it produce an exception say it add a same existing key into a collection ('System.ArgumentException").
However, I can list the directory by using ANTFS PC Host program.
Any hint is appreciate.
Best regards,
tony
     
Avatar
RankRankRankRank

Total Posts: 662

Joined 2012-10-09

PM

That basically means that two directory entries with the same index are present , which is not valid.

The PC Host uses a different implementation for parsing the directory from a byte array, essentially just casting the downloaded data into a struct, while the C# implementation does some validation on it.      
Rank

Total Posts: 29

Joined 0

PM

Is there anyway to walk around this situation using C# ?
Best regards,
tony

     
Avatar
RankRankRankRank

Total Posts: 662

Joined 2012-10-09

PM

No, the C# library stores the directory in a dictionary to make it easy to retrieve individual entries by index, and it is not possible to have duplicate keys in a dictionary. The raw data is still available from the download data, so you could try parsing it manually (refer to the ANT-FS Technology Specification for details on the format of the directory), and remove the offending duplicate entry before creating the ANTFS_Directory instance. Having two entries with the same index is not valid anyway because it introduces ambiguity - if the host requests a download for that index, which file is it going to get?

Is the client that you are downloading from a commercial ANT+ product? Does the PC host show entries with duplicate indexes when displaying the directory from this device?      
Rank

Total Posts: 29

Joined 0

PM

Dear alejandra,
Thanks for your reply I am really appreciate.
The product is not commercialized yet,
So, now all I need to do is clear the data in the flash.
Thanks for your help.
Best regards
Tony