Skip to content

Commit b3cd44e

Browse files
Improve diagnostic message for sdsRecPlayInit results in sds_control.c
1 parent f28dc06 commit b3cd44e

File tree

6 files changed

+349
-43
lines changed

6 files changed

+349
-43
lines changed

Alif/AppKit/algorithm/sds_control.c

Lines changed: 59 additions & 4 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
@@ -88,18 +93,68 @@ __NO_RETURN void sdsControlThread (void *argument) {
8893
uint8_t led0_val = 0U;
8994
uint32_t no_load_cnt, prev_cnt;
9095
uint32_t interval_time, cnt = 0U;
96+
int32_t ret;
9197

9298
// Initialize idle counter
9399
idle_cnt = 0U;
94100
osDelay(10U);
95101
no_load_cnt = idle_cnt;
96102

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

105160
// Create algorithm thread

Alif/AppKit/datatest/sds_control.c

Lines changed: 59 additions & 4 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
@@ -88,18 +93,68 @@ __NO_RETURN void sdsControlThread (void *argument) {
8893
uint8_t led0_val = 0U;
8994
uint32_t no_load_cnt, prev_cnt;
9095
uint32_t interval_time, cnt = 0U;
96+
int32_t ret;
9197

9298
// Initialize idle counter
9399
idle_cnt = 0U;
94100
osDelay(10U);
95101
no_load_cnt = idle_cnt;
96102

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

105160
// Create algorithm thread

Alif/DevKit/algorithm/sds_control.c

Lines changed: 56 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919
#include <stdio.h>
2020
#include <stdbool.h>
2121
#include <string.h>
22+
#include "RTE_Components.h"
2223
#include "cmsis_os2.h"
2324
#include "cmsis_vio.h"
2425
#include "sds_main.h"
2526
#include "sds_control.h"
2627
#include "sds_rec_play.h"
27-
#ifndef SIMULATOR
28+
#ifdef RTE_SDS_IO_SOCKET
2829
#include "sdsio_config_socket.h"
2930
#endif
3031

@@ -92,27 +93,68 @@ __NO_RETURN void sdsControlThread (void *argument) {
9293
uint8_t led0_val = 0U;
9394
uint32_t no_load_cnt, prev_cnt;
9495
uint32_t interval_time, cnt = 0U;
96+
int32_t ret;
9597

9698
// Initialize idle counter
9799
idle_cnt = 0U;
98100
osDelay(10U);
99101
no_load_cnt = idle_cnt;
100102

101103
// Initialize SDS recorder/player
102-
if (sdsRecPlayInit(rec_play_event_callback) != SDS_REC_PLAY_OK) {
103-
printf("SDS initialization failed!\n");
104-
#ifndef SIMULATOR
105-
if (strcmp(SDSIO_SOCKET_SERVER_IP, "0.0.0.0") == 0) {
106-
printf("SDSIO_SOCKET_SERVER_IP address not configured (see sdsio_config_socket.h)\n");
107-
}
108-
else {
109-
printf("'sdsio-server socket' on %s:%d not responding.\n", SDSIO_SOCKET_SERVER_IP, SDSIO_SOCKET_SERVER_PORT);
110-
printf("Ensure that SDSIO Server is running and restart the application!\n");
111-
}
112-
}
113-
else {
114-
printf("Connected to %s:%d\n", SDSIO_SOCKET_SERVER_IP, SDSIO_SOCKET_SERVER_PORT);
104+
ret = sdsRecPlayInit(rec_play_event_callback);
105+
106+
// Output a diagnostic message about initialization to the STDOUT channel
107+
switch (ret) {
108+
case SDS_REC_PLAY_OK:
109+
#if defined(RTE_SDS_IO_VSI)
110+
printf("SDS I/O VSI interface initialized successfully\n");
111+
#elif defined(RTE_SDS_IO_SOCKET)
112+
printf("Connection to SDSIO-Server at %s:%d established\n", SDSIO_SOCKET_SERVER_IP, SDSIO_SOCKET_SERVER_PORT);
113+
#elif defined(RTE_SDS_IO_USB)
114+
printf("Connection to SDSIO-Server established via USB interface\n");
115+
#elif defined(RTE_SDS_IO_SERIAL_CMSIS_USART)
116+
printf("Connection to SDSIO-Server established via USART interface\n");
117+
#elif defined(RTE_SDS_IO_CUSTOM)
118+
printf("Connection to SDSIO-Server established via custom interface\n");
119+
#elif defined(RTE_SDS_IO_FILE_SYSTEM_MDK_FS)
120+
printf("SDS I/O File System (MDK-FS) interface initialized successfully\n");
121+
#elif defined(RTE_SDS_IO_FILE_SYSTEM_SEMIHOSTING)
122+
printf("SDS I/O File System (SemiHosting) interface initialized successfully\n");
123+
#endif
124+
break;
125+
126+
case SDS_REC_PLAY_ERROR_IO:
127+
#if defined(RTE_SDS_IO_VSI)
128+
printf("SDS I/O VSI interface initialization failed!\n");
129+
#elif defined(RTE_SDS_IO_SOCKET)
130+
if (strcmp(SDSIO_SOCKET_SERVER_IP, "0.0.0.0") == 0) {
131+
printf("SDSIO_SOCKET_SERVER_IP address not configured (see sdsio_config_socket.h)!\n");
132+
} else {
133+
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);
134+
printf("Ensure that SDSIO-Server is running, then restart the application!\n");
135+
}
136+
#elif defined(RTE_SDS_IO_USB)
137+
printf("SDS I/O USB interface initialization failed or 'sdsio-server usb' unavailable!\n");
138+
printf("Ensure that SDSIO-Server is running, then restart the application!\n");
139+
#elif defined(RTE_SDS_IO_SERIAL_CMSIS_USART)
140+
printf("SDS I/O USART interface initialization failed or 'sdsio-server serial' unavailable!\n");
141+
printf("Ensure that SDSIO-Server is running, then restart the application!\n");
142+
#elif defined(RTE_SDS_IO_CUSTOM)
143+
printf("SDS I/O Custom interface initialization failed!\n");
144+
#elif defined(RTE_SDS_IO_FILE_SYSTEM_MDK_FS)
145+
printf("SDS I/O File System MDK-FS interface initialization failed!\n");
146+
#elif defined(RTE_SDS_IO_FILE_SYSTEM_SEMIHOSTING)
147+
printf("SDS I/O File System SemiHosting interface initialization failed!\n");
115148
#endif
149+
break;
150+
151+
case SDS_REC_PLAY_ERROR:
152+
printf("SDS initialization failed to create necessary threads or event flags!\n");
153+
break;
154+
155+
default:
156+
printf("SDS initialization failed with error code: %d\n", ret);
157+
break;
116158
}
117159

118160
// Create algorithm thread

Alif/DevKit/datatest/sds_control.c

Lines changed: 56 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919
#include <stdio.h>
2020
#include <stdbool.h>
2121
#include <string.h>
22+
#include "RTE_Components.h"
2223
#include "cmsis_os2.h"
2324
#include "cmsis_vio.h"
2425
#include "sds_main.h"
2526
#include "sds_control.h"
2627
#include "sds_rec_play.h"
27-
#ifndef SIMULATOR
28+
#ifdef RTE_SDS_IO_SOCKET
2829
#include "sdsio_config_socket.h"
2930
#endif
3031

@@ -92,27 +93,68 @@ __NO_RETURN void sdsControlThread (void *argument) {
9293
uint8_t led0_val = 0U;
9394
uint32_t no_load_cnt, prev_cnt;
9495
uint32_t interval_time, cnt = 0U;
96+
int32_t ret;
9597

9698
// Initialize idle counter
9799
idle_cnt = 0U;
98100
osDelay(10U);
99101
no_load_cnt = idle_cnt;
100102

101103
// Initialize SDS recorder/player
102-
if (sdsRecPlayInit(rec_play_event_callback) != SDS_REC_PLAY_OK) {
103-
printf("SDS initialization failed!\n");
104-
#ifndef SIMULATOR
105-
if (strcmp(SDSIO_SOCKET_SERVER_IP, "0.0.0.0") == 0) {
106-
printf("SDSIO_SOCKET_SERVER_IP address not configured (see sdsio_config_socket.h)\n");
107-
}
108-
else {
109-
printf("'sdsio-server socket' on %s:%d not responding.\n", SDSIO_SOCKET_SERVER_IP, SDSIO_SOCKET_SERVER_PORT);
110-
printf("Ensure that SDSIO Server is running and restart the application!\n");
111-
}
112-
}
113-
else {
114-
printf("Connected to %s:%d\n", SDSIO_SOCKET_SERVER_IP, SDSIO_SOCKET_SERVER_PORT);
104+
ret = sdsRecPlayInit(rec_play_event_callback);
105+
106+
// Output a diagnostic message about initialization to the STDOUT channel
107+
switch (ret) {
108+
case SDS_REC_PLAY_OK:
109+
#if defined(RTE_SDS_IO_VSI)
110+
printf("SDS I/O VSI interface initialized successfully\n");
111+
#elif defined(RTE_SDS_IO_SOCKET)
112+
printf("Connection to SDSIO-Server at %s:%d established\n", SDSIO_SOCKET_SERVER_IP, SDSIO_SOCKET_SERVER_PORT);
113+
#elif defined(RTE_SDS_IO_USB)
114+
printf("Connection to SDSIO-Server established via USB interface\n");
115+
#elif defined(RTE_SDS_IO_SERIAL_CMSIS_USART)
116+
printf("Connection to SDSIO-Server established via USART interface\n");
117+
#elif defined(RTE_SDS_IO_CUSTOM)
118+
printf("Connection to SDSIO-Server established via custom interface\n");
119+
#elif defined(RTE_SDS_IO_FILE_SYSTEM_MDK_FS)
120+
printf("SDS I/O File System (MDK-FS) interface initialized successfully\n");
121+
#elif defined(RTE_SDS_IO_FILE_SYSTEM_SEMIHOSTING)
122+
printf("SDS I/O File System (SemiHosting) interface initialized successfully\n");
123+
#endif
124+
break;
125+
126+
case SDS_REC_PLAY_ERROR_IO:
127+
#if defined(RTE_SDS_IO_VSI)
128+
printf("SDS I/O VSI interface initialization failed!\n");
129+
#elif defined(RTE_SDS_IO_SOCKET)
130+
if (strcmp(SDSIO_SOCKET_SERVER_IP, "0.0.0.0") == 0) {
131+
printf("SDSIO_SOCKET_SERVER_IP address not configured (see sdsio_config_socket.h)!\n");
132+
} else {
133+
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);
134+
printf("Ensure that SDSIO-Server is running, then restart the application!\n");
135+
}
136+
#elif defined(RTE_SDS_IO_USB)
137+
printf("SDS I/O USB interface initialization failed or 'sdsio-server usb' unavailable!\n");
138+
printf("Ensure that SDSIO-Server is running, then restart the application!\n");
139+
#elif defined(RTE_SDS_IO_SERIAL_CMSIS_USART)
140+
printf("SDS I/O USART interface initialization failed or 'sdsio-server serial' unavailable!\n");
141+
printf("Ensure that SDSIO-Server is running, then restart the application!\n");
142+
#elif defined(RTE_SDS_IO_CUSTOM)
143+
printf("SDS I/O Custom interface initialization failed!\n");
144+
#elif defined(RTE_SDS_IO_FILE_SYSTEM_MDK_FS)
145+
printf("SDS I/O File System MDK-FS interface initialization failed!\n");
146+
#elif defined(RTE_SDS_IO_FILE_SYSTEM_SEMIHOSTING)
147+
printf("SDS I/O File System SemiHosting interface initialization failed!\n");
115148
#endif
149+
break;
150+
151+
case SDS_REC_PLAY_ERROR:
152+
printf("SDS initialization failed to create necessary threads or event flags!\n");
153+
break;
154+
155+
default:
156+
printf("SDS initialization failed with error code: %d\n", ret);
157+
break;
116158
}
117159

118160
// Create algorithm thread

0 commit comments

Comments
 (0)