Skip to content

Feat splitter refactor#329

Merged
nitin710 merged 20 commits intodevfrom
feat-SplitterRefactor
Sep 11, 2025
Merged

Feat splitter refactor#329
nitin710 merged 20 commits intodevfrom
feat-SplitterRefactor

Conversation

@Joseph-Jacobson
Copy link
Contributor

@Joseph-Jacobson Joseph-Jacobson commented Jul 14, 2025

Description

This PR moves the packet splitter functionality into sendData, out of EmotiBitWifi and writeSdCardMessage. This sets us up to split packets in a single spot, so when we enable Bluetooth we won't add yet another splitter.

  • Debugger commands is added to allow for greater control
  • Added PacketFixedLengthTest to check the new splitting functionality
  • New error handler if writeSdCardMessage receives a packet over 512. Now a Data Overflow packet is now printed with a payload of the intended payload length.

Requirements

To run this branch you need:

  • FeatherWing 1.14.1
  • XPlat 1.7.2

PR #30

Issues Referenced

Documentation update

None

Notes for Reviewer

  • The data splitter in EmotiBitWiFi sendUDP is moved into EmotiBit sendData. The WiFi splitter was chosen over the splitter in writeSdCardMessage as it splits based on the delimiter.
  • Added flexibility to testing, letting us choose the tests to run during run time via the debugger. A table for the added modes/changes is provided below.
Command Details
> Sets "sendTestData" to true
< Sets "sendTestData" to false
@ Sets test data to Packet Fixed Length Test
# Sets test data to Sawtooth (this is also the default)
SplitterTesting drawio

Testing

Please follow "Packet Fixed Length Test" in the "EmotiBit Feature Test Protocols" document. This has been updated with the new changes

Results

  • ✅PacketFixedLengthTest determines if the error is generated

Detailed results located in PR #30

Feature Tests

Shared files

  • Firmware binary: [Link to firmware binary]
  • Other files.

Checklist to allow merge

  • All dependent repositories used were on branch master
  • Software
    • Get approval from the reviewer
    • Passed testing on Windows
    • Passed testing on macOS (for major changes/GUI changes/ PRs adding files distributed with the EmotiBit software)
    • Passed testing on linux (ubuntu) (for major changes/GUI changes/ PRs adding files distributed with the EmotiBit software)
    • Update software bundle version in ofxEmotiBitVersion.h
  • Firmware
    • Set testingMode to TestingMode::NONE
    • Set const bool DIGITAL_WRITE_DEBUG = false (if set true while testing)
    • Update version in EmotiBit.h
    • Update library.properties to the correct version (should match EmotiBit.h)
  • doxygen style comments included for new code snippets
  • Required documentation updated

Screenshots:

Summary by CodeRabbit

  • New Features
    • Improved data processing flow with chunked wireless transmission and SD writes.
    • Added overflow detection for SD writes with clear error logging.
    • Expanded debug controls to enable/disable test data and select test patterns.
  • Bug Fixes
    • More reliable trigger handling without consuming input bytes.
    • Corrected debug logging to show the active data type.
  • Documentation
    • Added guide for the Packet Fixed Length Test.
  • Tests
    • Added script to verify absence of Debug Overloads in recorded data.
  • Chores
    • Bumped version to 1.14.1.

@nitin710 nitin710 changed the base branch from 1.12.1.feat-blePrototype-Example to dev July 14, 2025 23:44
@Joseph-Jacobson Joseph-Jacobson requested a review from nitin710 July 15, 2025 00:23
@Joseph-Jacobson Joseph-Jacobson marked this pull request as ready for review July 16, 2025 16:01
Copy link
Collaborator

@nitin710 nitin710 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review 01

- removed constant print infos in debug mode
- spacing
- removed splitter indicator
@Joseph-Jacobson Joseph-Jacobson requested a review from nitin710 July 29, 2025 22:33
Copy link
Collaborator

@nitin710 nitin710 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. See review comments in the XPlat PR.

Also, see the latest PR template, specifically the Testing section. Let's conform this PR to that.

@nitin710
Copy link
Collaborator

@coderabbitai perform an review

@coderabbitai
Copy link

coderabbitai bot commented Aug 12, 2025

@nitin710 I'll perform a comprehensive review of this PR focusing on the packet splitter refactoring, new debugger commands, and error handling improvements.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link

coderabbitai bot commented Aug 12, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-SplitterRefactor

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🔭 Outside diff range comments (1)
EmotiBit.cpp (1)

2421-2421: Fix debug print to use correct variable name.

The debug print references an undefined variable t instead of the parameter type.

 size_t EmotiBit::getData(DataType type, float** data, uint32_t * timestamp) {
 #ifdef DEBUG
 	Serial.print("getData: type=");
-	Serial.println((uint8_t) t);
+	Serial.println((uint8_t) type);
 #endif // DEBUG
🧹 Nitpick comments (2)
testing/PacketFixedLengthTest/README.md (2)

2-2: Grammar fixes: “This tests verifies” → “This test verifies.”

Minor but visible in the first sentence.

Apply this diff (already included in a previous suggestion but calling it out explicitly due to prominence):

- This tests verifies
+ This test verifies

10-10: Spelling: “oscilliscope” → “oscilloscope.”

Caught by static analysis; fix for professionalism.

Apply this diff (already included in a previous suggestion but calling it out explicitly for traceability):

-4. Pressing record in the oscilliscope and waiting for the test to finish
+4. Pressing record in the oscilloscope and waiting for the test to finish
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f48eeaa and ef762a0.

📒 Files selected for processing (6)
  • EmotiBit.cpp (8 hunks)
  • EmotiBit.h (3 hunks)
  • EmotiBitWiFi.cpp (1 hunks)
  • library.properties (1 hunks)
  • testing/PacketFixedLengthTest/README.md (1 hunks)
  • testing/PacketFixedLengthTest/run_test.sh (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
EmotiBit.cpp (1)
EmotiBitWiFi.cpp (2)
  • sendData (407-416)
  • sendData (407-407)
🪛 LanguageTool
testing/PacketFixedLengthTest/README.md

[grammar] ~10-~10: Ensure spelling is correct
Context: ...tter test '@' 4. Pressing record in the oscilliscope and waiting for the test to finish 5. C...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🔇 Additional comments (10)
library.properties (1)

2-2: LGTM! Version bump is appropriate for the refactor.

The version increment from 1.14.0 to 1.14.1 correctly follows semantic versioning for a patch release containing the packet splitter refactor and bug fixes.

EmotiBit.h (2)

301-301: Good rename to better reflect the constant's broader usage.

The rename from MAX_SD_WRITE_LEN to MAX_SEND_LEN better reflects that this constant is now used for both SD card writes and network sends.


428-428: LGTM! Well-structured test data type addition.

The addition of _testDataType with a sensible default of SAWTOOTH provides good flexibility for different test data patterns.

EmotiBit.cpp (7)

1651-1651: Good fix for the debug input processing issue.

Using Serial.peek() instead of Serial.read() correctly addresses the issue from #318 where the 'F' character was being consumed prematurely, preventing FTP mode from being triggered.


1749-1753: LGTM! Cleaner main loop data flow.

Moving processData() and sendData() out of conditional logic ensures data is always processed consistently, regardless of test mode.


3409-3488: Well-implemented centralized packet splitting logic.

The refactored sendData() function successfully centralizes packet splitting from WiFi and SD card write functions. The implementation correctly:

  1. Handles test data injection when enabled
  2. Splits messages into chunks respecting MAX_SEND_LEN boundaries
  3. Preserves packet integrity by splitting at delimiter boundaries
  4. Handles both the main buffer and remainder consistently

3665-3678: Good error handling for oversized SD card writes.

The new overflow detection correctly identifies when a message exceeds MAX_SEND_LEN and logs a DATA_OVERFLOW packet with the attempted size. This provides valuable debugging information.


3876-3876: Appropriate use of new test data API.

The updated call to EmotiBitPacket::createTestDataPacket correctly passes the _testDataType parameter to support different test patterns.


3983-3986: Well-designed debug commands for test data control.

The new debug commands provide good runtime control over test data:

  • > and < for enabling/disabling test data
  • @ and # for selecting test type
    Clear user prompts make the functionality discoverable.

Also applies to: 4333-4351


3411-3422: Consider edge case: empty test data when not recording.

The logic only adds test data when _sdWrite is true (line 3875), but test data mode can be enabled without recording. This might confuse users who enable test mode but don't see any test data because recording isn't active.

Consider whether test data should be generated regardless of recording state, or if the current behavior should be documented more clearly in the debug help text.

Copy link
Collaborator

@produceconsumerobot produceconsumerobot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments, but overall looks great.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From this description, I'm not sure I can understand what this test is doing. Perhaps improving the clarity would be helpful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edited for clarity

@Joseph-Jacobson
Copy link
Contributor Author

Ready for merge

@nitin710 nitin710 merged commit 831b4f8 into dev Sep 11, 2025
2 checks passed
@nitin710 nitin710 deleted the feat-SplitterRefactor branch September 11, 2025 20:11
@coderabbitai coderabbitai bot mentioned this pull request Oct 23, 2025
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments