Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:gabryelreyes/SerialMuxProt into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
gabryelreyes committed Nov 20, 2023
2 parents 5deed50 + 7011597 commit 7534c3e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
1 change: 1 addition & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ check_src_filters =
check_flags =
clangtidy: --header-filter='' --checks=-*,clang-analyzer-*,performance-*,portability-*,readability-uppercase-literal-suffix,readability-redundant-control-flow --warnings-as-errors=-*,clang-analyzer-*,performance-*,portability-*,readability-uppercase-literal-suffix,readability-redundant-control-flow
check_skip_packages = yes
debug_test = test_SerialMuxProt

[env:esp32dev]
platform = espressif32
Expand Down
44 changes: 23 additions & 21 deletions test/test_SerialMuxProt/test_SerialMuxProt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include <unity.h>
#include <TestStream.h>
#include <SerialMuxProtServer.hpp>

#include <stdio.h>
/******************************************************************************
* Compiler Switches
*****************************************************************************/
Expand Down Expand Up @@ -180,14 +180,14 @@ static void testCmdSync()
{
SerialMuxProtServer<2U> testSerialMuxProtServer(gTestStream);
uint8_t expectedOutputBufferVector[6U][MAX_FRAME_LEN] = {
{0x00, 0x0F, 0xFA, 0x00, 0x00, 0x00, 0x03, 0xE8}, /* SYNC 1000ms*/
{0x00, 0x0F, 0xE6, 0x00, 0x00, 0x00, 0x07, 0xD0}, /* SYNC 2000ms*/
{0x00, 0x0F, 0x82, 0x00, 0x00, 0x00, 0x1B, 0x58}, /* SYNC 7000ms*/
{0x00, 0x0F, 0x1E, 0x00, 0x00, 0x00, 0x2E, 0xE0}, /* SYNC 12000ms*/
{0x00, 0x0F, 0xB9, 0x00, 0x00, 0x00, 0x42, 0x68} /* SYNC 17000ms*/
{0x00, 0x10, 0xFB, 0x00, 0xE8, 0x03, 0x00, 0x00}, /* SYNC 1000ms*/
{0x00, 0x10, 0xE7, 0x00, 0xD0, 0x07, 0x00, 0x00}, /* SYNC 2000ms*/
{0x00, 0x10, 0x83, 0x00, 0x58, 0x1B, 0x00, 0x00}, /* SYNC 7000ms*/
{0x00, 0x10, 0x1F, 0x00, 0xE0, 0x2E, 0x00, 0x00}, /* SYNC 12000ms*/
{0x00, 0x10, 0xBA, 0x00, 0x68, 0x42, 0x00, 0x00} /* SYNC 17000ms*/
};
uint8_t inputQueueVector[2U][MAX_FRAME_LEN] = {{0x00, 0x0F, 0xE7, 0x01, 0x00, 0x00, 0x07, 0xD0},
{0x00, 0x0F, 0x83, 0x01, 0x00, 0x00, 0x1B, 0x58}};
uint8_t inputQueueVector[2U][MAX_FRAME_LEN] = {{0x00, 0x10, 0xE8, 0x01, 0xD0, 0x07, 0x00, 0x00},
{0x00, 0x10, 0x84, 0x01, 0x58, 0x1B, 0x00, 0x00}};

/*
* Case: Unsynced Heartbeat.
Expand Down Expand Up @@ -293,12 +293,12 @@ static void testCmdSyncRsp()
uint8_t testTime = 0U;
uint8_t numberOfCases = 3U;
uint8_t expectedOutputBufferVector[numberOfCases][MAX_FRAME_LEN] = {
{0x00, 0x0F, 0x10, 0x01, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x0F, 0x25, 0x01, 0x12, 0x34, 0x56, 0x78},
{0x00, 0x0F, 0x10, 0x01, 0xFF, 0xFF, 0xFF, 0xFF}};
uint8_t inputQueueVector[numberOfCases][MAX_FRAME_LEN] = {{0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x0F, 0x24, 0x00, 0x12, 0x34, 0x56, 0x78},
{0x00, 0x0F, 0x0F, 0x00, 0xFF, 0xFF, 0xFF, 0xFF}};
{0x00, 0x10, 0x11, 0x01, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x10, 0x26, 0x01, 0x78, 0x56, 0x34, 0x12},
{0x00, 0x10, 0x11, 0x01, 0xFF, 0xFF, 0xFF, 0xFF}};
uint8_t inputQueueVector[numberOfCases][MAX_FRAME_LEN] = {{0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x10, 0x25, 0x00, 0x78, 0x56, 0x34, 0x12},
{0x00, 0x10, 0x10, 0x00, 0xFF, 0xFF, 0xFF, 0xFF}};

/* Ignore SYNC */
testSerialMuxProtServer.process(testTime++);
Expand Down Expand Up @@ -326,9 +326,10 @@ static void testCmdScrb()
uint8_t testTime = 0U;
uint8_t numberOfCases = 2U;
uint8_t expectedOutputBufferVector[numberOfCases][MAX_FRAME_LEN] = {
{0x00, 0x0F, 0x53, 0x03, 0x00, 'T', 'E', 'S', 'T'}, {0x00, 0x0F, 0x54, 0x03, 0x01, 'T', 'E', 'S', 'T'}};
{0x00, 0x10, 0x54, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 'T', 'E', 'S', 'T'},
{0x00, 0x10, 0x55, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 'T', 'E', 'S', 'T'}};
uint8_t inputQueueVector[numberOfCases][MAX_FRAME_LEN] = {
{0x00, 0x0F, 0x52, 0x02, 'T', 'E', 'S', 'T', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
{0x00, 0x10, 0x53, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 'T', 'E', 'S', 'T', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};

/* Ignore SYNC */
testSerialMuxProtServer.process(testTime++);
Expand Down Expand Up @@ -378,10 +379,11 @@ static void testCmdScrbRsp()
uint8_t testTime = 1U;
uint8_t numberOfCases = 3U;
uint8_t expectedOutputBufferVector[numberOfCases][MAX_FRAME_LEN] = {
{0x00, 0x0F, 0x52, 0x02, 'T', 'E', 'S', 'T', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
uint8_t inputQueueVector[numberOfCases][MAX_FRAME_LEN] = {{0x00, 0x0F, 0x10, 0x01, 0x00, 0x00, 0x00},
{0x00, 0x0F, 0x53, 0x03, 0x00, 'T', 'E', 'S', 'T'},
{0x00, 0x0F, 0x54, 0x03, 0x01, 'T', 'E', 'S', 'T'}};
{0x00, 0x10, 0x53, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 'T', 'E', 'S', 'T', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
uint8_t inputQueueVector[numberOfCases][MAX_FRAME_LEN] = {
{0x00, 0x10, 0x11, 0x01, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x10, 0x54, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 'T', 'E', 'S', 'T'},
{0x00, 0x10, 0x55, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 'T', 'E', 'S', 'T'}};

/*
* Case: Suscribe to Unknown Channel
Expand Down Expand Up @@ -506,7 +508,7 @@ static void testDataSend()
{
SerialMuxProtServer<1U> testSerialMuxProtServer(gTestStream);
uint8_t expectedOutputBufferVector[1U][MAX_FRAME_LEN] = {{0x01, 0x04, 0x1A, 0x12, 0x34, 0x56, 0x78}};
uint8_t inputQueueVector[1U][MAX_FRAME_LEN] = {{0x00, 0x0F, 0x10, 0x01, 0x00, 0x00, 0x00}};
uint8_t inputQueueVector[1U][MAX_FRAME_LEN] = {{0x00, 0x10, 0x11, 0x01, 0x00, 0x00, 0x00, 0x00}};

/* Flush Stream */
gTestStream.flushInputBuffer();
Expand Down

0 comments on commit 7534c3e

Please sign in to comment.