Code Monkey home page Code Monkey logo

garmin-fit's Introduction

mrihtar stats mrihtar langs

garmin-fit's People

Contributors

eserte avatar kkzst avatar mrihtar avatar pau4o avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

garmin-fit's Issues

fit2gpx.pl didnt parse fit file at all

I was just playing around with some sample FIT files and for most of them it "somehow" works but one was not parsed at all -> It is attached -> Maybe could you check on it what happened ?

Thanks,

TkTz
Laufen.zip

fitdump.pl message_index Support (text and JSON)

There are now 10 messages for bike_profile with message_number=6 in Settings.fit. Each of these messages has a message_index field which contains the sub-field mask which contains what appears to be a valid index value.

bike_profile (6, type: 0, length: 81 bytes):
    name (0-16-STRING): "Bike 10"\n
    message_index (254-1-UINT16): selected=0,reserved=0,mask=9 (9)
    ...

It's unclear how one might reference a specific index of a single message_number.

Is this supported?

import virtual Ride from Zwift via Garmin

Today I tried to import a virtual ride from zwift. The file was uploaded to garmin and I downloaded it from there as usual. But then I am always geting an error. (line 260)
I am looking forward to also import my virtual rides.
Thanks for your work on this tool!
2269877207.zip

Add Shimano Di2 shift count support and Edge sweat loss units

I am not skilled enough to make changes here (yet), but I found that editing my download of the FIT.pm file to make this diff then the fitdump output shows Di2 shifting counts and the Garmin Edge1030 sweat loss summary:

5261,5262c5261,5262
< 107 => +{'name' => 'front_gear_change_count'},
< 108 => +{'name' => 'rear_gear_change_count'},

 107 => +{'name' => 'unknown107'}, # unknown UINT16
 108 => +{'name' => 'unknown108'}, # unknown UINT16

5291d5290
< 178 => +{'name' => 'sweat_loss', 'unit' => 'ml'},

I hope that someone might add this to the code so it would be useful to others.

can't convert fit File exported from FitFileRepairTool

Hello mrihtar,
I have a problem to convert a FIT-File exported from FitFileRepairTool (http://fitfilerepairtool.info/).
The FIT-File was original created as an export in BKOOL-Bike Trainer Software.
But it contains 2 Rounds, so I load this file inte the FitFileRepairTool, to concatinate the 2 Rounds to one. After this I make an export also into a new FIT-File.
When I start the pearl-script to convert the new File it stops whit an error-message:
"Use of uninitialized value in concatenation (.) or string at ./fit2slf_orig.pl line 258"
Can you anlyse this problem?
(See Fit-File inthe attachment)
a5520321.fit.zip

Best regards Walter

custom ini file

Please can you specify config file path as parameter ? If would be helpfull, instead of using current dir.

Thank you.

Small typo

diff.txt

the string $p:: is interpreted as a variable name rather than the variable $p followed by two colons. Add braces to remove the ambiguity and avoid a warning.

Can't convert fit-File from Wahoo Elemnt

first thank you to mrihtar for develop and programing this utility.

I use the perl-file fit2slf.pl to convert my workouts from fit-file-format to slf-file-format.
After converting, I import them into the Sigma Data Center. This works very fine till the last firmware update of the wahoo elemnt.
When I try to convert the fit-file now, I get an error:
"Can't use an undefined value as a HASH reference at ./fit2slf.pl line 414".

Can you please take a look at this problem?

I can sent you an example file in the old and the new export format of the wahoo elemnt.

best regards streamtec

Problems with big endian

The perl module has some problems with big endian values.

  • The parser will fail for big endian files with array-valued fields (such as for hrv)
  • The parser will fail on big endian systems
    • see Runalyze/Runalyze#1875 for a related issue
    • message numbers will be wrong
    • for a fix:
      • $endian != $my_endian should be $endian (#L4780, #L4828, #L4868)
      • add $v = reverse $v if ref $desc->{endian_converter} eq 'ARRAY'; to #L4927

I can add a pull request for this, but I don't have a big endian system to check and a final confirmation that the last point fixes wrong ordering of arrayed-valued fields is still missing (see https://github.com/Runalyze/Runalyze/issues/1875#issuecomment-234050418).

PS: Thanks for having a repo for Kiyokazu's perl module!

Error when converting a fit file from wahoo element with actual firmware

Hello mrihtar,
today I want to convert a fit file from my wahoo elemnt.
There was an firmware update since last converting a file.
I get this error-message:
"Use of uninitialized value $prev_timestamp in subtraction (-) at ./fit2slf_orig.pl line 1438.
Illegal division by zero at ./fit2slf_orig.pl line 1446."
Can you have a look where's the problem?
I have attached the FIT-File.
ELEMNT.fit.zip

File causing endless loop

We got a file resulting in an endless loop: endless-loop.zip

I'm not sure what's wrong with the file, as Garmin's FitToCSV.bat can't convert it:

FIT CSV Tool - Protocol 2.0 Profile 20.81 Release
Exception in thread "main" java.lang.RuntimeException: com.garmin.fit.FitRuntim
Exception: FIT decode error: Endian 118 not supported. Error at byte: 242
        at com.garmin.fit.csv.CSVTool.run(CSVTool.java:238)
        at com.garmin.fit.csv.CSVTool.main(CSVTool.java:324)
Caused by: com.garmin.fit.FitRuntimeException: FIT decode error: Endian 118 not
supported. Error at byte: 242
        at com.garmin.fit.Decode.read(Decode.java:770)
        at com.garmin.fit.Decode.resume(Decode.java:371)
        at com.garmin.fit.Decode.read(Decode.java:348)
        at com.garmin.fit.csv.CSVTool.run(CSVTool.java:212)
        ... 1 more

Still, having an endless loop crashes the whole process. The following patch fixes the issue for us:

diff --git a/Garmin/FIT.pm b/Garmin/FIT.pm
--- a/call/perl/Garmin/FIT.pm
+++ b/call/perl/Garmin/FIT.pm
@@ -7608,7 +7608,7 @@ sub fetch {
       $desc_i = ($rechd & $rechd_mask_cth_local_message_type) >> $rechd_offset_cth_local_message_type;
     }
     elsif ($rechd & $rechd_mask_definition_message) {
-      $self->fetch_definition_message;
+      $self->fetch_definition_message || return undef;
     }
     else {
       $desc_i = $rechd & $rechd_mask_local_message_type;
@@ -7621,7 +7621,7 @@ sub fetch {
       my $desc = $self->data_message_descriptor->[$desc_i];
 
       if (ref $desc eq 'HASH') {
-        $self->fetch_data_message($desc);
+        $self->fetch_data_message($desc) || return undef;
       }
       else {
         $self->error(sprintf("%d at %ld: not defined", $rechd, $j));

fit2slf.pl command does not work

Hi, I saw your entry in the German MTB news forum. Great tool. After installing Strawberry Perl on Win64 and the 3 Modules (and a reboot of the PC), I get the following error message. Any idea what went wrong ? Thank you.

C:>cd Strawberry

C:\Strawberry>dir
Volume in Laufwerk C: hat keine Bezeichnung.
Volumeseriennummer: 2099-FEC9

Verzeichnis von C:\Strawberry

16.10.2016 13:57

.
16.10.2016 13:57 ..
16.10.2016 12:22 c
16.10.2016 12:29 cpan
11.05.2016 00:56 11.807 DISTRIBUTIONS.txt
16.10.2016 12:43 42.513 fit2slf.ini
16.10.2016 12:40 511.021 fit2slf.pl
16.10.2016 12:44 99.829 fitdump.pl
16.10.2016 12:54 Garmin
16.10.2016 12:23 licenses
16.10.2016 12:22 perl
16.10.2016 12:23 2.119 README.txt
16.10.2016 12:23 23.783 relocation.txt
15.10.2016 17:07 314.842 test.fit
16.10.2016 12:23 win32
7 Datei(en), 1.005.914 Bytes
8 Verzeichnis(se), 141.501.394.944 Bytes frei

C:\Strawberry>fitdump.pl
Bareword found where operator expected at C:\Strawberry\fitdump.pl line 6, near ""en" class"
(Missing operator before class?)
Bareword found where operator expected at C:\Strawberry\fitdump.pl line 22, near "<title>Garmin"
(Missing operator before Garmin?)
Can't modify numeric lt (<) in scalar assignment at C:\Strawberry\fitdump.pl line 6, near ""en" class"
syntax error at C:\Strawberry\fitdump.pl line 6, near ""en" class"
Unrecognized character \xC2; marked by <-- HERE after at master <-- HERE near column 44 at C:\Strawberry\fitdump.pl line 22.

C:\Strawberry>fit2slf.pl
Bareword found where operator expected at C:\Strawberry\fit2slf.pl line 6, near ""en" class"
(Missing operator before class?)
Bareword found where operator expected at C:\Strawberry\fit2slf.pl line 22, near "<title>Garmin"
(Missing operator before Garmin?)
Can't modify numeric lt (<) in scalar assignment at C:\Strawberry\fit2slf.pl line 6, near ""en" class"
syntax error at C:\Strawberry\fit2slf.pl line 6, near ""en" class"
Unrecognized character \xC2; marked by <-- HERE after at master <-- HERE near column 44 at C:\Strawberry\fit2slf.pl line 22.

C:\Strawberry>fit2slf.pl test.fit
Bareword found where operator expected at C:\Strawberry\fit2slf.pl line 6, near ""en" class"
(Missing operator before class?)
Bareword found where operator expected at C:\Strawberry\fit2slf.pl line 22, near "<title>Garmin"
(Missing operator before Garmin?)
Can't modify numeric lt (<) in scalar assignment at C:\Strawberry\fit2slf.pl line 6, near ""en" class"
syntax error at C:\Strawberry\fit2slf.pl line 6, near ""en" class"
Unrecognized character \xC2; marked by <-- HERE after at master <-- HERE near column 44 at C:\Strawberry\fit2slf.pl line 22.

Problem with time_created

Hi,

till last year the time_created element of the exported Garmin swim file had both a human readable date and a numeric version.
The latest file I downloaded however only provides me with the numeric version: how can I transform it to a date as before?

5629129253.fit.zip

Thankx a lot!

fitdump.pl: JSON output

I'm trying to do some data analysis of .fit files and I love Garmin::FIT for helping me with this. But not being a Perl developer by trade, it would be really slick if fitdump.pl had a --json option or some way to output the data as JSON. Ideally, you'd output basically an array of objects and each object would correspond with the type of data it corresponds to. I will look into submitting a PR for this in the meantime but I figured I'd start here to get your opinion, and possibly save time by having an expert knock it out.

Thanks again for this awesome library.

Missing Lap and Pause information in .slf file

@mrihtar , translation works now perfect but some information is missing in the .slf file.
The information about laps and break times are not visible in the Data Center.
Would that something be you could implement in your script?

No lap, No auto pause, wrong power

Hi,
I convert a ride today with the "fit master", and I don't have a lap, no auto pause, and the power is wrong (I've a power metter)
Can you help me with this?
Regards

Newer profiles

I have FIT files that show protocol ver: 1.00, profile ver: 20.44 and when dumping them there are quite a few unknown values... what's the process by which this library gets updated to newer versions?

Missing Values in GPX file

I miss the speed and distance node in the resulting gpx-file. When i make a dump2text the values where there.
The source is a garmin .fit from Edge 130 Plus.

Bildschirmfoto vom 2023-02-19 18-10-34
Bildschirmfoto vom 2023-02-19 18-06-25

Upload to CPAN?

It would be nice if this distribution was also available on CPAN. If you agree with this, and need some help, then I can provide a pull request with the required changes (a Makefile.PL, maybe a basic test suite etc.)

fit2gpx.pl writes lat="0" lon="0" if position is not defined in fit file

In gpx files generated by fit2gpx.pl, I find points with zero longitude and zero latitude. Identifing the respective point in the fitdump.pl output via timestamp (timezone considered correctly) shows, that location information was not provided in this case. See below for respective data from dump and gpx file.

fitdump.pl output:
record (20, type: 1, length: 19 bytes):
timestamp (253-1-UINT32): 2019-02-13T12:39:05 (918992345)
distance (5-1-UINT32): 8060.45 m (806045)
altitude (2-1-UINT16): 521.8 m (5109)
xxx87 (87-1-UINT16): 0
xxx88 (88-1-UINT16): 300
heart_rate (3-1-UINT8): 157 bpm (157)
cadence (4-1-UINT8): 86 rpm (86)
temperature (13-1-SINT8): 17 deg.C (17)
fractional_cadence (53-1-UINT8): 0.00 rpm (0)

corresponding fit2gpx.pl output
<trkpt lat="0" lon="0"> <ele>521.8</ele> <time>2019-02-13T11:39:05Z</time> <extensions> <gpxtpx:TrackPointExtension> <gpxtpx:hr>157</gpxtpx:hr> <gpxtpx:cad>86</gpxtpx:cad> <gpxtpx:atemp>17</gpxtpx:atemp> </gpxtpx:TrackPointExtension> </extensions> </trkpt>

example.zip

Localized month names may be problematic

A today's conversion of a fit file using fit2gpx.pl and a German locale created an invalid XML file due to

        <name>Track 19-Mär-23 11:58</name>

where the umlaut-a was in iso-8559-1 encoding, not in utf-8 encoding.

Suggestions:

  • I think ISO8601 datetimes are the best option nowadays. So the strftime format in
    $f_startTime = POSIX::strftime("%d-%b-%y %H:%M", @lt);
    is probably better rewritten to "%FT%T" or so
  • Alternatively keep the %b format, but make sure that it's at some point converted to utf-8, either by using something like binmode(TMP, ':utf8') or Encode::encode_utf8 or so.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.