From 2eac0e9d40f90a4bec333b30fe2b6d2b2a3c91f0 Mon Sep 17 00:00:00 2001 From: Joseph-Jacobson Date: Wed, 2 Jul 2025 10:14:26 -0700 Subject: [PATCH 01/17] initial changes --- src/EmotiBitPacket.cpp | 28 +++++++++++++++++++++++++--- src/EmotiBitPacket.h | 5 +++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/EmotiBitPacket.cpp b/src/EmotiBitPacket.cpp index 13b54ff..b7a2ce5 100644 --- a/src/EmotiBitPacket.cpp +++ b/src/EmotiBitPacket.cpp @@ -487,17 +487,18 @@ void EmotiBitPacket::createTestDataPacket(String &dataMessage) static bool firstMessage = true; static int testCount = 0; dataMessage = ""; - + bool splitterTest = true; //set true to test splitter data, false to test sawtooth data + //ToDo: add test type to header so we can differentiate between different tests // First message to signify start of test 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) + else if (testCount <= EmotiBitPacket::maxTestLength && splitterTest == false) { int dataLength = 0; @@ -508,6 +509,12 @@ void EmotiBitPacket::createTestDataPacket(String &dataMessage) testCount++; } + else if (testCount <= EmotiBitPacket::maxTestLength && splitterTest == true) + { + dataMessage = EmotiBitPacket::createSplitterData(testCount); + testCount++; + } + // End case to visually signal end of test else if (testCount == EmotiBitPacket::maxTestLength + 1) { @@ -536,6 +543,21 @@ String EmotiBitPacket::createTestSawtoothData(int& outLength) return payload; } +String EmotiBitPacket::createSplitterData(int testCount) +{ + String packet; + if (testCount % 2 == 0) + { + packet = "-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------1"; + return packet; + } + else //(testCount % 1 == 0) + { + packet = "---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------2"; + return packet; + } +} + EmotiBitPacket::Header EmotiBitPacket::createTestHeader(uint16_t dataLength) { static uint32_t timestamp = 0; diff --git a/src/EmotiBitPacket.h b/src/EmotiBitPacket.h index e92c419..8d5d9e7 100644 --- a/src/EmotiBitPacket.h +++ b/src/EmotiBitPacket.h @@ -365,6 +365,11 @@ class EmotiBitPacket { //! @return String representation of the test sawtooth data message static String createTestSawtoothData(int& outLength); + //! @brief Creates a splitter data message + //! @param testCount Test count number to determine what data to send + //! @return String representation of the splitter data message + static String createSplitterData(int testCount); + //! @brief Tests the conversion of headers to a String //! @param dataLength Length of the data to be included in the header From 55c951474eb08071b0cc4c90ce55b076feaff18d Mon Sep 17 00:00:00 2001 From: Joseph-Jacobson Date: Mon, 14 Jul 2025 14:49:20 -0700 Subject: [PATCH 02/17] Added robust testing --- src/EmotiBitPacket.cpp | 36 ++++++++++++-------------- src/EmotiBitPacket.h | 9 +++++-- tests/MockDataTest/scripts/run_test.sh | 16 ++++++++++++ tests/MockDataTest/src/main.cpp | 19 ++++++++++++-- 4 files changed, 57 insertions(+), 23 deletions(-) diff --git a/src/EmotiBitPacket.cpp b/src/EmotiBitPacket.cpp index b7a2ce5..6cb79ec 100644 --- a/src/EmotiBitPacket.cpp +++ b/src/EmotiBitPacket.cpp @@ -93,7 +93,8 @@ const char* EmotiBitPacket::PayloadLabel::LSL_MARKER_SRC_TIMESTAMP = "LM\0"; const char* EmotiBitPacket::PayloadLabel::LSL_LOCAL_CLOCK_TIMESTAMP = "LC\0"; const char* EmotiBitPacket::PayloadLabel::LSL_MARKER_DATA = "LD\0"; - +const char* EmotiBitPacket::TestType::SAWTOOTH = "ST\0"; +const char* EmotiBitPacket::TestType::SPLITTER = "SP\0"; const char EmotiBitPacket::PACKET_DELIMITER_CSV = '\n'; //const uint8_t nAperiodicTypeTags = 2; @@ -117,7 +118,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,24 +482,22 @@ EmotiBitPacket::Header EmotiBitPacket::createHeaderWithTime(const string &typeTa #endif -void EmotiBitPacket::createTestDataPacket(String &dataMessage) +void EmotiBitPacket::createTestDataPacket(String &dataMessage, const char* 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 = ""; - bool splitterTest = true; //set true to test splitter data, false to test sawtooth data //ToDo: add test type to header so we can differentiate between different tests // First message to signify start of test if (firstMessage) { firstMessage = false; EmotiBitPacket::Header beginHeader = EmotiBitPacket::createHeader(EmotiBitPacket::TypeTag::USER_NOTE, 0, 0, 1, 0, 0); - String data = String("Test Length:") + String(maxTestLength) + EmotiBitPacket::PACKET_DELIMITER_CSV; + String data = String("Test Length: ") + String(maxTestLength) + String(" Test Type: ") + String(testType) + EmotiBitPacket::PACKET_DELIMITER_CSV; dataMessage = EmotiBitPacket::createPacket(beginHeader, data); } - - else if (testCount <= EmotiBitPacket::maxTestLength && splitterTest == false) + //ToDo: Refactor testing structure to be more modular so we can add more tests easily + else if (testCount <= EmotiBitPacket::maxTestLength && testType == EmotiBitPacket::TestType::SAWTOOTH) { int dataLength = 0; @@ -509,7 +508,7 @@ void EmotiBitPacket::createTestDataPacket(String &dataMessage) testCount++; } - else if (testCount <= EmotiBitPacket::maxTestLength && splitterTest == true) + else if (testCount <= EmotiBitPacket::maxTestLength && testType == EmotiBitPacket::TestType::SPLITTER) { dataMessage = EmotiBitPacket::createSplitterData(testCount); testCount++; @@ -545,17 +544,16 @@ String EmotiBitPacket::createTestSawtoothData(int& outLength) String EmotiBitPacket::createSplitterData(int testCount) { + String packet; - if (testCount % 2 == 0) - { - packet = "-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------1"; - return packet; - } - else //(testCount % 1 == 0) - { - packet = "---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------2"; - return packet; - } + const int packetLen = testCount; // -2 for marker and delimiter + for (int i = 0; i < packetLen; i++) + { + packet += "-"; + } + packet += "0"; // Add marker at the end + packet += EmotiBitPacket::PACKET_DELIMITER_CSV; // Add delimiter + return packet; } EmotiBitPacket::Header EmotiBitPacket::createTestHeader(uint16_t dataLength) diff --git a/src/EmotiBitPacket.h b/src/EmotiBitPacket.h index 8d5d9e7..75e4e3b 100644 --- a/src/EmotiBitPacket.h +++ b/src/EmotiBitPacket.h @@ -246,7 +246,12 @@ class EmotiBitPacket { static const char* LSL_LOCAL_CLOCK_TIMESTAMP; static const char* LSL_MARKER_DATA; }; - + class TestType + { + public: + static const char* SAWTOOTH; + static const char* SPLITTER; + }; static const char PACKET_DELIMITER_CSV; static const uint16_t MAX_TO_EMOTIBIT_PACKET_LEN = 255; #ifdef ARDUINO @@ -358,7 +363,7 @@ class EmotiBitPacket { //! @brief Appends a test data message to the passed dataMessage reference //! @param dataMessage reference to the String to append the test data message to //! @note Tests will start when isRecording is true, and with the current implementation, the test will end at the end of the test length - static void createTestDataPacket(String &dataMessage); + static void createTestDataPacket(String &dataMessage, const char* testType); //! @brief Creates a test sawtooth data message //! @param outLength reference to an int to store the length of the created sawtooth data message diff --git a/tests/MockDataTest/scripts/run_test.sh b/tests/MockDataTest/scripts/run_test.sh index 652d469..5e4b859 100644 --- a/tests/MockDataTest/scripts/run_test.sh +++ b/tests/MockDataTest/scripts/run_test.sh @@ -18,6 +18,7 @@ fi TEST_FILE="$PROJECT_ROOT/build/Release/test.csv" EMOTIBIT_CSV="" +TEST_TYPE="" if [[ ! -x "$PROJECT_ROOT/build/Release/MockDataTest" ]]; then echo "Executable not found or not executable: $PROJECT_ROOT/build/Release/MockDataTest" @@ -31,6 +32,10 @@ while [[ $# -gt 0 ]]; do EMOTIBIT_CSV="$2" shift 2 ;; + -t|--testtype) + TEST_TYPE="$2" + shift 2 + ;; *) echo "Usage: $0 -e|--extension " exit 1 @@ -43,6 +48,17 @@ if [[ -z "$EMOTIBIT_CSV" ]]; then exit 1 fi +if [[ -z "$TEST_TYPE" ]]; then + echo "Error: You must specify -t or --test " + exit 1 +fi + +echo "Rebuilding and running test with type: $TEST_TYPE" + +cd "$PROJECT_ROOT/build/Release" +"$EXECUTABLE" --testtype "$TEST_TYPE" +cd "$PROJECT_ROOT/build" + if [[ ! -f "$TEST_FILE" ]]; then echo "Test file not found: $TEST_FILE" exit 1 diff --git a/tests/MockDataTest/src/main.cpp b/tests/MockDataTest/src/main.cpp index 474aa07..c8ba75a 100644 --- a/tests/MockDataTest/src/main.cpp +++ b/tests/MockDataTest/src/main.cpp @@ -36,11 +36,26 @@ #include #include "EmotiBitPacket.h" -int main() { +int main(int argc, char* argv[]) { String dataMessage; uint16_t packetNumber = 0; uint8_t clipping = 0; uint32_t x = 0; + const char* testDataType = EmotiBitPacket::TestType::SAWTOOTH; // Default to SAWTOOTH + + // Check test type + for (int i = 1; i < argc - 1; ++i) { + if (std::string(argv[i]) == "--testtype" || std::string(argv[i]) == "-t") { + std::string type = argv[i + 1]; + if (type == "Splitter" || type == "splitter" || type == "SPLITTER" || type == "SP") { + testDataType = EmotiBitPacket::TestType::SPLITTER; + } else if (type == "Sawtooth" || type == "sawtooth" || type == "SAWTOOTH" || type == "ST") { + testDataType = EmotiBitPacket::TestType::SAWTOOTH; + } else { + std::cerr << "Unknown test type: " << type << ". Using default (SAWTOOTH)." << std::endl; + } + } + } std::ofstream testfile("test.csv", std::ios::binary); if (!testfile.is_open()) { @@ -49,7 +64,7 @@ int main() { } while (x <= EmotiBitPacket::maxTestLength + 2) { // Loop until maxTestLength + 2 to account for the first and last messages - EmotiBitPacket::createTestDataPacket(dataMessage); + EmotiBitPacket::createTestDataPacket(dataMessage, testDataType); testfile << dataMessage.str; x++; } From 1dbc858589655bf069054f6fecde71b25bac4194 Mon Sep 17 00:00:00 2001 From: Joseph-Jacobson Date: Mon, 14 Jul 2025 14:53:48 -0700 Subject: [PATCH 03/17] Added doxygen comment --- src/EmotiBitPacket.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/EmotiBitPacket.h b/src/EmotiBitPacket.h index 75e4e3b..29fa3eb 100644 --- a/src/EmotiBitPacket.h +++ b/src/EmotiBitPacket.h @@ -362,6 +362,7 @@ class EmotiBitPacket { //! @brief Appends a test data message to the passed dataMessage reference //! @param dataMessage reference to the String to append the test data message to + //! @param testType Type of the test to create data for //! @note Tests will start when isRecording is true, and with the current implementation, the test will end at the end of the test length static void createTestDataPacket(String &dataMessage, const char* testType); From 54bb76ec2890c70e9d1a7691350efcd42be96dde Mon Sep 17 00:00:00 2001 From: Joseph-Jacobson Date: Mon, 14 Jul 2025 15:39:46 -0700 Subject: [PATCH 04/17] Bumped library version --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 11c336e..7fb9717 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=EmotiBit XPlat Utils -version=1.7.1 +version=1.7.2 author=Connected Future Labs maintainer=Connected Future Labs sentence=A Utilities Library required for the successfull operation of EmotiBit FeatherWing and EmotiBit Oscilloscope Library From f76fb5ca1d91e0d7ec3080ce1772b3a67a4d9264 Mon Sep 17 00:00:00 2001 From: Joseph-Jacobson Date: Mon, 14 Jul 2025 16:19:17 -0700 Subject: [PATCH 05/17] Updated README --- tests/MockDataTest/README.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/MockDataTest/README.md b/tests/MockDataTest/README.md index 3964a7a..cf56736 100644 --- a/tests/MockDataTest/README.md +++ b/tests/MockDataTest/README.md @@ -1,4 +1,20 @@ # 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 \ No newline at end of file +- 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 test type +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 and the test type + +| Command | Details | +|--------|--------| +| Z | Turns on "splitter" indicator, which is a "S" that is be printed after each split| +| z | Turns off "splitter" indicator| +| < | Sets "sendTestData" to true| +| > | Sets "sendTestData" to false| +| @ | Sets test data to Splitter| +| # | Sets test data to Sawtooth (this is also the default)| \ No newline at end of file From 709bde1e5c8c19334432d2c0e01cd0f818262c4a Mon Sep 17 00:00:00 2001 From: Joseph-Jacobson Date: Mon, 14 Jul 2025 17:13:53 -0700 Subject: [PATCH 06/17] Typo update --- tests/MockDataTest/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/MockDataTest/README.md b/tests/MockDataTest/README.md index cf56736..69c351d 100644 --- a/tests/MockDataTest/README.md +++ b/tests/MockDataTest/README.md @@ -12,7 +12,7 @@ The following table shows commands for choosing the test type. A typical workflo | Command | Details | |--------|--------| -| Z | Turns on "splitter" indicator, which is a "S" that is be printed after each split| +| Z | Turns on "splitter" indicator, which is a "S" that is printed after each split| | z | Turns off "splitter" indicator| | < | Sets "sendTestData" to true| | > | Sets "sendTestData" to false| From 6e383680db38c2935bc4e32f02be7463a0dddc3a Mon Sep 17 00:00:00 2001 From: Joseph-Jacobson Date: Tue, 15 Jul 2025 13:51:08 -0700 Subject: [PATCH 07/17] modifications to splitter test --- src/EmotiBitPacket.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/EmotiBitPacket.cpp b/src/EmotiBitPacket.cpp index 6cb79ec..099221a 100644 --- a/src/EmotiBitPacket.cpp +++ b/src/EmotiBitPacket.cpp @@ -546,13 +546,19 @@ String EmotiBitPacket::createSplitterData(int testCount) { String packet; - const int packetLen = testCount; // -2 for marker and delimiter - for (int i = 0; i < packetLen; i++) + const int packetLen = testCount; + for (int i = 0; i < packetLen - 2; i++) // -2 for marker and delimiter { packet += "-"; } packet += "0"; // Add marker at the end packet += EmotiBitPacket::PACKET_DELIMITER_CSV; // Add delimiter + +// added nub + packet += "---------------"; + packet += "1"; + packet += EmotiBitPacket::PACKET_DELIMITER_CSV; // Add delimiter + return packet; } From 6f215d872c061ccee742cdc881bbe61621f75d4c Mon Sep 17 00:00:00 2001 From: Joseph-Jacobson Date: Tue, 15 Jul 2025 16:19:42 -0700 Subject: [PATCH 08/17] Moved and refactored the "splitter" test functionality --- src/EmotiBitPacket.cpp | 45 ++++++++++++++------------ src/EmotiBitPacket.h | 11 ++----- tests/MockDataTest/README.md | 5 +-- tests/MockDataTest/scripts/run_test.sh | 14 +------- tests/MockDataTest/src/main.cpp | 19 ++--------- 5 files changed, 32 insertions(+), 62 deletions(-) diff --git a/src/EmotiBitPacket.cpp b/src/EmotiBitPacket.cpp index 099221a..9dedd63 100644 --- a/src/EmotiBitPacket.cpp +++ b/src/EmotiBitPacket.cpp @@ -93,8 +93,6 @@ const char* EmotiBitPacket::PayloadLabel::LSL_MARKER_SRC_TIMESTAMP = "LM\0"; const char* EmotiBitPacket::PayloadLabel::LSL_LOCAL_CLOCK_TIMESTAMP = "LC\0"; const char* EmotiBitPacket::PayloadLabel::LSL_MARKER_DATA = "LD\0"; -const char* EmotiBitPacket::TestType::SAWTOOTH = "ST\0"; -const char* EmotiBitPacket::TestType::SPLITTER = "SP\0"; const char EmotiBitPacket::PACKET_DELIMITER_CSV = '\n'; //const uint8_t nAperiodicTypeTags = 2; @@ -493,11 +491,11 @@ void EmotiBitPacket::createTestDataPacket(String &dataMessage, const char* testT { firstMessage = false; EmotiBitPacket::Header beginHeader = EmotiBitPacket::createHeader(EmotiBitPacket::TypeTag::USER_NOTE, 0, 0, 1, 0, 0); - String data = String("Test Length: ") + String(maxTestLength) + String(" Test Type: ") + String(testType) + EmotiBitPacket::PACKET_DELIMITER_CSV; + String data = String("Test Length: ") + String(maxTestLength) + String(" Test Type: ") + testType + EmotiBitPacket::PACKET_DELIMITER_CSV; dataMessage = EmotiBitPacket::createPacket(beginHeader, data); } //ToDo: Refactor testing structure to be more modular so we can add more tests easily - else if (testCount <= EmotiBitPacket::maxTestLength && testType == EmotiBitPacket::TestType::SAWTOOTH) + else if (testCount <= EmotiBitPacket::maxTestLength && testType == "Sawtooth") { int dataLength = 0; @@ -508,19 +506,20 @@ void EmotiBitPacket::createTestDataPacket(String &dataMessage, const char* testT testCount++; } - else if (testCount <= EmotiBitPacket::maxTestLength && testType == EmotiBitPacket::TestType::SPLITTER) + else if (testCount <= EmotiBitPacket::maxTestLength && testType == "Splitter") { - dataMessage = EmotiBitPacket::createSplitterData(testCount); + dataMessage = EmotiBitPacket::createPacketFixedLengthTest(testCount); testCount++; } // End case to visually signal end of test else if (testCount == EmotiBitPacket::maxTestLength + 1) { - 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); String data = String(0); dataMessage = EmotiBitPacket::createPacket(endHeader, data); - testCount++; + //testCount++; + testCount = 0; // Reset testCount for next test } } @@ -542,22 +541,28 @@ String EmotiBitPacket::createTestSawtoothData(int& outLength) return payload; } -String EmotiBitPacket::createSplitterData(int testCount) +String EmotiBitPacket::createPacketFixedLengthTest(int testCount) { - - String packet; - const int packetLen = testCount; - for (int i = 0; i < packetLen - 2; i++) // -2 for marker and delimiter + String packet; + String data; + 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); + + // Calculate number of dashes needed + int dataLength = testCount - headerString.length() - 3; // 3 accounts for ',' + '0' + delimiter + if (dataLength < 0) dataLength = 0; // Prevent negative + + for (int i = 0; i < dataLength; i++) { - packet += "-"; + data += "-"; } - packet += "0"; // Add marker at the end - packet += EmotiBitPacket::PACKET_DELIMITER_CSV; // Add delimiter + data += "0"; // Add marker at the end + data += EmotiBitPacket::PACKET_DELIMITER_CSV; // Add delimiter -// added nub - packet += "---------------"; - packet += "1"; - packet += EmotiBitPacket::PACKET_DELIMITER_CSV; // Add delimiter + packet = headerString + EmotiBitPacket::PAYLOAD_DELIMITER + data; return packet; } diff --git a/src/EmotiBitPacket.h b/src/EmotiBitPacket.h index 29fa3eb..097ad07 100644 --- a/src/EmotiBitPacket.h +++ b/src/EmotiBitPacket.h @@ -246,12 +246,7 @@ class EmotiBitPacket { static const char* LSL_LOCAL_CLOCK_TIMESTAMP; static const char* LSL_MARKER_DATA; }; - class TestType - { - public: - static const char* SAWTOOTH; - static const char* SPLITTER; - }; + static const char PACKET_DELIMITER_CSV; static const uint16_t MAX_TO_EMOTIBIT_PACKET_LEN = 255; #ifdef ARDUINO @@ -364,7 +359,7 @@ class EmotiBitPacket { //! @param dataMessage reference to the String to append the test data message to //! @param testType Type of the test to create data for //! @note Tests will start when isRecording is true, and with the current implementation, the test will end at the end of the test length - static void createTestDataPacket(String &dataMessage, const char* testType); + static void createTestDataPacket(String &dataMessage, const char* testType = "Sawtooth"); //default to Sawtooth //! @brief Creates a test sawtooth data message //! @param outLength reference to an int to store the length of the created sawtooth data message @@ -374,7 +369,7 @@ class EmotiBitPacket { //! @brief Creates a splitter data message //! @param testCount Test count number to determine what data to send //! @return String representation of the splitter data message - static String createSplitterData(int testCount); + static String createPacketFixedLengthTest(int testCount); //! @brief Tests the conversion of headers to a String diff --git a/tests/MockDataTest/README.md b/tests/MockDataTest/README.md index 69c351d..0fceab6 100644 --- a/tests/MockDataTest/README.md +++ b/tests/MockDataTest/README.md @@ -6,15 +6,12 @@ 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 test type +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 and the test type | Command | Details | |--------|--------| -| Z | Turns on "splitter" indicator, which is a "S" that is printed after each split| -| z | Turns off "splitter" indicator| | < | Sets "sendTestData" to true| | > | Sets "sendTestData" to false| -| @ | Sets test data to Splitter| | # | Sets test data to Sawtooth (this is also the default)| \ No newline at end of file diff --git a/tests/MockDataTest/scripts/run_test.sh b/tests/MockDataTest/scripts/run_test.sh index 5e4b859..ab6f218 100644 --- a/tests/MockDataTest/scripts/run_test.sh +++ b/tests/MockDataTest/scripts/run_test.sh @@ -18,7 +18,6 @@ fi TEST_FILE="$PROJECT_ROOT/build/Release/test.csv" EMOTIBIT_CSV="" -TEST_TYPE="" if [[ ! -x "$PROJECT_ROOT/build/Release/MockDataTest" ]]; then echo "Executable not found or not executable: $PROJECT_ROOT/build/Release/MockDataTest" @@ -32,10 +31,6 @@ while [[ $# -gt 0 ]]; do EMOTIBIT_CSV="$2" shift 2 ;; - -t|--testtype) - TEST_TYPE="$2" - shift 2 - ;; *) echo "Usage: $0 -e|--extension " exit 1 @@ -48,15 +43,8 @@ if [[ -z "$EMOTIBIT_CSV" ]]; then exit 1 fi -if [[ -z "$TEST_TYPE" ]]; then - echo "Error: You must specify -t or --test " - exit 1 -fi - -echo "Rebuilding and running test with type: $TEST_TYPE" - cd "$PROJECT_ROOT/build/Release" -"$EXECUTABLE" --testtype "$TEST_TYPE" +"$EXECUTABLE" cd "$PROJECT_ROOT/build" if [[ ! -f "$TEST_FILE" ]]; then diff --git a/tests/MockDataTest/src/main.cpp b/tests/MockDataTest/src/main.cpp index c8ba75a..474aa07 100644 --- a/tests/MockDataTest/src/main.cpp +++ b/tests/MockDataTest/src/main.cpp @@ -36,26 +36,11 @@ #include #include "EmotiBitPacket.h" -int main(int argc, char* argv[]) { +int main() { String dataMessage; uint16_t packetNumber = 0; uint8_t clipping = 0; uint32_t x = 0; - const char* testDataType = EmotiBitPacket::TestType::SAWTOOTH; // Default to SAWTOOTH - - // Check test type - for (int i = 1; i < argc - 1; ++i) { - if (std::string(argv[i]) == "--testtype" || std::string(argv[i]) == "-t") { - std::string type = argv[i + 1]; - if (type == "Splitter" || type == "splitter" || type == "SPLITTER" || type == "SP") { - testDataType = EmotiBitPacket::TestType::SPLITTER; - } else if (type == "Sawtooth" || type == "sawtooth" || type == "SAWTOOTH" || type == "ST") { - testDataType = EmotiBitPacket::TestType::SAWTOOTH; - } else { - std::cerr << "Unknown test type: " << type << ". Using default (SAWTOOTH)." << std::endl; - } - } - } std::ofstream testfile("test.csv", std::ios::binary); if (!testfile.is_open()) { @@ -64,7 +49,7 @@ int main(int argc, char* argv[]) { } while (x <= EmotiBitPacket::maxTestLength + 2) { // Loop until maxTestLength + 2 to account for the first and last messages - EmotiBitPacket::createTestDataPacket(dataMessage, testDataType); + EmotiBitPacket::createTestDataPacket(dataMessage); testfile << dataMessage.str; x++; } From be4b7375f8aac45e22c5e08f9cb4760b031bbfb2 Mon Sep 17 00:00:00 2001 From: Joseph-Jacobson Date: Tue, 15 Jul 2025 17:12:48 -0700 Subject: [PATCH 09/17] reverting fix --- src/EmotiBitPacket.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/EmotiBitPacket.cpp b/src/EmotiBitPacket.cpp index 9dedd63..e30c6e9 100644 --- a/src/EmotiBitPacket.cpp +++ b/src/EmotiBitPacket.cpp @@ -518,8 +518,7 @@ void EmotiBitPacket::createTestDataPacket(String &dataMessage, const char* testT EmotiBitPacket::Header endHeader = EmotiBitPacket::createHeader(EmotiBitPacket::TypeTag::EDA, 0, 0, 1, 0, 0); String data = String(0); dataMessage = EmotiBitPacket::createPacket(endHeader, data); - //testCount++; - testCount = 0; // Reset testCount for next test + testCount++; } } From 362bec9df8088918cdc14b3ef7102121907a330b Mon Sep 17 00:00:00 2001 From: Joseph-Jacobson Date: Wed, 16 Jul 2025 08:53:38 -0700 Subject: [PATCH 10/17] Review Edits --- src/EmotiBitPacket.cpp | 7 +++---- src/EmotiBitPacket.h | 3 +-- tests/MockDataTest/README.md | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/EmotiBitPacket.cpp b/src/EmotiBitPacket.cpp index e30c6e9..8671387 100644 --- a/src/EmotiBitPacket.cpp +++ b/src/EmotiBitPacket.cpp @@ -485,7 +485,6 @@ void EmotiBitPacket::createTestDataPacket(String &dataMessage, const char* testT static bool firstMessage = true; static int testCount = 0; dataMessage = ""; - //ToDo: add test type to header so we can differentiate between different tests // First message to signify start of test if (firstMessage) { @@ -497,14 +496,14 @@ void EmotiBitPacket::createTestDataPacket(String &dataMessage, const char* testT //ToDo: Refactor testing structure to be more modular so we can add more tests easily else if (testCount <= EmotiBitPacket::maxTestLength && testType == "Sawtooth") { - 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++; + } else if (testCount <= EmotiBitPacket::maxTestLength && testType == "Splitter") { diff --git a/src/EmotiBitPacket.h b/src/EmotiBitPacket.h index 097ad07..1b36169 100644 --- a/src/EmotiBitPacket.h +++ b/src/EmotiBitPacket.h @@ -246,7 +246,6 @@ class EmotiBitPacket { static const char* LSL_LOCAL_CLOCK_TIMESTAMP; static const char* LSL_MARKER_DATA; }; - static const char PACKET_DELIMITER_CSV; static const uint16_t MAX_TO_EMOTIBIT_PACKET_LEN = 255; #ifdef ARDUINO @@ -366,7 +365,7 @@ class EmotiBitPacket { //! @return String representation of the test sawtooth data message static String createTestSawtoothData(int& outLength); - //! @brief Creates a splitter data message + //! @brief Creates test data that iterates in increasing length to test splitting functionality //! @param testCount Test count number to determine what data to send //! @return String representation of the splitter data message static String createPacketFixedLengthTest(int testCount); diff --git a/tests/MockDataTest/README.md b/tests/MockDataTest/README.md index 0fceab6..266f4be 100644 --- a/tests/MockDataTest/README.md +++ b/tests/MockDataTest/README.md @@ -8,7 +8,7 @@ The following table shows commands for choosing the test type. A typical workflo 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 and the test type +5. Comparing the SD card result with the bash script, specifying the extension | Command | Details | |--------|--------| From 9bb0b82a3191b56390fef7ccb2f8f08378cf7bee Mon Sep 17 00:00:00 2001 From: Joseph-Jacobson Date: Wed, 16 Jul 2025 09:00:14 -0700 Subject: [PATCH 11/17] spacing --- src/EmotiBitPacket.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/EmotiBitPacket.cpp b/src/EmotiBitPacket.cpp index 8671387..2465efa 100644 --- a/src/EmotiBitPacket.cpp +++ b/src/EmotiBitPacket.cpp @@ -94,6 +94,7 @@ const char* EmotiBitPacket::PayloadLabel::LSL_LOCAL_CLOCK_TIMESTAMP = "LC\0"; const char* EmotiBitPacket::PayloadLabel::LSL_MARKER_DATA = "LD\0"; + const char EmotiBitPacket::PACKET_DELIMITER_CSV = '\n'; //const uint8_t nAperiodicTypeTags = 2; //const uint8_t nUserMessagesTypeTags = 1; From dda0ad11902bd6634af4244fe7d5096ae68781eb Mon Sep 17 00:00:00 2001 From: Joseph-Jacobson Date: Wed, 23 Jul 2025 16:15:04 -0700 Subject: [PATCH 12/17] indent fix --- src/EmotiBitPacket.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EmotiBitPacket.cpp b/src/EmotiBitPacket.cpp index 2465efa..eb95e1d 100644 --- a/src/EmotiBitPacket.cpp +++ b/src/EmotiBitPacket.cpp @@ -506,7 +506,7 @@ void EmotiBitPacket::createTestDataPacket(String &dataMessage, const char* testT testCount++; } - else if (testCount <= EmotiBitPacket::maxTestLength && testType == "Splitter") + else if (testCount <= EmotiBitPacket::maxTestLength && testType == "Splitter") { dataMessage = EmotiBitPacket::createPacketFixedLengthTest(testCount); testCount++; From d3bdd349c3e337c257ebf940b1d0c866de7252ef Mon Sep 17 00:00:00 2001 From: Joseph-Jacobson Date: Wed, 23 Jul 2025 16:21:11 -0700 Subject: [PATCH 13/17] spacing --- src/EmotiBitPacket.cpp | 85 +++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/src/EmotiBitPacket.cpp b/src/EmotiBitPacket.cpp index eb95e1d..d371167 100644 --- a/src/EmotiBitPacket.cpp +++ b/src/EmotiBitPacket.cpp @@ -483,11 +483,11 @@ EmotiBitPacket::Header EmotiBitPacket::createHeaderWithTime(const string &typeTa void EmotiBitPacket::createTestDataPacket(String &dataMessage, const char* testType) { - 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); @@ -495,7 +495,7 @@ void EmotiBitPacket::createTestDataPacket(String &dataMessage, const char* testT dataMessage = EmotiBitPacket::createPacket(beginHeader, data); } //ToDo: Refactor testing structure to be more modular so we can add more tests easily - else if (testCount <= EmotiBitPacket::maxTestLength && testType == "Sawtooth") + else if (testCount <= EmotiBitPacket::maxTestLength && testType == "Sawtooth") { int dataLength = 0; @@ -525,61 +525,62 @@ void EmotiBitPacket::createTestDataPacket(String &dataMessage, const char* testT 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::createPacketFixedLengthTest(int testCount) { - String packet; - String data; - static uint32_t timestamp = 0; - static uint16_t packetNumber = 0; - EmotiBitPacket::Header header = EmotiBitPacket::createHeader(EmotiBitPacket::TypeTag::USER_NOTE, timestamp++, packetNumber++, 1); + String packet; + String data; + 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); + String headerString = EmotiBitPacket::headerToString(header); - // Calculate number of dashes needed - int dataLength = testCount - headerString.length() - 3; // 3 accounts for ',' + '0' + delimiter - if (dataLength < 0) dataLength = 0; // Prevent negative + // Calculate number of dashes needed + int dataLength = testCount - headerString.length() - 3; // 3 accounts for ',' + '0' + delimiter + if (dataLength < 0) dataLength = 0; // Prevent negative - for (int i = 0; i < dataLength; i++) - { - data += "-"; - } - data += "0"; // Add marker at the end - data += EmotiBitPacket::PACKET_DELIMITER_CSV; // Add delimiter + for (int i = 0; i < dataLength; i++) + { + data += "-"; + } + data += "0"; // Add marker at the end + data += EmotiBitPacket::PACKET_DELIMITER_CSV; // Add delimiter - packet = headerString + EmotiBitPacket::PAYLOAD_DELIMITER + data; + packet = headerString + EmotiBitPacket::PAYLOAD_DELIMITER + data; - return packet; + 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; } \ No newline at end of file From 32f2221859fefccde8d357e78accd6d45eb4be18 Mon Sep 17 00:00:00 2001 From: Joseph-Jacobson Date: Mon, 28 Jul 2025 08:47:36 -0700 Subject: [PATCH 14/17] PR Refactors - replaced const char* with enum - extracted 3 - naming - spacing --- src/ArduinoString.h | 4 ++-- src/EmotiBitPacket.cpp | 15 ++++++++------- src/EmotiBitPacket.h | 9 +++++++-- tests/MockDataTest/src/main.cpp | 2 +- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/ArduinoString.h b/src/ArduinoString.h index 1ea046d..fe81326 100644 --- a/src/ArduinoString.h +++ b/src/ArduinoString.h @@ -70,8 +70,8 @@ namespace EmotiBit String& operator+=(int val) { - str += std::to_string(val); - return *this; + str += std::to_string(val); + return *this; } size_t indexOf(char val, size_t from) const diff --git a/src/EmotiBitPacket.cpp b/src/EmotiBitPacket.cpp index d371167..e978611 100644 --- a/src/EmotiBitPacket.cpp +++ b/src/EmotiBitPacket.cpp @@ -481,7 +481,7 @@ EmotiBitPacket::Header EmotiBitPacket::createHeaderWithTime(const string &typeTa #endif -void EmotiBitPacket::createTestDataPacket(String &dataMessage, const char* testType) +void EmotiBitPacket::createTestDataPacket(String &dataMessage, TestType testType) { static bool firstMessage = true; static int testCount = 0; @@ -491,11 +491,11 @@ void EmotiBitPacket::createTestDataPacket(String &dataMessage, const char* testT { firstMessage = false; EmotiBitPacket::Header beginHeader = EmotiBitPacket::createHeader(EmotiBitPacket::TypeTag::USER_NOTE, 0, 0, 1, 0, 0); - String data = String("Test Length: ") + String(maxTestLength) + String(" Test Type: ") + testType + EmotiBitPacket::PACKET_DELIMITER_CSV; + String data = String("Test Length: ") + String(maxTestLength) + EmotiBitPacket::PACKET_DELIMITER_CSV; dataMessage = EmotiBitPacket::createPacket(beginHeader, data); } //ToDo: Refactor testing structure to be more modular so we can add more tests easily - else if (testCount <= EmotiBitPacket::maxTestLength && testType == "Sawtooth") + else if (testCount <= EmotiBitPacket::maxTestLength && testType == TestType::SAWTOOTHTEST) { int dataLength = 0; @@ -506,9 +506,9 @@ void EmotiBitPacket::createTestDataPacket(String &dataMessage, const char* testT testCount++; } - else if (testCount <= EmotiBitPacket::maxTestLength && testType == "Splitter") + else if (testCount <= EmotiBitPacket::maxTestLength && testType == TestType::FIXEDPACKETLENGTHTEST) // Change splitter to fixedlength { - dataMessage = EmotiBitPacket::createPacketFixedLengthTest(testCount); + dataMessage = EmotiBitPacket::createTestPacketFixedLength(testCount); testCount++; } @@ -541,10 +541,11 @@ String EmotiBitPacket::createTestSawtoothData(int& outLength) return payload; } -String EmotiBitPacket::createPacketFixedLengthTest(int testCount) +String EmotiBitPacket::createTestPacketFixedLength(int testCount) { 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); @@ -552,7 +553,7 @@ String EmotiBitPacket::createPacketFixedLengthTest(int testCount) String headerString = EmotiBitPacket::headerToString(header); // Calculate number of dashes needed - int dataLength = testCount - headerString.length() - 3; // 3 accounts for ',' + '0' + delimiter + int dataLength = testCount - (int)headerString.length() - payloadLengthOffset; //check this on pr if (dataLength < 0) dataLength = 0; // Prevent negative for (int i = 0; i < dataLength; i++) diff --git a/src/EmotiBitPacket.h b/src/EmotiBitPacket.h index 1b36169..6602d04 100644 --- a/src/EmotiBitPacket.h +++ b/src/EmotiBitPacket.h @@ -254,6 +254,11 @@ class EmotiBitPacket { static const string TIMESTAMP_STRING_FORMAT; #endif +enum TestType { + FIXEDPACKETLENGTHTEST, + SAWTOOTHTEST +}; + EmotiBitPacket(); @@ -358,7 +363,7 @@ class EmotiBitPacket { //! @param dataMessage reference to the String to append the test data message to //! @param testType Type of the test to create data for //! @note Tests will start when isRecording is true, and with the current implementation, the test will end at the end of the test length - static void createTestDataPacket(String &dataMessage, const char* testType = "Sawtooth"); //default to Sawtooth + static void createTestDataPacket(String &dataMessage, TestType testType = TestType::SAWTOOTHTEST); //! @brief Creates a test sawtooth data message //! @param outLength reference to an int to store the length of the created sawtooth data message @@ -368,7 +373,7 @@ class EmotiBitPacket { //! @brief Creates test data that iterates in increasing length to test splitting functionality //! @param testCount Test count number to determine what data to send //! @return String representation of the splitter data message - static String createPacketFixedLengthTest(int testCount); + static String createTestPacketFixedLength(int testCount); //! @brief Tests the conversion of headers to a String diff --git a/tests/MockDataTest/src/main.cpp b/tests/MockDataTest/src/main.cpp index 474aa07..ca32213 100644 --- a/tests/MockDataTest/src/main.cpp +++ b/tests/MockDataTest/src/main.cpp @@ -49,7 +49,7 @@ int main() { } while (x <= EmotiBitPacket::maxTestLength + 2) { // Loop until maxTestLength + 2 to account for the first and last messages - EmotiBitPacket::createTestDataPacket(dataMessage); + EmotiBitPacket::createTestDataPacket(dataMessage, EmotiBitPacket::TestType::SAWTOOTHTEST); testfile << dataMessage.str; x++; } From 75602692dfac4303b73e9365b98113c2b66ce77a Mon Sep 17 00:00:00 2001 From: Joseph-Jacobson Date: Mon, 28 Jul 2025 09:26:40 -0700 Subject: [PATCH 15/17] Removed comment --- src/EmotiBitPacket.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EmotiBitPacket.cpp b/src/EmotiBitPacket.cpp index e978611..4a00f52 100644 --- a/src/EmotiBitPacket.cpp +++ b/src/EmotiBitPacket.cpp @@ -553,7 +553,7 @@ String EmotiBitPacket::createTestPacketFixedLength(int testCount) String headerString = EmotiBitPacket::headerToString(header); // Calculate number of dashes needed - int dataLength = testCount - (int)headerString.length() - payloadLengthOffset; //check this on pr + int dataLength = testCount - (int)headerString.length() - payloadLengthOffset; if (dataLength < 0) dataLength = 0; // Prevent negative for (int i = 0; i < dataLength; i++) From 2004f07c2ce764f90127075a91f0442a9514aa85 Mon Sep 17 00:00:00 2001 From: Joseph-Jacobson Date: Tue, 5 Aug 2025 10:30:50 -0700 Subject: [PATCH 16/17] Renaming --- src/EmotiBitPacket.cpp | 4 ++-- src/EmotiBitPacket.h | 6 +++--- tests/MockDataTest/src/main.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/EmotiBitPacket.cpp b/src/EmotiBitPacket.cpp index 4a00f52..c931daf 100644 --- a/src/EmotiBitPacket.cpp +++ b/src/EmotiBitPacket.cpp @@ -495,7 +495,7 @@ void EmotiBitPacket::createTestDataPacket(String &dataMessage, TestType testType dataMessage = EmotiBitPacket::createPacket(beginHeader, data); } //ToDo: Refactor testing structure to be more modular so we can add more tests easily - else if (testCount <= EmotiBitPacket::maxTestLength && testType == TestType::SAWTOOTHTEST) + else if (testCount <= EmotiBitPacket::maxTestLength && testType == TestType::SAWTOOTH) { int dataLength = 0; @@ -506,7 +506,7 @@ void EmotiBitPacket::createTestDataPacket(String &dataMessage, TestType testType testCount++; } - else if (testCount <= EmotiBitPacket::maxTestLength && testType == TestType::FIXEDPACKETLENGTHTEST) // Change splitter to fixedlength + else if (testCount <= EmotiBitPacket::maxTestLength && testType == TestType::FIXED_PACKET_LENGTH) // Change splitter to fixedlength { dataMessage = EmotiBitPacket::createTestPacketFixedLength(testCount); testCount++; diff --git a/src/EmotiBitPacket.h b/src/EmotiBitPacket.h index 6602d04..5ef942b 100644 --- a/src/EmotiBitPacket.h +++ b/src/EmotiBitPacket.h @@ -255,8 +255,8 @@ class EmotiBitPacket { #endif enum TestType { - FIXEDPACKETLENGTHTEST, - SAWTOOTHTEST + FIXED_PACKET_LENGTH, + SAWTOOTH }; EmotiBitPacket(); @@ -363,7 +363,7 @@ enum TestType { //! @param dataMessage reference to the String to append the test data message to //! @param testType Type of the test to create data for //! @note Tests will start when isRecording is true, and with the current implementation, the test will end at the end of the test length - static void createTestDataPacket(String &dataMessage, TestType testType = TestType::SAWTOOTHTEST); + static void createTestDataPacket(String &dataMessage, TestType testType = TestType::SAWTOOTH); //! @brief Creates a test sawtooth data message //! @param outLength reference to an int to store the length of the created sawtooth data message diff --git a/tests/MockDataTest/src/main.cpp b/tests/MockDataTest/src/main.cpp index ca32213..83ee07c 100644 --- a/tests/MockDataTest/src/main.cpp +++ b/tests/MockDataTest/src/main.cpp @@ -49,7 +49,7 @@ int main() { } while (x <= EmotiBitPacket::maxTestLength + 2) { // Loop until maxTestLength + 2 to account for the first and last messages - EmotiBitPacket::createTestDataPacket(dataMessage, EmotiBitPacket::TestType::SAWTOOTHTEST); + EmotiBitPacket::createTestDataPacket(dataMessage, EmotiBitPacket::TestType::SAWTOOTH); testfile << dataMessage.str; x++; } From 0e3750ef02578b8abdb66c77d337733eaddb75bc Mon Sep 17 00:00:00 2001 From: Joseph-Jacobson Date: Fri, 22 Aug 2025 09:26:02 -0700 Subject: [PATCH 17/17] PR updates --- src/EmotiBitPacket.cpp | 10 +++++----- src/EmotiBitPacket.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/EmotiBitPacket.cpp b/src/EmotiBitPacket.cpp index c931daf..a3812eb 100644 --- a/src/EmotiBitPacket.cpp +++ b/src/EmotiBitPacket.cpp @@ -495,7 +495,7 @@ void EmotiBitPacket::createTestDataPacket(String &dataMessage, TestType testType dataMessage = EmotiBitPacket::createPacket(beginHeader, data); } //ToDo: Refactor testing structure to be more modular so we can add more tests easily - else if (testCount <= EmotiBitPacket::maxTestLength && testType == TestType::SAWTOOTH) + else if (testType == TestType::SAWTOOTH && testCount <= EmotiBitPacket::maxTestLength) { int dataLength = 0; @@ -506,7 +506,7 @@ void EmotiBitPacket::createTestDataPacket(String &dataMessage, TestType testType testCount++; } - else if (testCount <= EmotiBitPacket::maxTestLength && testType == TestType::FIXED_PACKET_LENGTH) // Change splitter to fixedlength + else if (testType == TestType::FIXED_PACKET_LENGTH && testCount <= EmotiBitPacket::maxTestLength) // Change splitter to fixedlength { dataMessage = EmotiBitPacket::createTestPacketFixedLength(testCount); testCount++; @@ -541,7 +541,7 @@ String EmotiBitPacket::createTestSawtoothData(int& outLength) return payload; } -String EmotiBitPacket::createTestPacketFixedLength(int testCount) +String EmotiBitPacket::createTestPacketFixedLength(int payloadLength) { String packet; String data; @@ -553,14 +553,14 @@ String EmotiBitPacket::createTestPacketFixedLength(int testCount) String headerString = EmotiBitPacket::headerToString(header); // Calculate number of dashes needed - int dataLength = testCount - (int)headerString.length() - payloadLengthOffset; + 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 + 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; diff --git a/src/EmotiBitPacket.h b/src/EmotiBitPacket.h index 5ef942b..28a129e 100644 --- a/src/EmotiBitPacket.h +++ b/src/EmotiBitPacket.h @@ -371,9 +371,9 @@ enum TestType { static String createTestSawtoothData(int& outLength); //! @brief Creates test data that iterates in increasing length to test splitting functionality - //! @param testCount Test count number to determine what data to send + //! @param payloadLength payload length of the packet to create //! @return String representation of the splitter data message - static String createTestPacketFixedLength(int testCount); + static String createTestPacketFixedLength(int payloadLength); //! @brief Tests the conversion of headers to a String