Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

Problems encoding ‘string’ fields

Rank

Total Posts: 3

Joined 2013-11-20

PM

Hi,
I'm having trouble encoding .fit message fields that contain text.
I've also noticed that the C# EncodeDemo example fails for the same reason that my app fails.
Here's the C# code from EncodeDemo.cs that's raising an exception:

UserProfileMesg myUserProfile = new UserProfileMesg();
myUserProfile.SetGender(Gender.Female);
float myWeight = 63.1F;
myUserProfile.SetWeight(myWeight);
myUserProfile.SetAge(99);
myUserProfile.SetFriendlyName(Encoding.UTF8.GetBytes("TestUser"));
// +++> This last line throws an exception !!!

Here's the exception text:
System.InvalidCastException: Unable to cast object of type
'System.Byte[]' to type 'System.IConvertible'.

This problem also exists when trying to invoke the SetOpponentName() method for a 'Session' message.
I'm running MS Visual Studio 2010 with FIT SDK v9.02.
Please help.
Thanks,
skigrinder
     
RankRankRank

Total Posts: 91

Joined 2012-10-12

PM

-There is a bug. Depending on how long it takes to fix I will either build a special or roll the fix into the 9.10 release scheduled for the end of the month.

Regards
ShaneP      
Rank

Total Posts: 3

Joined 2013-11-20

PM

Hi Shane,
Thanks much for looking into this.
I'm not in a hurry for the fix.
End of the month would be great.
Please let me know if you need help in testing.
Thanks,
skigrinder      
RankRankRank

Total Posts: 91

Joined 2012-10-12

PM

-Try 9.10, it should resolve the issue you were seeing under C#. Please let me know if you see anything else strange.

Regards
ShaneP      
Rank

Total Posts: 3

Joined 2013-11-20

PM

Hi Shane,
Thanks for fixing this issue.
The byte[] fields are working for me now.

Is there a limit to the number of text characters in a byte[] field?
I get errors with long text.

Is there a byte[] field in any .fit message that allows for long text content?
I'd like to let the user enter free form notes for an activity and store these somewhere in the .fit file.

Thanks,
skigrinder      
RankRankRank

Total Posts: 91

Joined 2012-10-12

PM

FIT doesn't directly support freeform content since each field is constrained to a max size of 256 bytes, something the SDK likely doesn't guard you from at this time. You will need to break your message into blocks <256bytes and send over multiple messages.
     
RankRankRank

Total Posts: 91

Joined 2012-10-12

PM

-Since this seems like a pretty reasonable thing to do I will look at adding an 'official' mesg to the FIT profile that could be used for freeform text data.

ShaneP      
RankRankRank

Total Posts: 91

Joined 2012-10-12

PM

-See AN18 (available at page http://www.thisisant.com/developer/resources/downloads/#documents_tab) for a suggested method of encoding large text blocks using .FIT