-
Notifications
You must be signed in to change notification settings - Fork 2
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
Changes from 16 commits
2eac0e9
55c9514
1dbc858
54bb76e
f76fb5c
709bde1
6e38368
6f215d8
be4b737
362bec9
9bb0b82
dda0ad1
d3bdd34
32f2221
7560269
2004f07
0e3750e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 (testCount <= EmotiBitPacket::maxTestLength && testType == TestType::SAWTOOTH) | ||
|
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. Code readability might be improved to start the conditional with the testType rather than the testCount
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. I'm not 100% sure, but it seems like using <= EmotiBitPacket::maxTestLength might create one extra packet. E.g. if you set maxTestLength = 1, wouldn't it actually create 2 packets?
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. Started with conditional, second comment addressed below |
||
| { | ||
| 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.
|
||
|
|
||
| else if (testCount <= EmotiBitPacket::maxTestLength && testType == TestType::FIXED_PACKET_LENGTH) // 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.
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.
|
||
| 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 testCount) | ||
|
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. Using testCount is fine, it does the job, but I wonder if having payloadLen as an input would have given a little more transparency into how the input translates into a test packet.
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. Switched to payloadLength as an input |
||
| { | ||
| 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.
|
||
|
|
||
| // Calculate number of dashes needed | ||
| int dataLength = testCount - (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 | ||
|
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. It's fine to have a "0" marker at the end and I probably wouldn't recommend changing it now because it might require changing in a few places, but I wonder if it's necessary. Could you have just used PACKET_DELIMITER_CSV as the packet-end marker that you search for in the comparison script?
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. I'll add a ToDo |
||
| 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; | ||
| } | ||
| 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.
|
||
| | 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.
|
||
Uh oh!
There was an error while loading. Please reload this page.