Skip to content

Commit 713376e

Browse files
committed
Rework for CI test with FVP
1 parent 54ffed9 commit 713376e

File tree

6 files changed

+252
-60
lines changed

6 files changed

+252
-60
lines changed

template/algorithm/sds_control.c

Lines changed: 90 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,16 @@
1818

1919
#include <stdio.h>
2020
#include <stdbool.h>
21+
#include <string.h>
22+
#include "RTE_Components.h"
2123
#include "cmsis_os2.h"
2224
#include "cmsis_vio.h"
2325
#include "sds_main.h"
2426
#include "sds_control.h"
2527
#include "sds_rec_play.h"
28+
#ifdef RTE_SDS_IO_SOCKET
29+
#include "sdsio_config_socket.h"
30+
#endif
2631

2732

2833
// AlgorithmThread thread attributes
@@ -53,25 +58,35 @@ static void rec_play_event_callback (sdsRecPlayId_t id, uint32_t event) {
5358
}
5459

5560
#ifdef SIMULATOR
61+
static uint32_t key_cnt = 0U;
62+
5663
// Simulate keypress
5764
static uint32_t simGetSignal (uint32_t mask) {
58-
static uint32_t key_cnt = 0U;
59-
uint32_t ret = 0U;
65+
uint32_t ret = 0U;
6066

6167
switch (key_cnt) {
68+
#ifdef SDS_PLAY
6269
case 20U: // At 2 seconds
6370
ret = mask; // Simulate keypress
6471
break;
65-
#ifndef SDS_PLAY
66-
case 120U: // At 12 seconds
72+
73+
case 1000U: // At 100 seconds
74+
putchar(0x04); // Send signal to simulator to shutdown
75+
break;
76+
#else
77+
case 10U: // At 1 second
6778
ret = mask; // Simulate keypress
6879
break;
69-
#endif
70-
case 150U: // At 15 seconds
80+
81+
case 110U: // At 11 seconds
82+
ret = mask; // Simulate keypress
83+
break;
84+
85+
case 120U: // At 12 seconds
7186
putchar(0x04); // Send signal to simulator to shutdown
7287
break;
88+
#endif
7389
}
74-
7590
key_cnt++;
7691

7792
return ret;
@@ -88,16 +103,68 @@ __NO_RETURN void sdsControlThread (void *argument) {
88103
uint8_t led0_val = 0U;
89104
uint32_t no_load_cnt, prev_cnt;
90105
uint32_t interval_time, cnt = 0U;
106+
int32_t ret;
91107

92108
// Initialize idle counter
93109
idle_cnt = 0U;
94110
osDelay(10U);
95111
no_load_cnt = idle_cnt;
96112

97113
// Initialize SDS recorder/player
98-
if (sdsRecPlayInit(rec_play_event_callback) != SDS_REC_PLAY_OK) {
99-
printf("SDS initialization failed!\n");
100-
printf("For Network and USB SDSIO Interfaces ensure that SDSIO Server is running and restart the application!\n");
114+
ret = sdsRecPlayInit(rec_play_event_callback);
115+
116+
// Output a diagnostic message about initialization to the STDOUT channel
117+
switch (ret) {
118+
case SDS_REC_PLAY_OK:
119+
#if defined(RTE_SDS_IO_VSI)
120+
printf("SDS I/O VSI interface initialized successfully\n");
121+
#elif defined(RTE_SDS_IO_SOCKET)
122+
printf("Connection to SDSIO-Server at %s:%d established\n", SDSIO_SOCKET_SERVER_IP, SDSIO_SOCKET_SERVER_PORT);
123+
#elif defined(RTE_SDS_IO_USB)
124+
printf("Connection to SDSIO-Server established via USB interface\n");
125+
#elif defined(RTE_SDS_IO_SERIAL_CMSIS_USART)
126+
printf("Connection to SDSIO-Server established via USART interface\n");
127+
#elif defined(RTE_SDS_IO_CUSTOM)
128+
printf("Connection to SDSIO-Server established via custom interface\n");
129+
#elif defined(RTE_SDS_IO_FILE_SYSTEM_MDK_FS)
130+
printf("SDS I/O File System (MDK-FS) interface initialized successfully\n");
131+
#elif defined(RTE_SDS_IO_FILE_SYSTEM_SEMIHOSTING)
132+
printf("SDS I/O File System (SemiHosting) interface initialized successfully\n");
133+
#endif
134+
break;
135+
136+
case SDS_REC_PLAY_ERROR_IO:
137+
#if defined(RTE_SDS_IO_VSI)
138+
printf("SDS I/O VSI interface initialization failed!\n");
139+
#elif defined(RTE_SDS_IO_SOCKET)
140+
if (strcmp(SDSIO_SOCKET_SERVER_IP, "0.0.0.0") == 0) {
141+
printf("SDSIO_SOCKET_SERVER_IP address not configured (see sdsio_config_socket.h)!\n");
142+
} else {
143+
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);
144+
printf("Ensure that SDSIO-Server is running, then restart the application!\n");
145+
}
146+
#elif defined(RTE_SDS_IO_USB)
147+
printf("SDS I/O USB interface initialization failed or 'sdsio-server usb' unavailable!\n");
148+
printf("Ensure that SDSIO-Server is running, then restart the application!\n");
149+
#elif defined(RTE_SDS_IO_SERIAL_CMSIS_USART)
150+
printf("SDS I/O USART interface initialization failed or 'sdsio-server serial' unavailable!\n");
151+
printf("Ensure that SDSIO-Server is running, then restart the application!\n");
152+
#elif defined(RTE_SDS_IO_CUSTOM)
153+
printf("SDS I/O Custom interface initialization failed!\n");
154+
#elif defined(RTE_SDS_IO_FILE_SYSTEM_MDK_FS)
155+
printf("SDS I/O File System MDK-FS interface initialization failed!\n");
156+
#elif defined(RTE_SDS_IO_FILE_SYSTEM_SEMIHOSTING)
157+
printf("SDS I/O File System SemiHosting interface initialization failed!\n");
158+
#endif
159+
break;
160+
161+
case SDS_REC_PLAY_ERROR:
162+
printf("SDS initialization failed to create necessary threads or event flags!\n");
163+
break;
164+
165+
default:
166+
printf("SDS initialization failed with error code: %d\n", ret);
167+
break;
101168
}
102169

103170
// Create algorithm thread
@@ -144,6 +211,19 @@ __NO_RETURN void sdsControlThread (void *argument) {
144211
vioSetSignal(vioLED1, vioLEDoff);
145212
sdsStreamingState = SDS_STREAMING_INACTIVE;
146213
}
214+
#ifdef SDS_PLAY
215+
#ifdef SIMULATOR
216+
// Start next SDS stream
217+
key_cnt = 0U;
218+
#endif
219+
#endif
220+
break;
221+
222+
case SDS_STREAMING_END:
223+
#ifdef SIMULATOR
224+
// Send signal to simulator to shutdown
225+
putchar(0x04);
226+
#endif
147227
break;
148228
}
149229

template/algorithm/sds_control.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ extern "C"
3434
#define SDS_STREAMING_ACTIVE 1 // Streaming is active, SDS streams are open and ready for read/write operations
3535
#define SDS_STREAMING_STOP 2 // Request to stop streaming and close the open streams
3636
#define SDS_STREAMING_STOP_SAFE 3 // Safe state for streaming to be stopped
37+
#define SDS_STREAMING_END 4 // Request to end streaming (no more data)
3738

3839
// Assert macro
3940
#define SDS_ASSERT(cond) \

template/algorithm/sds_main.c

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
#include <stdio.h>
20+
#include "RTE_Components.h"
2021
#include "cmsis_os2.h"
2122
#include "sds_main.h"
2223
#include "sds_control.h"
@@ -50,6 +51,8 @@ static sdsRecPlayId_t recIdDataInput = NULL;
5051
#endif
5152
static sdsRecPlayId_t recIdDataOutput = NULL;
5253

54+
// SDS file sequence number
55+
static uint32_t sequence_num = 0;
5356

5457
// Public functions
5558

@@ -67,7 +70,8 @@ int32_t OpenStreams (void) {
6770
playIdDataInput = sdsPlayOpen("DataInput", sds_play_buf_data_in, sizeof(sds_play_buf_data_in));
6871
SDS_ASSERT(playIdDataInput != NULL);
6972
if (playIdDataInput == NULL) {
70-
printf("Failed to open SDS stream for playback of input data!\n");
73+
sdsStreamingState = SDS_STREAMING_END; // end simulation
74+
printf("No more SDS data files for playback of input data!\n");
7175
status = -1;
7276
}
7377
#else
@@ -80,27 +84,37 @@ int32_t OpenStreams (void) {
8084
}
8185
#endif
8286

83-
// Open stream for recording of output data
84-
recIdDataOutput = sdsRecOpen("DataOutput", sds_rec_buf_data_out, sizeof(sds_rec_buf_data_out));
85-
SDS_ASSERT(recIdDataOutput != NULL);
86-
if (recIdDataOutput == NULL) {
87-
printf("Failed to open SDS stream for recording of output data!\n");
88-
status = -1;
87+
if (status == 0) {
88+
// Open stream for recording of output data
89+
recIdDataOutput = sdsRecOpen("DataOutput", sds_rec_buf_data_out, sizeof(sds_rec_buf_data_out));
90+
SDS_ASSERT(recIdDataOutput != NULL);
91+
if (recIdDataOutput == NULL) {
92+
printf("ERROR: Failed to open SDS stream for recording of output data!\n");
93+
status = -1;
94+
}
8995
}
9096

9197
#ifdef SDS_PLAY
9298
if (status == 0) {
93-
printf("SDS playback and recording started\n");
99+
printf("SDS playback and recording (#%d) started\n", sequence_num);
94100
} else {
95-
printf("SDS playback and recording start failed!\n");
96-
printf("For Network and USB SDSIO Interfaces ensure that SDSIO Server is running and restart the application!\n");
101+
if (sequence_num == 0) {
102+
printf("ERROR: SDS playback and recording start failed!\n");
103+
#if defined(RTE_SDS_IO_SOCKET) || defined(RTE_SDS_IO_USB) || defined(RTE_SDS_IO_SERIAL) || defined(RTE_SDS_IO_CUSTOM)
104+
printf("Ensure that SDSIO Server is running and restart the application!\n");
105+
#endif
106+
}
97107
}
98108
#else
99109
if (status == 0) {
100-
printf("SDS recording started\n");
110+
printf("SDS recording (#%d) started\n", sequence_num);
101111
} else {
102-
printf("SDS recording start failed!\n");
103-
printf("For Network and USB SDSIO Interfaces ensure that SDSIO Server is running and restart the application!\n");
112+
if (sequence_num == 0) {
113+
printf("ERROR: SDS recording start failed!\n");
114+
#if defined(RTE_SDS_IO_SOCKET) || defined(RTE_SDS_IO_USB) || defined(RTE_SDS_IO_SERIAL) || defined(RTE_SDS_IO_CUSTOM)
115+
printf("Ensure that SDSIO Server is running and restart the application!\n");
116+
#endif
117+
}
104118
}
105119
#endif
106120

@@ -120,15 +134,15 @@ int32_t CloseStreams (void) {
120134
status = sdsPlayClose(playIdDataInput);
121135
SDS_ASSERT(status == SDS_REC_PLAY_OK);
122136
if (status != 0) {
123-
printf("Failed to close SDS stream for playback of input data!\n");
137+
printf("ERROR: Failed to close SDS stream for playback of input data!\n");
124138
status = -1;
125139
}
126140
#else
127141
// Close stream for recording of input data
128142
status = sdsRecClose(recIdDataInput);
129143
SDS_ASSERT(status == SDS_REC_PLAY_OK);
130144
if (status != 0) {
131-
printf("Failed to close SDS stream for recording of input data!\n");
145+
printf("ERROR: Failed to close SDS stream for recording of input data!\n");
132146
status = -1;
133147
}
134148
#endif
@@ -137,23 +151,24 @@ int32_t CloseStreams (void) {
137151
status = sdsRecClose(recIdDataOutput);
138152
SDS_ASSERT(status == SDS_REC_PLAY_OK);
139153
if (status != 0) {
140-
printf("Failed to close SDS stream for recording of output data!\n");
154+
printf("ERROR: Failed to close SDS stream for recording of output data!\n");
141155
status = -1;
142156
}
143157

144158
#ifdef SDS_PLAY
145159
if (status == 0) {
146-
printf("SDS playback and recording stopped\n");
160+
printf("SDS playback and recording (#%d) stopped\n====\n\n", sequence_num);
147161
} else {
148-
printf("SDS playback and recording stop failed!\n");
162+
printf("ERROR: SDS playback and recording stop failed!\n====\n\n");
149163
}
150164
#else
151165
if (status == 0) {
152-
printf("SDS recording stopped\n");
166+
printf("SDS recording (#%d) stopped\n====\n\n", sequence_num);
153167
} else {
154-
printf("SDS recording stop failed!\n");
168+
printf("ERROR: SDS recording stop failed!\n====\n\n");
155169
}
156170
#endif
171+
sequence_num++;
157172

158173
return status;
159174
}

0 commit comments

Comments
 (0)