From 713376e821908ab7aac6e2df476b086f7467aee4 Mon Sep 17 00:00:00 2001 From: Franc Urbanc Date: Tue, 11 Nov 2025 14:35:34 +0100 Subject: [PATCH] Rework for CI test with FVP --- template/algorithm/sds_control.c | 100 +++++++++++++++++++++++++++---- template/algorithm/sds_control.h | 1 + template/algorithm/sds_main.c | 55 ++++++++++------- template/datatest/sds_control.c | 100 +++++++++++++++++++++++++++---- template/datatest/sds_control.h | 1 + template/datatest/sds_main.c | 55 ++++++++++------- 6 files changed, 252 insertions(+), 60 deletions(-) diff --git a/template/algorithm/sds_control.c b/template/algorithm/sds_control.c index b0bbac34..d2caae82 100644 --- a/template/algorithm/sds_control.c +++ b/template/algorithm/sds_control.c @@ -18,11 +18,16 @@ #include #include +#include +#include "RTE_Components.h" #include "cmsis_os2.h" #include "cmsis_vio.h" #include "sds_main.h" #include "sds_control.h" #include "sds_rec_play.h" +#ifdef RTE_SDS_IO_SOCKET +#include "sdsio_config_socket.h" +#endif // AlgorithmThread thread attributes @@ -53,25 +58,35 @@ static void rec_play_event_callback (sdsRecPlayId_t id, uint32_t event) { } #ifdef SIMULATOR +static uint32_t key_cnt = 0U; + // Simulate keypress static uint32_t simGetSignal (uint32_t mask) { - static uint32_t key_cnt = 0U; - uint32_t ret = 0U; + uint32_t ret = 0U; switch (key_cnt) { +#ifdef SDS_PLAY case 20U: // At 2 seconds ret = mask; // Simulate keypress break; -#ifndef SDS_PLAY - case 120U: // At 12 seconds + + case 1000U: // At 100 seconds + putchar(0x04); // Send signal to simulator to shutdown + break; +#else + case 10U: // At 1 second ret = mask; // Simulate keypress break; -#endif - case 150U: // At 15 seconds + + case 110U: // At 11 seconds + ret = mask; // Simulate keypress + break; + + case 120U: // At 12 seconds putchar(0x04); // Send signal to simulator to shutdown break; +#endif } - key_cnt++; return ret; @@ -88,6 +103,7 @@ __NO_RETURN void sdsControlThread (void *argument) { uint8_t led0_val = 0U; uint32_t no_load_cnt, prev_cnt; uint32_t interval_time, cnt = 0U; + int32_t ret; // Initialize idle counter idle_cnt = 0U; @@ -95,9 +111,60 @@ __NO_RETURN void sdsControlThread (void *argument) { no_load_cnt = idle_cnt; // Initialize SDS recorder/player - if (sdsRecPlayInit(rec_play_event_callback) != SDS_REC_PLAY_OK) { - printf("SDS initialization failed!\n"); - printf("For Network and USB SDSIO Interfaces ensure that SDSIO Server is running and restart the application!\n"); + ret = sdsRecPlayInit(rec_play_event_callback); + + // Output a diagnostic message about initialization to the STDOUT channel + switch (ret) { + case SDS_REC_PLAY_OK: +#if defined(RTE_SDS_IO_VSI) + printf("SDS I/O VSI interface initialized successfully\n"); +#elif defined(RTE_SDS_IO_SOCKET) + printf("Connection to SDSIO-Server at %s:%d established\n", SDSIO_SOCKET_SERVER_IP, SDSIO_SOCKET_SERVER_PORT); +#elif defined(RTE_SDS_IO_USB) + printf("Connection to SDSIO-Server established via USB interface\n"); +#elif defined(RTE_SDS_IO_SERIAL_CMSIS_USART) + printf("Connection to SDSIO-Server established via USART interface\n"); +#elif defined(RTE_SDS_IO_CUSTOM) + printf("Connection to SDSIO-Server established via custom interface\n"); +#elif defined(RTE_SDS_IO_FILE_SYSTEM_MDK_FS) + printf("SDS I/O File System (MDK-FS) interface initialized successfully\n"); +#elif defined(RTE_SDS_IO_FILE_SYSTEM_SEMIHOSTING) + printf("SDS I/O File System (SemiHosting) interface initialized successfully\n"); +#endif + break; + + case SDS_REC_PLAY_ERROR_IO: +#if defined(RTE_SDS_IO_VSI) + printf("SDS I/O VSI interface initialization failed!\n"); +#elif defined(RTE_SDS_IO_SOCKET) + if (strcmp(SDSIO_SOCKET_SERVER_IP, "0.0.0.0") == 0) { + printf("SDSIO_SOCKET_SERVER_IP address not configured (see sdsio_config_socket.h)!\n"); + } else { + printf("SDS I/O Network interface initialization failed or 'sdsio-server socket' unavailable at %s:%d !\n", SDSIO_SOCKET_SERVER_IP, SDSIO_SOCKET_SERVER_PORT); + printf("Ensure that SDSIO-Server is running, then restart the application!\n"); + } +#elif defined(RTE_SDS_IO_USB) + printf("SDS I/O USB interface initialization failed or 'sdsio-server usb' unavailable!\n"); + printf("Ensure that SDSIO-Server is running, then restart the application!\n"); +#elif defined(RTE_SDS_IO_SERIAL_CMSIS_USART) + printf("SDS I/O USART interface initialization failed or 'sdsio-server serial' unavailable!\n"); + printf("Ensure that SDSIO-Server is running, then restart the application!\n"); +#elif defined(RTE_SDS_IO_CUSTOM) + printf("SDS I/O Custom interface initialization failed!\n"); +#elif defined(RTE_SDS_IO_FILE_SYSTEM_MDK_FS) + printf("SDS I/O File System MDK-FS interface initialization failed!\n"); +#elif defined(RTE_SDS_IO_FILE_SYSTEM_SEMIHOSTING) + printf("SDS I/O File System SemiHosting interface initialization failed!\n"); +#endif + break; + + case SDS_REC_PLAY_ERROR: + printf("SDS initialization failed to create necessary threads or event flags!\n"); + break; + + default: + printf("SDS initialization failed with error code: %d\n", ret); + break; } // Create algorithm thread @@ -144,6 +211,19 @@ __NO_RETURN void sdsControlThread (void *argument) { vioSetSignal(vioLED1, vioLEDoff); sdsStreamingState = SDS_STREAMING_INACTIVE; } +#ifdef SDS_PLAY +#ifdef SIMULATOR + // Start next SDS stream + key_cnt = 0U; +#endif +#endif + break; + + case SDS_STREAMING_END: +#ifdef SIMULATOR + // Send signal to simulator to shutdown + putchar(0x04); +#endif break; } diff --git a/template/algorithm/sds_control.h b/template/algorithm/sds_control.h index 17f619fa..36ddb6eb 100644 --- a/template/algorithm/sds_control.h +++ b/template/algorithm/sds_control.h @@ -34,6 +34,7 @@ extern "C" #define SDS_STREAMING_ACTIVE 1 // Streaming is active, SDS streams are open and ready for read/write operations #define SDS_STREAMING_STOP 2 // Request to stop streaming and close the open streams #define SDS_STREAMING_STOP_SAFE 3 // Safe state for streaming to be stopped +#define SDS_STREAMING_END 4 // Request to end streaming (no more data) // Assert macro #define SDS_ASSERT(cond) \ diff --git a/template/algorithm/sds_main.c b/template/algorithm/sds_main.c index 3102690f..fb04e3ed 100644 --- a/template/algorithm/sds_main.c +++ b/template/algorithm/sds_main.c @@ -17,6 +17,7 @@ */ #include +#include "RTE_Components.h" #include "cmsis_os2.h" #include "sds_main.h" #include "sds_control.h" @@ -50,6 +51,8 @@ static sdsRecPlayId_t recIdDataInput = NULL; #endif static sdsRecPlayId_t recIdDataOutput = NULL; +// SDS file sequence number +static uint32_t sequence_num = 0; // Public functions @@ -67,7 +70,8 @@ int32_t OpenStreams (void) { playIdDataInput = sdsPlayOpen("DataInput", sds_play_buf_data_in, sizeof(sds_play_buf_data_in)); SDS_ASSERT(playIdDataInput != NULL); if (playIdDataInput == NULL) { - printf("Failed to open SDS stream for playback of input data!\n"); + sdsStreamingState = SDS_STREAMING_END; // end simulation + printf("No more SDS data files for playback of input data!\n"); status = -1; } #else @@ -80,27 +84,37 @@ int32_t OpenStreams (void) { } #endif - // Open stream for recording of output data - recIdDataOutput = sdsRecOpen("DataOutput", sds_rec_buf_data_out, sizeof(sds_rec_buf_data_out)); - SDS_ASSERT(recIdDataOutput != NULL); - if (recIdDataOutput == NULL) { - printf("Failed to open SDS stream for recording of output data!\n"); - status = -1; + if (status == 0) { + // Open stream for recording of output data + recIdDataOutput = sdsRecOpen("DataOutput", sds_rec_buf_data_out, sizeof(sds_rec_buf_data_out)); + SDS_ASSERT(recIdDataOutput != NULL); + if (recIdDataOutput == NULL) { + printf("ERROR: Failed to open SDS stream for recording of output data!\n"); + status = -1; + } } #ifdef SDS_PLAY if (status == 0) { - printf("SDS playback and recording started\n"); + printf("SDS playback and recording (#%d) started\n", sequence_num); } else { - printf("SDS playback and recording start failed!\n"); - printf("For Network and USB SDSIO Interfaces ensure that SDSIO Server is running and restart the application!\n"); + if (sequence_num == 0) { + printf("ERROR: SDS playback and recording start failed!\n"); +#if defined(RTE_SDS_IO_SOCKET) || defined(RTE_SDS_IO_USB) || defined(RTE_SDS_IO_SERIAL) || defined(RTE_SDS_IO_CUSTOM) + printf("Ensure that SDSIO Server is running and restart the application!\n"); +#endif + } } #else if (status == 0) { - printf("SDS recording started\n"); + printf("SDS recording (#%d) started\n", sequence_num); } else { - printf("SDS recording start failed!\n"); - printf("For Network and USB SDSIO Interfaces ensure that SDSIO Server is running and restart the application!\n"); + if (sequence_num == 0) { + printf("ERROR: SDS recording start failed!\n"); +#if defined(RTE_SDS_IO_SOCKET) || defined(RTE_SDS_IO_USB) || defined(RTE_SDS_IO_SERIAL) || defined(RTE_SDS_IO_CUSTOM) + printf("Ensure that SDSIO Server is running and restart the application!\n"); +#endif + } } #endif @@ -120,7 +134,7 @@ int32_t CloseStreams (void) { status = sdsPlayClose(playIdDataInput); SDS_ASSERT(status == SDS_REC_PLAY_OK); if (status != 0) { - printf("Failed to close SDS stream for playback of input data!\n"); + printf("ERROR: Failed to close SDS stream for playback of input data!\n"); status = -1; } #else @@ -128,7 +142,7 @@ int32_t CloseStreams (void) { status = sdsRecClose(recIdDataInput); SDS_ASSERT(status == SDS_REC_PLAY_OK); if (status != 0) { - printf("Failed to close SDS stream for recording of input data!\n"); + printf("ERROR: Failed to close SDS stream for recording of input data!\n"); status = -1; } #endif @@ -137,23 +151,24 @@ int32_t CloseStreams (void) { status = sdsRecClose(recIdDataOutput); SDS_ASSERT(status == SDS_REC_PLAY_OK); if (status != 0) { - printf("Failed to close SDS stream for recording of output data!\n"); + printf("ERROR: Failed to close SDS stream for recording of output data!\n"); status = -1; } #ifdef SDS_PLAY if (status == 0) { - printf("SDS playback and recording stopped\n"); + printf("SDS playback and recording (#%d) stopped\n====\n\n", sequence_num); } else { - printf("SDS playback and recording stop failed!\n"); + printf("ERROR: SDS playback and recording stop failed!\n====\n\n"); } #else if (status == 0) { - printf("SDS recording stopped\n"); + printf("SDS recording (#%d) stopped\n====\n\n", sequence_num); } else { - printf("SDS recording stop failed!\n"); + printf("ERROR: SDS recording stop failed!\n====\n\n"); } #endif + sequence_num++; return status; } diff --git a/template/datatest/sds_control.c b/template/datatest/sds_control.c index b0bbac34..d2caae82 100644 --- a/template/datatest/sds_control.c +++ b/template/datatest/sds_control.c @@ -18,11 +18,16 @@ #include #include +#include +#include "RTE_Components.h" #include "cmsis_os2.h" #include "cmsis_vio.h" #include "sds_main.h" #include "sds_control.h" #include "sds_rec_play.h" +#ifdef RTE_SDS_IO_SOCKET +#include "sdsio_config_socket.h" +#endif // AlgorithmThread thread attributes @@ -53,25 +58,35 @@ static void rec_play_event_callback (sdsRecPlayId_t id, uint32_t event) { } #ifdef SIMULATOR +static uint32_t key_cnt = 0U; + // Simulate keypress static uint32_t simGetSignal (uint32_t mask) { - static uint32_t key_cnt = 0U; - uint32_t ret = 0U; + uint32_t ret = 0U; switch (key_cnt) { +#ifdef SDS_PLAY case 20U: // At 2 seconds ret = mask; // Simulate keypress break; -#ifndef SDS_PLAY - case 120U: // At 12 seconds + + case 1000U: // At 100 seconds + putchar(0x04); // Send signal to simulator to shutdown + break; +#else + case 10U: // At 1 second ret = mask; // Simulate keypress break; -#endif - case 150U: // At 15 seconds + + case 110U: // At 11 seconds + ret = mask; // Simulate keypress + break; + + case 120U: // At 12 seconds putchar(0x04); // Send signal to simulator to shutdown break; +#endif } - key_cnt++; return ret; @@ -88,6 +103,7 @@ __NO_RETURN void sdsControlThread (void *argument) { uint8_t led0_val = 0U; uint32_t no_load_cnt, prev_cnt; uint32_t interval_time, cnt = 0U; + int32_t ret; // Initialize idle counter idle_cnt = 0U; @@ -95,9 +111,60 @@ __NO_RETURN void sdsControlThread (void *argument) { no_load_cnt = idle_cnt; // Initialize SDS recorder/player - if (sdsRecPlayInit(rec_play_event_callback) != SDS_REC_PLAY_OK) { - printf("SDS initialization failed!\n"); - printf("For Network and USB SDSIO Interfaces ensure that SDSIO Server is running and restart the application!\n"); + ret = sdsRecPlayInit(rec_play_event_callback); + + // Output a diagnostic message about initialization to the STDOUT channel + switch (ret) { + case SDS_REC_PLAY_OK: +#if defined(RTE_SDS_IO_VSI) + printf("SDS I/O VSI interface initialized successfully\n"); +#elif defined(RTE_SDS_IO_SOCKET) + printf("Connection to SDSIO-Server at %s:%d established\n", SDSIO_SOCKET_SERVER_IP, SDSIO_SOCKET_SERVER_PORT); +#elif defined(RTE_SDS_IO_USB) + printf("Connection to SDSIO-Server established via USB interface\n"); +#elif defined(RTE_SDS_IO_SERIAL_CMSIS_USART) + printf("Connection to SDSIO-Server established via USART interface\n"); +#elif defined(RTE_SDS_IO_CUSTOM) + printf("Connection to SDSIO-Server established via custom interface\n"); +#elif defined(RTE_SDS_IO_FILE_SYSTEM_MDK_FS) + printf("SDS I/O File System (MDK-FS) interface initialized successfully\n"); +#elif defined(RTE_SDS_IO_FILE_SYSTEM_SEMIHOSTING) + printf("SDS I/O File System (SemiHosting) interface initialized successfully\n"); +#endif + break; + + case SDS_REC_PLAY_ERROR_IO: +#if defined(RTE_SDS_IO_VSI) + printf("SDS I/O VSI interface initialization failed!\n"); +#elif defined(RTE_SDS_IO_SOCKET) + if (strcmp(SDSIO_SOCKET_SERVER_IP, "0.0.0.0") == 0) { + printf("SDSIO_SOCKET_SERVER_IP address not configured (see sdsio_config_socket.h)!\n"); + } else { + printf("SDS I/O Network interface initialization failed or 'sdsio-server socket' unavailable at %s:%d !\n", SDSIO_SOCKET_SERVER_IP, SDSIO_SOCKET_SERVER_PORT); + printf("Ensure that SDSIO-Server is running, then restart the application!\n"); + } +#elif defined(RTE_SDS_IO_USB) + printf("SDS I/O USB interface initialization failed or 'sdsio-server usb' unavailable!\n"); + printf("Ensure that SDSIO-Server is running, then restart the application!\n"); +#elif defined(RTE_SDS_IO_SERIAL_CMSIS_USART) + printf("SDS I/O USART interface initialization failed or 'sdsio-server serial' unavailable!\n"); + printf("Ensure that SDSIO-Server is running, then restart the application!\n"); +#elif defined(RTE_SDS_IO_CUSTOM) + printf("SDS I/O Custom interface initialization failed!\n"); +#elif defined(RTE_SDS_IO_FILE_SYSTEM_MDK_FS) + printf("SDS I/O File System MDK-FS interface initialization failed!\n"); +#elif defined(RTE_SDS_IO_FILE_SYSTEM_SEMIHOSTING) + printf("SDS I/O File System SemiHosting interface initialization failed!\n"); +#endif + break; + + case SDS_REC_PLAY_ERROR: + printf("SDS initialization failed to create necessary threads or event flags!\n"); + break; + + default: + printf("SDS initialization failed with error code: %d\n", ret); + break; } // Create algorithm thread @@ -144,6 +211,19 @@ __NO_RETURN void sdsControlThread (void *argument) { vioSetSignal(vioLED1, vioLEDoff); sdsStreamingState = SDS_STREAMING_INACTIVE; } +#ifdef SDS_PLAY +#ifdef SIMULATOR + // Start next SDS stream + key_cnt = 0U; +#endif +#endif + break; + + case SDS_STREAMING_END: +#ifdef SIMULATOR + // Send signal to simulator to shutdown + putchar(0x04); +#endif break; } diff --git a/template/datatest/sds_control.h b/template/datatest/sds_control.h index 17f619fa..36ddb6eb 100644 --- a/template/datatest/sds_control.h +++ b/template/datatest/sds_control.h @@ -34,6 +34,7 @@ extern "C" #define SDS_STREAMING_ACTIVE 1 // Streaming is active, SDS streams are open and ready for read/write operations #define SDS_STREAMING_STOP 2 // Request to stop streaming and close the open streams #define SDS_STREAMING_STOP_SAFE 3 // Safe state for streaming to be stopped +#define SDS_STREAMING_END 4 // Request to end streaming (no more data) // Assert macro #define SDS_ASSERT(cond) \ diff --git a/template/datatest/sds_main.c b/template/datatest/sds_main.c index 3102690f..fb04e3ed 100644 --- a/template/datatest/sds_main.c +++ b/template/datatest/sds_main.c @@ -17,6 +17,7 @@ */ #include +#include "RTE_Components.h" #include "cmsis_os2.h" #include "sds_main.h" #include "sds_control.h" @@ -50,6 +51,8 @@ static sdsRecPlayId_t recIdDataInput = NULL; #endif static sdsRecPlayId_t recIdDataOutput = NULL; +// SDS file sequence number +static uint32_t sequence_num = 0; // Public functions @@ -67,7 +70,8 @@ int32_t OpenStreams (void) { playIdDataInput = sdsPlayOpen("DataInput", sds_play_buf_data_in, sizeof(sds_play_buf_data_in)); SDS_ASSERT(playIdDataInput != NULL); if (playIdDataInput == NULL) { - printf("Failed to open SDS stream for playback of input data!\n"); + sdsStreamingState = SDS_STREAMING_END; // end simulation + printf("No more SDS data files for playback of input data!\n"); status = -1; } #else @@ -80,27 +84,37 @@ int32_t OpenStreams (void) { } #endif - // Open stream for recording of output data - recIdDataOutput = sdsRecOpen("DataOutput", sds_rec_buf_data_out, sizeof(sds_rec_buf_data_out)); - SDS_ASSERT(recIdDataOutput != NULL); - if (recIdDataOutput == NULL) { - printf("Failed to open SDS stream for recording of output data!\n"); - status = -1; + if (status == 0) { + // Open stream for recording of output data + recIdDataOutput = sdsRecOpen("DataOutput", sds_rec_buf_data_out, sizeof(sds_rec_buf_data_out)); + SDS_ASSERT(recIdDataOutput != NULL); + if (recIdDataOutput == NULL) { + printf("ERROR: Failed to open SDS stream for recording of output data!\n"); + status = -1; + } } #ifdef SDS_PLAY if (status == 0) { - printf("SDS playback and recording started\n"); + printf("SDS playback and recording (#%d) started\n", sequence_num); } else { - printf("SDS playback and recording start failed!\n"); - printf("For Network and USB SDSIO Interfaces ensure that SDSIO Server is running and restart the application!\n"); + if (sequence_num == 0) { + printf("ERROR: SDS playback and recording start failed!\n"); +#if defined(RTE_SDS_IO_SOCKET) || defined(RTE_SDS_IO_USB) || defined(RTE_SDS_IO_SERIAL) || defined(RTE_SDS_IO_CUSTOM) + printf("Ensure that SDSIO Server is running and restart the application!\n"); +#endif + } } #else if (status == 0) { - printf("SDS recording started\n"); + printf("SDS recording (#%d) started\n", sequence_num); } else { - printf("SDS recording start failed!\n"); - printf("For Network and USB SDSIO Interfaces ensure that SDSIO Server is running and restart the application!\n"); + if (sequence_num == 0) { + printf("ERROR: SDS recording start failed!\n"); +#if defined(RTE_SDS_IO_SOCKET) || defined(RTE_SDS_IO_USB) || defined(RTE_SDS_IO_SERIAL) || defined(RTE_SDS_IO_CUSTOM) + printf("Ensure that SDSIO Server is running and restart the application!\n"); +#endif + } } #endif @@ -120,7 +134,7 @@ int32_t CloseStreams (void) { status = sdsPlayClose(playIdDataInput); SDS_ASSERT(status == SDS_REC_PLAY_OK); if (status != 0) { - printf("Failed to close SDS stream for playback of input data!\n"); + printf("ERROR: Failed to close SDS stream for playback of input data!\n"); status = -1; } #else @@ -128,7 +142,7 @@ int32_t CloseStreams (void) { status = sdsRecClose(recIdDataInput); SDS_ASSERT(status == SDS_REC_PLAY_OK); if (status != 0) { - printf("Failed to close SDS stream for recording of input data!\n"); + printf("ERROR: Failed to close SDS stream for recording of input data!\n"); status = -1; } #endif @@ -137,23 +151,24 @@ int32_t CloseStreams (void) { status = sdsRecClose(recIdDataOutput); SDS_ASSERT(status == SDS_REC_PLAY_OK); if (status != 0) { - printf("Failed to close SDS stream for recording of output data!\n"); + printf("ERROR: Failed to close SDS stream for recording of output data!\n"); status = -1; } #ifdef SDS_PLAY if (status == 0) { - printf("SDS playback and recording stopped\n"); + printf("SDS playback and recording (#%d) stopped\n====\n\n", sequence_num); } else { - printf("SDS playback and recording stop failed!\n"); + printf("ERROR: SDS playback and recording stop failed!\n====\n\n"); } #else if (status == 0) { - printf("SDS recording stopped\n"); + printf("SDS recording (#%d) stopped\n====\n\n", sequence_num); } else { - printf("SDS recording stop failed!\n"); + printf("ERROR: SDS recording stop failed!\n====\n\n"); } #endif + sequence_num++; return status; }