feat(dive detail): implement parse of raw data on Windows#345
Open
essengee wants to merge 3 commits into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements Windows support for parsing raw dive computer binary blobs (stored in SQLite) into structured ParsedDive data, and adds a native C test to validate the wrapper’s error handling and “happy path” parsing.
Changes:
- Implement
ParseRawDiveDataon Windows by callinglibdc_parse_raw_diveand converting the resultinglibdc_parsed_dive_tinto a PigeonParsedDive. - Add a native C test (
test_parse_raw_dive) that exercises invalid-argument handling, unknown-descriptor errors, and a real fixture parse. - Extend the native test CMake setup to build/link the new test with wrapper + libdivecomputer sources.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/libdivecomputer_plugin/windows/dive_computer_host_api_impl.cc | Implements raw dive parsing on Windows via libdc_parse_raw_dive and returns ParsedDive/FlutterError. |
| packages/libdivecomputer_plugin/test/native/test_parse_raw_dive.c | Adds native parsing tests (invalid args, unknown descriptor, real fixture). |
| packages/libdivecomputer_plugin/test/native/CMakeLists.txt | Adds a new native test target and wires it into CTest, including platform config selection. |
Comment on lines
+166
to
+170
| int rc = libdc_parse_raw_dive( | ||
| vendor.c_str(), product.c_str(), | ||
| static_cast<unsigned int>(model), | ||
| data.data(), static_cast<unsigned int>(data.size()), | ||
| &dive, error_buf, sizeof(error_buf)); |
Comment on lines
+9
to
+20
| static unsigned int load_fixture(const char *path, unsigned char **out) { | ||
| FILE *f = fopen(path, "rb"); | ||
| if (!f) return 0; | ||
| fseek(f, 0, SEEK_END); | ||
| long len = ftell(f); | ||
| fseek(f, 0, SEEK_SET); | ||
| if (len <= 0) { fclose(f); return 0; } | ||
| *out = (unsigned char *)malloc((size_t)len); | ||
| size_t read = fread(*out, 1, (size_t)len, f); | ||
| fclose(f); | ||
| return (unsigned int)read; | ||
| } |
|
|
||
| # Collect libdivecomputer sources needed for parsing (exclude platform I/O | ||
| # files that don't compile cross-platform). | ||
| file(GLOB LIBDC_ALL_SOURCES "${LIBDC_DIR}/src/*.c") |
Resolve the conflict in the native test CMakeLists.txt registry by taking the union of both sides' added test targets: main's test_descriptor_match_integration and test_hw_ostc3_read alongside this PR's test_parse_raw_dive (with all three add_test registrations). No content from either side is dropped.
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.
Summary
Parsing raw dive data stored in the SQLite db was not implemented for Windows. This PR resolves that.
Changes
Test Plan
flutter testpassesflutter analyzepasses