php-fit-file-analysis icon indicating copy to clipboard operation
php-fit-file-analysis copied to clipboard

FatalErrorException: Unsupported operand types

Open robthompsonweb opened this issue 6 years ago • 5 comments

Getting the following error when using the attached FIT file with HR: _(1/1) FatalErrorExceptionUnsupported operand types in phpFITFileAnalysis.php (line 2713)

Using the latest master version - looks like $last_event_timestamp is an array of 2 elements rather than the expected integer but not sure how you match the correct version to use..

error3.txt Tried uploading to garmin connect and FIT file is working ok.

robthompsonweb avatar Feb 13 '18 14:02 robthompsonweb

Will take a quick look now but I think the wife is expecting some of my attention, given what day it is :)

Might be the weekend before I get to take a proper look...

Is the FIT file recorded with a different device? Cheers

adriangibbons avatar Feb 14 '18 10:02 adriangibbons

Haha no rush – was just flagging it.

Its from a Garmin fēnix 5X – the swim uploaded to garmin connect is https://connect.garmin.com/modern/activity/2497435759

From: Adrian Gibbons [email protected] Reply-To: adriangibbons/php-fit-file-analysis [email protected] Date: Wednesday, 14 February 2018 at 10:47 To: adriangibbons/php-fit-file-analysis [email protected] Cc: Rob Thompson [email protected], Author [email protected] Subject: Re: [adriangibbons/php-fit-file-analysis] FatalErrorException: Unsupported operand types (#45)

Will take a quick look now but I think the wife is expecting some of my attention, given what day it is :)

Might be the weekend before I get to take a proper look...

Is the FIT file recorded with a different device? Cheers

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

robthompsonweb avatar Feb 14 '18 10:02 robthompsonweb

The Garmin Connect page can't be viewed any longer.

Try inserting the following at line 2703

// Manually scale timestamps (i.e. divide by 1024)
$last_event_timestamp = $this->data_mesgs['hr']['event_timestamp'];
if (is_array($last_event_timestamp)) {
    $last_event_timestamp = $last_event_timestamp[0];
}

You might need to try $last_event_timestamp[1] if heart rate isn't working.

If this works then I'll commit the change to the project. Cheers, Adrian.

adriangibbons avatar Feb 21 '18 10:02 adriangibbons

Hey @robthompsonweb - do thing now work as expected for the file(s) throwing the error?

Cheers, Adrian.

adriangibbons avatar Feb 28 '18 05:02 adriangibbons

Yes so I did try it with [0] and [1] (not sure what data this is) which removes the error but only seems to give HR for half the activity (but garmin connect displays it for the whole activity).

Looking at the field record->heart_rate the last timestamp is 1518258007 - which is only about 1/3 through the activity (record->timestamp[988] out out of 3424) Json export of the data from the fit file in the original post.

The field hr->event_timestamp is a array with 2 elements which could have something to do with it (its only parsing the first event??) - looking at another file with HR hr->event_timestamp is a timestamp not array (attached single_event_hr_fit.txt ).

Will try digging a bit to see if I can figure out why when got a second

robthompsonweb avatar Mar 05 '18 13:03 robthompsonweb