Repository navigation
Conversation
fitjson dump writes every message and interpreted field as one JSON line, with Foundation-free formatting so the output can be compared byte for byte across platforms. GoldenTests compares it, in .fast and .generic, with references generated from 130dc1a on macOS: full dumps for samples up to 1 MB, SHA-256 plus counts for large.fit (scripts/golden-full.sh rebuilds the full dump to diff), and private samples from FITFILEPARSER_PRIVATE_SAMPLES. sample.fit and large.fit are copied from fit-benchmarks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The array join in FitInterpretMesg started from the second element (the first was overwritten before the string was built) and joined raw values before scale and offset. time_in_zone lost the bound and the time below zone 1, and times stayed in ms. Checked against fitdecode on the ski tour (98|119|143|161|183|201, 103.001|246.735|...) and leftrightbalancetest (power zones and times). Elements are now formatted with a plain C helper (%.15g, %.17g when needed to round-trip) instead of NSNumber, so the C port and Linux give the same text. Golden references change on purpose for .generic arrays only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…new baseline Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
First step of the Linux port: the target is becoming plain C. No client imports it (the app only uses the FitFileParser Swift API). The generator and fitsdkupdate.py write to the new folder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Objective-C class used NSDictionary/NSString/NSNumber, which do not exist for C on Linux. The Swift class keeps its name, so FitFile.devDataParser still compiles, with units() and nativeFields() public. Output is unchanged (golden tests identical), including behaviours of the original that are kept on purpose for now: - developer values of the last message that had some are reused for messages without (fit_convert only resets its buffer for the former) - units are only picked up once some message carried developer data - NSNumber conversions: uint32 wraps through Int32, floats never filtered - fallback name MESG_NUM_x_FIELD_y for a native message the profile lacks Reads stay inside the fixed-size name/unit arrays and the 256-byte buffer, and invalid UTF-8 names are skipped (the original raised on a nil key). Dropping the per-message NSDictionary bridge makes sample.fit faster (.fast 10.2 -> 7.7 ms, .generic 21.7 -> 16.9 ms, M5 Max). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fitsdkparser.py no longer emits the Objective-C string functions (rzfit_objc_field_num_to_string, string_from_<type>, unit/type_to_string): nothing used them since FitDevDataParser moved to Swift, which has its own generated name tables. What remains is plain C: - rzfit_c_field_info.c (was the field info half of rzfit_objc_map.m) - rzfit_c_reference_mesg.c/.h (was rzfit_objc_reference_mesg.m/.h) The generated code is otherwise identical (checked), 13.5k -> 3k lines. The FIT_INTERP_FIELD struct moves to a plain C header, fit_interpret.h, and the hand-written rzfit_objc_map.h becomes rzfit_c_field_info.h without Foundation. Golden tests identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FitInterpretMesg (Objective-C) becomes fit_interpret.c, a line for line translation: the NSMutableArray of dynamic strings is replaced by a byte buffer (offset/length per string, decoded in Swift, invalid UTF-8 gives as before), and loads go through memcpy instead of unaligned dereferences. A small Swift class owns the C state and keeps build_fit_message(). fit.c, fit_crc.c and fit_convert.c were C in .m files; the unused @import Foundation goes. The generated Swift files import Foundation themselves, since the C module no longer re-exports it. No Objective-C is left in the package. Golden tests identical (public and private samples, both modes). Back to back against 681aa12 (M5 Max, N=50, medians): sample.fit .fast 10.2 -> 7.4 ms, .generic 21.7 -> 12.7 ms; large.fit .fast 178 -> 88 ms, .generic 211 -> 111 ms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CLLocationCoordinate2D comes from CoreLocation where it exists and is a struct with the same name and fields elsewhere, so FitValue.coordinate keeps its source API. LinuxMain.swift (which imported a module that no longer exists) and XCTestManifests.swift go: test discovery is automatic. scripts/linux-test.sh runs the tests in the swift Docker image, with the private samples mounted read-only when FITFILEPARSER_PRIVATE_SAMPLES is set. On linux/arm64 (swift:6.4, 6.4.3) all 13 tests pass and the golden outputs are identical to the macOS references for all 11 samples, both modes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- macos: build and test (goldens included), checkout v4 - linux: swift:6.4.3 container, build and test (goldens must match the macOS references), fitjson bench for the log - static: Static Linux SDK 6.4.3 (official URL and checksum from swift.org, downloaded with curl and checked), x86_64-swift-linux-musl fitjson without debug info (57 MB) - static-check: the binary in php:8-cli, no Swift runtime, compared with the golden outputs Checked locally: the x86_64 static binary run in php:8-cli (emulated) gives byte-identical dumps for every public sample and mode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FIT_FIELD_INFO stored scale and offset as FIT_SINT16, and the generator only emitted integer scales. So .generic left fields raw or wrong: - training_load_peak (scale 65536 truncated to 0): 9616195 -> 146.73 - precise_target_speed (1000000 truncated to 16960): 395.4 -> 6.706 m/s - power phase / position (0.7111111 dropped): raw -> degrees, matching fitdecode (lap avg_left_power_phase 7.031250109863283|199.68750312011724...) - also pitch/roll/track, accel, gyro, fractional_timestamp, orientation Scale and offset are now doubles, emitted with the same rule as the .fast Swift formula (any single scale). Array elements print with the fewest of 15/16/17 digits that read back exactly. Golden references change on purpose for .generic only (public and private samples); .fast is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
objc-bridge.md becomes c-layer.md (plain C target, Swift interpreter owner and developer field parser, behaviours kept on purpose). code-generation, fit-file, fit-message and INDEX follow the port; linux-port.md records the commits, checks run (and not run) and the speed before/after. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The FIT invalid float is all bits set, a NaN, and the checks compared the value with it (val != FIT_FLOAT32_INVALID), which is always true for a NaN. So .generic returned NaN for invalid float fields, and the float64 case even compared with the float32 invalid. Compare the bit pattern instead, in the interpreter and for developer fields. Golden change: avg_flow and total_grit (session and lap, invalid in the samples) are no longer reported, as with the Garmin Python SDK and fitdecode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…DKs do The developer data of a message was assigned to field_descriptions by position (descriptions filtered by native message, in arrival order). That gave wrong values whenever a message did not list every such field in that order, and, in .generic, field_description itself was read as the generated struct although raw mode keeps fields in file order, so developer fields were lost unless the file happened to use the struct layout. Checked on devfields_synthetic.fit (new, scripts/make-devfields-sample.py) against the Garmin FIT Python SDK; the old code gave, in .fast, Alpha=25185 and Beta=99 (bytes of a string field), a spurious Gamma, the previous record's values on a record without developer data, and swapped, wrapped lap values; in .generic no developer field at all. Now: - fit_convert keeps each local message's developer field definitions (field number, size, developer data index; local patch) and dev_data_sizes and field_offset are 16 bits (a sum above 255 bytes wrapped and lost the position in the stream) - FitDevDataParser looks each one up by (developer data index, field number) and skips unknown, string and array fields by size; integers convert without wrapping; invalid values (0 for the z types) are dropped - fit_interp_to_reference rebuilds field_description from a raw message - units are recorded with each field_description, so every developer value has its unit (running.fit had none, the first 905 records of sample.fit none) Golden change: units added to the developer fields of running.fit, sample.fit and large.fit; values unchanged (they match the Garmin SDK on every record and lap). Tests pass under --sanitize=address. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The script compares fitjson dump (.generic) with the Garmin FIT Python SDK field by field, with the known conventions normalised. linux-port.md lists what the review fixed and what still differs; c-layer.md follows the developer field and invalid float fixes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft, opened to run CI on the Linux port. Not ready to merge.
fitjson dumpof every sample, both modes) pin the output; the port keeps it byte-identical on macOS and Linux.rzfit_c_*), interpreter in C,FitDevDataParserin Swift, CoreLocation shim.fitjsonCLI (dump,bench), static musl build checked inphp:8-cli..genericarrays keep element 0 and apply scale; scale/offset as double (training_load_peak, power phase,precise_target_speed)..fast178 → 88 ms,.generic211 → 111 ms on M5 Max).Plan and results:
designs/linux-port.md.🤖 Generated with Claude Code