-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
[(Probably) since Garmin Edge 1040 Solar Firmware Update] Uncaught TypeError: end(): Argument #1 ($array) must be of type array, null given #71
Comments
Dropping in my latest finding (and still hoping for this issue to relive): With the Edge Firmware mentioned my Garmin device now generates V2 FIT-files - previously those were V1. When I import and export them in/from Fit File Repair Tool they are converted to V1 - which seems to be what makes them parsable by php-fit-file-analysis... |
Hi @akberlin - this repo isn't really maintained any more. But let's see... The error appears to be with line 2478, i.e. Makes me suspect that What happens if you comment out the offending line and instead
|
Hi @adriangibbons - thanks for getting back.... I'll give it a try on wednesday... am in the process of reinstalling my webserver after a faulty WD SSD went dead with my Ubuntu system on it... I'll signal my findings with the var_dump... |
Hi again @adriangibbons - sorry for the late answer, not my style usually. Had some troubles buying the replacement SSD - NVMe-SSDs seem to be hard to get at the moment... server is up and running again.... sooooo: Yep, your assumption is right. With the V2 original file created by my Edge 1040 |
@akberlin If you take a look at the arrays of data, do you see an array that looks like speed?
|
@adriangibbons I did both options for both files (V2 originally created, V1 converted). Seemed to be easier to render the results into a PDF (see enclosed). |
@akberlin It seems that the V1 file uses Whereas the V2 file uses So the code on/around line 2478 needs to be enhanced to work out which to use. Maybe something like (quick hack): $tmp_speed = $this->data_mesgs['record']['speed'];
if ($tmp_speed === null) {
$tmp_speed = $this->data_mesgs['record']['enhanced_speed'];
}
$is_paused[$last_ts] = end($tmp_speed) == 0 ? true : false;
/* or maybe the below in PHP >= 7.4 */
$this->data_mesgs['record']['speed'] ??= $this->data_mesgs['record']['enhanced_speed'];
$is_paused[$last_ts] = end($this->data_mesgs['record']['speed']) == 0 ? true : false; // line 2478 unchanged, inserted the above |
I'd probably insert the below around line 1576 (i.e. the end of // Copy enhanced_xxx fields to plain boring non-enhanced records if they're not already set.
$this->data_mesgs['record']['speed'] ??= $this->data_mesgs['record']['enhanced_speed'];
$this->data_mesgs['record']['altitude'] ??= $this->data_mesgs['record']['enhanced_altitude']; |
@adriangibbons Wow. You're fast. I used your second suggestion and inserted the code right at the end of the function. This does prevent the exception from happening because speed and altitude are now filled and available. But when I try to access the session`s (and probably also lap's) avg_speed and max_speed they are NULL. |
Hi Adrian, hi community,
seems like Garmin have extended/changed something in the file format with a firmware update. (Or my Edge 1040 Solar is producing crap because of the new firmware. - Not sure actually!) Since then I happen to see these errors when importing FIT-files:
First obstacle was this:
when commenting out the section about gear changes (don't need them actually anyways) I see the same problem with pauses - but those I'd like to import...
My current bypass is using the "Fit File Repair Tool" - which seems to see this assumed file format extension as an error or correctly interprets the existing error and cleans the FIT-file which then runs smoothly.
Would be willing to provide original and repaired files but not as an attachment here... (home address visible)
Adrian, thanks for your superb framework and the support... Regards from Germany Andreas
The text was updated successfully, but these errors were encountered: