-
Notifications
You must be signed in to change notification settings - Fork 1
Feat splitter refactor #30
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
2eac0e9
initial changes
Joseph-Jacobson 55c9514
Added robust testing
Joseph-Jacobson 1dbc858
Added doxygen comment
Joseph-Jacobson 54bb76e
Bumped library version
Joseph-Jacobson f76fb5c
Updated README
Joseph-Jacobson 709bde1
Typo update
Joseph-Jacobson 6e38368
modifications to splitter test
Joseph-Jacobson 6f215d8
Moved and refactored the "splitter" test functionality
Joseph-Jacobson be4b737
reverting fix
Joseph-Jacobson 362bec9
Review Edits
Joseph-Jacobson 9bb0b82
spacing
Joseph-Jacobson dda0ad1
indent fix
Joseph-Jacobson d3bdd34
spacing
Joseph-Jacobson 32f2221
PR Refactors
Joseph-Jacobson 7560269
Removed comment
Joseph-Jacobson 2004f07
Renaming
Joseph-Jacobson 0e3750e
PR updates
Joseph-Jacobson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -117,7 +117,7 @@ const char* const EmotiBitPacket::TypeTagGroups::COMPOSITE_PAYLOAD[] = | |
| }; | ||
| uint8_t EmotiBitPacket::TypeTagGroups::NUM_COMPOSITE_PAYLOAD = sizeof(EmotiBitPacket::TypeTagGroups::COMPOSITE_PAYLOAD) / sizeof(EmotiBitPacket::TypeTagGroups::COMPOSITE_PAYLOAD[0]); | ||
|
|
||
| const uint32_t EmotiBitPacket::maxTestLength = 200; // testing value | ||
| const uint32_t EmotiBitPacket::maxTestLength = 512; // testing value | ||
|
|
||
| #ifdef ARDUINO | ||
| const String EmotiBitPacket::TIMESTAMP_STRING_FORMAT = "%Y-%m-%d_%H-%M-%S-%f"; | ||
|
|
@@ -481,37 +481,41 @@ EmotiBitPacket::Header EmotiBitPacket::createHeaderWithTime(const string &typeTa | |
|
|
||
| #endif | ||
|
|
||
| void EmotiBitPacket::createTestDataPacket(String &dataMessage) | ||
| void EmotiBitPacket::createTestDataPacket(String &dataMessage, TestType testType) | ||
| { | ||
| //ToDo: Edit function to be more modular in the future so we can add more test data messages | ||
| static bool firstMessage = true; | ||
| static int testCount = 0; | ||
| dataMessage = ""; | ||
|
|
||
| static bool firstMessage = true; | ||
| static int testCount = 0; | ||
| dataMessage = ""; | ||
| // First message to signify start of test | ||
| if (firstMessage) | ||
| if (firstMessage) | ||
| { | ||
| firstMessage = false; | ||
| EmotiBitPacket::Header beginHeader = EmotiBitPacket::createHeader(EmotiBitPacket::TypeTag::USER_NOTE, 0, 0, 1, 0, 0); | ||
| String data = String(maxTestLength); | ||
| String data = String("Test Length: ") + String(maxTestLength) + EmotiBitPacket::PACKET_DELIMITER_CSV; | ||
| dataMessage = EmotiBitPacket::createPacket(beginHeader, data); | ||
| } | ||
|
|
||
| else if (testCount <= EmotiBitPacket::maxTestLength) | ||
| //ToDo: Refactor testing structure to be more modular so we can add more tests easily | ||
| else if (testType == TestType::SAWTOOTH && testCount <= EmotiBitPacket::maxTestLength) | ||
| { | ||
| int dataLength = 0; | ||
| int dataLength = 0; | ||
|
|
||
| String data = EmotiBitPacket::createTestSawtoothData(dataLength); //Set data first so dataLength is set for the header | ||
| EmotiBitPacket::Header header = EmotiBitPacket::createTestHeader(dataLength); | ||
|
|
||
| dataMessage = EmotiBitPacket::createPacket(header, data); | ||
| testCount++; | ||
| } | ||
| testCount++; | ||
| } | ||
Joseph-Jacobson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| else if (testType == TestType::FIXED_PACKET_LENGTH && testCount <= EmotiBitPacket::maxTestLength) // Change splitter to fixedlength | ||
| { | ||
| dataMessage = EmotiBitPacket::createTestPacketFixedLength(testCount); | ||
| testCount++; | ||
| } | ||
|
|
||
| // End case to visually signal end of test | ||
| else if (testCount == EmotiBitPacket::maxTestLength + 1) | ||
Joseph-Jacobson marked this conversation as resolved.
Show resolved
Hide resolved
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maxTestLength + 1 also seems to suggest maxTestLength + 1 packets may be created
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The +1 accounts for the "start message" |
||
| { | ||
| EmotiBitPacket:: Header endHeader = EmotiBitPacket::createHeader(EmotiBitPacket::TypeTag::EDA, 0, 0, 1, 0, 0); | ||
| EmotiBitPacket::Header endHeader = EmotiBitPacket::createHeader(EmotiBitPacket::TypeTag::EDA, 0, 0, 1, 0, 0); | ||
Joseph-Jacobson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| String data = String(0); | ||
| dataMessage = EmotiBitPacket::createPacket(endHeader, data); | ||
| testCount++; | ||
|
|
@@ -521,35 +525,63 @@ void EmotiBitPacket::createTestDataPacket(String &dataMessage) | |
|
|
||
| String EmotiBitPacket::createTestSawtoothData(int& outLength) | ||
| { | ||
| String payload; | ||
| String payload; | ||
|
|
||
| int numValues = 10; // Number of values to generate | ||
| int minVal = 0; // Minimum value | ||
| int maxVal = 100; // Maximum value | ||
| int numValues = 10; // Number of values to generate | ||
| int minVal = 0; // Minimum value | ||
| int maxVal = 100; // Maximum value | ||
|
|
||
| for (uint8_t i = 0; i < numValues; ++i) | ||
| { | ||
| if (i > 0) payload += EmotiBitPacket::PAYLOAD_DELIMITER; | ||
| int value = minVal + ((maxVal - minVal) * i) / (numValues - 1); | ||
| payload += value; | ||
| } | ||
| if (i > 0) payload += EmotiBitPacket::PAYLOAD_DELIMITER; | ||
| int value = minVal + ((maxVal - minVal) * i) / (numValues - 1); | ||
| payload += value; | ||
| } | ||
| outLength = numValues; | ||
| return payload; | ||
| return payload; | ||
| } | ||
|
|
||
| String EmotiBitPacket::createTestPacketFixedLength(int payloadLength) | ||
| { | ||
| String packet; | ||
| String data; | ||
| int payloadLengthOffset = (String(PAYLOAD_DELIMITER) + "0" + String(PACKET_DELIMITER_CSV)).length(); | ||
| static uint32_t timestamp = 0; | ||
| static uint16_t packetNumber = 0; | ||
| EmotiBitPacket::Header header = EmotiBitPacket::createHeader(EmotiBitPacket::TypeTag::USER_NOTE, timestamp++, packetNumber++, 1); | ||
|
|
||
| String headerString = EmotiBitPacket::headerToString(header); | ||
Joseph-Jacobson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Calculate number of dashes needed | ||
| int dataLength = payloadLength - (int)headerString.length() - payloadLengthOffset; | ||
| if (dataLength < 0) dataLength = 0; // Prevent negative | ||
|
|
||
| for (int i = 0; i < dataLength; i++) | ||
| { | ||
| data += "-"; | ||
| } | ||
| data += "0"; // Add marker at the end, consider replacing with a packet delimiter | ||
| data += EmotiBitPacket::PACKET_DELIMITER_CSV; // Add delimiter | ||
|
|
||
| packet = headerString + EmotiBitPacket::PAYLOAD_DELIMITER + data; | ||
|
|
||
| return packet; | ||
| } | ||
|
|
||
| EmotiBitPacket::Header EmotiBitPacket::createTestHeader(uint16_t dataLength) | ||
| { | ||
| static uint32_t timestamp = 0; | ||
| static uint16_t packetNumber = 0; | ||
| static uint8_t protocolVersion = 0; | ||
| static uint8_t dataReliability = 0; | ||
| static uint16_t packetNumber = 0; | ||
| static uint8_t protocolVersion = 0; | ||
| static uint8_t dataReliability = 0; | ||
|
|
||
| EmotiBitPacket::Header header = EmotiBitPacket::createHeader( | ||
| EmotiBitPacket::TypeTag::EDA, | ||
| EmotiBitPacket::Header header = EmotiBitPacket::createHeader( | ||
| EmotiBitPacket::TypeTag::EDA, | ||
| timestamp++, | ||
| packetNumber++, | ||
| dataLength, | ||
| protocolVersion++, | ||
| dataReliability++ | ||
| ); | ||
| return header; | ||
| packetNumber++, | ||
| dataLength, | ||
| protocolVersion++, | ||
| dataReliability++ | ||
| ); | ||
| return header; | ||
| } | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,17 @@ | ||
| # Description | ||
| - This tests verifies that the Mock Data Testing data is identical between the EmotiBit SD card and a generated expected output. | ||
| - The data is verified with the bash script, comparing the SD card output with the outputed test.csv file from the executable | ||
| - Instructions to run this test can be found in the EmotiBit Test Protocols Document under Mock Data Testing | ||
| - Instructions to run this test can be found in the EmotiBit Test Protocols Document under Mock Data Testing | ||
|
|
||
| The following table shows commands for choosing the test type. A typical workflow will consist of: | ||
| 1. Going into debug mode | ||
| 2. Setting sendTestData to true | ||
| 3. Choosing the Sawtooth test '#' | ||
| 4. Pressing record in the oscilliscope and waiting for the test to finish | ||
| 5. Comparing the SD card result with the bash script, specifying the extension | ||
|
|
||
Joseph-Jacobson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| | Command | Details | | ||
| |--------|--------| | ||
| | < | Sets "sendTestData" to true| | ||
| | > | Sets "sendTestData" to false| | ||
| | # | Sets test data to Sawtooth (this is also the default)| | ||
Joseph-Jacobson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.