Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All values are default values in new fields added with fitgen #76

Open
jsliacan opened this issue Jan 26, 2023 · 7 comments
Open

All values are default values in new fields added with fitgen #76

jsliacan opened this issue Jan 26, 2023 · 7 comments

Comments

@jsliacan
Copy link

I'm not sure if this is an issue, but I need help figuring out why all values from radar_current, radar_speeds, etc. fields that I added with fitgen default to max uint8 or uint16 as I define them. The values from other fields are parsed correctly (e.g. HR or distance). I apologize in advance if this is a user error!

Let's focus on radar_current (which is the current count of cars coming up from behind registered by Garmin radar). See the file displayed below. The last entry is 20.

image

I defined radar_current as uint8. See SDK's Profile.xlxs screenshot:

Screenshot from 2023-01-26 12-09-25

Once I regenerate a few files with fitgen and I tell go about it with replace github.com/tormoder/fit => /home/jsliacan/Github/fit in go.mod, I run a modified example code from here:

for _, record := range activity.Records {
where I extract the last entry in the radar_current field in the record (snippet below). I expected to see 20 but I get 255. However, for hr field (which I didn't generate with fitgen) I get the correct value of 114.

var numCars, hr int
for _, record := range activity.Records {
    numCars = int(record.RadarCurrent)
    hr = int(record.HeartRate)
}
fmt.Println(hr, numCars)

Any help appreciated.

@tormoder
Copy link
Owner

I'll need to take a closer look, but you're sure field def numbers are correct? (190, 191 and 192.)

@jsliacan
Copy link
Author

but you're sure field def numbers are correct? (190, 191 and 192.)

I chose them at will from between 0 and 255, paying attention to having them unique (within the Profile.xlsx file). I can't find any information on this, are they pre-defined somewhere? I'm not having much luck finding anything about radar_current, for instance. Either online, in SDK files, or in the repo. Thanks

@tormoder
Copy link
Owner

tormoder commented Feb 2, 2023

They'll need to match the field def numer they're encoded with in the file. It looks like these are undocumented/"hidden", and not present in the SDK specification.

What did you use to generate the file overview in your issue?

You can try to decode the file with debug logging, and then look at the different field defintions to get at hint about field def numbers. See this decode option:

fit/opts.go

Line 27 in a5da86a

func WithStdLogger() DecodeOption {

@jsliacan
Copy link
Author

jsliacan commented Feb 6, 2023

Thanks for your time and all the info! I'll probably just transform the file to CSV and read it that way, seems easier at this point. I can see all the fields and correct values in a csv.

What did you use to generate the file overview in your issue?

I just loaded my file over here: https://www.fitfileviewer.com/. Seems to work OK, not sure what they do behind the scenes.

You can try to decode the file with debug logging, and then look at the different field defintions to get at hint about field def numbers.

Many thanks for the tip! The project is actually about the data in the fit files, so I'll move onto that now. I didn't know the radar fields are so non-standard, I expected it to work out of the box... And thanks for the fit module btw.

Feel free to close the issue any time.

@jsliacan
Copy link
Author

jsliacan commented Feb 7, 2023

Hi again,

So I looked at it a bit more and it seems that there is something called "Developer Data Fields", which you probably know, described here.. I can't work out how to access those using your fit module, e.g. developer field # 2 (with value 20 in the entry below, obtained in python).

{'timestamp': datetime.datetime(2023, 1, 12, 19, 49, 41, tzinfo=datetime.timezone.utc), 'position_lat': 696972206, 'position_long': 185899572, 'distance': 30808.85, 'altitude': 60.200000000000045, 'speed': 0.0, 88: 100, 'heart_rate': 114, 'temperature': 21, 'enhanced_speed': 0.0, 'enhanced_altitude': 60.200000000000045, 'developer_fields': {0: [0, 0, 0, 0, 0, 0, 0, 0], 1: [0, 0, 0, 0, 0, 0, 0, 0], 2: 20, 3: 0, 4: 0}}

They seem to have definition numbers which are "local" in the sense that if I use them in the Profile.xlsx file, then run fitgen to generate code, there is a duplicate index in the slice in profile.go. That makes sense (EDIT: esp since these dev fields are supposed to eliminate the need for going through editing Profile.xlsx, running fitgen, etc.), but I can't think of a way to access these developer fields with your fit module. I'm assuming this is possible, but I might be wrong. Could you please give me a few more pointers here? As usual, any help is much appreciated! Thanks

PS: when I decode the fit file with java -jar FitDecodeExample.jar file_from_Forerunner645.fit I get a very readable output (including all records and fields in it), and towards the top I see these Dev Field Descriptions:

New Developer Field Description
   App Id: c5d949c3-9acb-4e00-bb2d-c3b871e9e733
   App Version: 51
   Field Num: 0
New Developer Field Description
   App Id: c5d949c3-9acb-4e00-bb2d-c3b871e9e733
   App Version: 51
   Field Num: 1
New Developer Field Description
   App Id: c5d949c3-9acb-4e00-bb2d-c3b871e9e733
   App Version: 51
   Field Num: 2
New Developer Field Description
   App Id: c5d949c3-9acb-4e00-bb2d-c3b871e9e733
   App Version: 51
   Field Num: 5
New Developer Field Description
   App Id: c5d949c3-9acb-4e00-bb2d-c3b871e9e733
   App Version: 51
   Field Num: 6

Also, towards the end of the file, there's another one (an extra, which does not correspond to any of my radar fields):

New Developer Field Description
   App Id: c5d949c3-9acb-4e00-bb2d-c3b871e9e733
   App Version: 51
   Field Num: 3

@tormoder
Copy link
Owner

Data Developer Fields are not supported fully be this libary yet.

It supports parsing files containing them (i.e. parse files containing them without crashing), but they're not parsed/available yet.

I'm want and plan to support them, but have not had the time to work on the feature. There is a fork that supports them (I think), https://github.com/hammerheadnav/fit, and I hope I may integrate some of that work.

That being said, I'm not clear to me if the radar field you mention is a Data Developer Field or just an "undocumented" SDK profile field.

@jsliacan
Copy link
Author

@tormoder thanks for the info and your work around here! Feel free to close this issue as you prefer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants