Skip to content

Commit cd12ec9

Browse files
DavidLesnjakRobertRostohar
authored andcommitted
SDS REC: Update driver
- Improve performance - Update configuration file
1 parent 04a7141 commit cd12ec9

File tree

3 files changed

+26
-29
lines changed

3 files changed

+26
-29
lines changed

ARM.SDS.pdsc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
SDS Player:
1414
- Improve performance
1515
- Update configuration file
16+
SDS Recorder:
17+
- Improve performance
18+
- Update configuration file
1619
SDSIO-Server:
1720
- Correct response handling for open and read commands
1821
- Remove automatic file open after .sds file index is reset in read mode
@@ -159,15 +162,15 @@
159162
</component>
160163

161164
<!-- SDS Recorder -->
162-
<component Cclass="SDS" Cgroup="Recorder" Cvariant="CMSIS-RTOS2" Cversion="1.0.0" condition="SDS Recorder with CMSIS-RTOS2">
165+
<component Cclass="SDS" Cgroup="Recorder" Cvariant="CMSIS-RTOS2" Cversion="2.0.0" condition="SDS Recorder with CMSIS-RTOS2">
163166
<description>Record to Output device</description>
164167
<RTE_Components_h>
165168
#define RTE_SDS_RECORDER /* Synchronous Data Stream Recorder */
166169
</RTE_Components_h>
167170
<files>
168171
<file category="header" name="sds/include/sds_rec.h"/>
169172
<file category="source" name="sds/source/sds_rec.c"/>
170-
<file category="header" name="sds/config/sds_rec_config.h" attr="config" version="1.0.0"/>
173+
<file category="header" name="sds/config/sds_rec_config.h" attr="config" version="2.0.0"/>
171174
</files>
172175
</component>
173176

sds/config/sds_rec_config.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023 Arm Limited. All rights reserved.
2+
* Copyright (c) 2023-2024 Arm Limited. All rights reserved.
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -17,7 +17,7 @@
1717
*
1818
* Name: sds_rec_config.h
1919
* Purpose: SDS Recorder configuration options
20-
* Rev.: V1.0.0
20+
* Rev.: V2.0.0
2121
*/
2222

2323
//-------- <<< Use Configuration Wizard in Context Menu >>> --------------------
@@ -26,11 +26,11 @@
2626

2727
// <o>Maximum number of recorder streams <1-31>
2828
// <i>Default: 16
29-
#define SDS_REC_MAX_STREAMS 16U
29+
#define SDS_REC_MAX_STREAMS 16U
3030

31-
// <o>Maximum size of a record
31+
// <o>Size of a temporary recorder buffer
3232
// <i>Default: 8192
33-
#define SDS_REC_MAX_RECORD_SIZE 8192U
33+
#define SDS_REC_BUF_SIZE 8192U
3434

3535
// </h>
3636

sds/source/sds_rec.c

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022-2023 Arm Limited. All rights reserved.
2+
* Copyright (c) 2022-2024 Arm Limited. All rights reserved.
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -41,8 +41,6 @@ typedef struct {
4141
uint32_t buf_size;
4242
sdsId_t stream;
4343
sdsioId_t sdsio;
44-
volatile uint32_t cnt_in;
45-
volatile uint32_t cnt_out;
4644
} sdsRec_t;
4745

4846
static sdsRec_t RecStreams[SDS_REC_MAX_STREAMS] = {0};
@@ -55,7 +53,7 @@ typedef struct {
5553
} RecHead_t;
5654

5755
// Record buffer
58-
static uint8_t RecBuf[SDS_REC_MAX_RECORD_SIZE];
56+
static uint8_t RecBuf[SDS_REC_BUF_SIZE];
5957

6058
// Event callback
6159
static sdsRecEvent_t sdsRecEvent = NULL;
@@ -149,7 +147,6 @@ static void sdsRecEventCallback (sdsId_t id, uint32_t event, void *arg) {
149147
// Recorder thread
150148
static __NO_RETURN void sdsRecThread (void *arg) {
151149
sdsRec_t *rec;
152-
RecHead_t rec_head;
153150
uint32_t flags, cnt, n;
154151

155152
(void)arg;
@@ -168,22 +165,22 @@ static __NO_RETURN void sdsRecThread (void *arg) {
168165
if ((rec->flags & SDS_REC_FLAG_CLOSE) != 0U) {
169166
continue;
170167
}
171-
while (rec->cnt_out != rec->cnt_in) {
172-
cnt = sdsRead(rec->stream, &rec_head, sizeof(RecHead_t));
173-
if (cnt == sizeof(RecHead_t)) {
174-
memcpy(RecBuf, &rec_head, sizeof(RecHead_t));
175-
cnt = sdsRead(rec->stream, RecBuf + sizeof(RecHead_t), rec_head.data_size);
176-
rec->cnt_out++;
177-
if (cnt == rec_head.data_size) {
178-
cnt += sizeof(RecHead_t);
179-
if (sdsioWrite(rec->sdsio, RecBuf, cnt) != cnt) {
180-
if (sdsRecEvent != NULL) {
181-
sdsRecEvent(rec, SDS_REC_EVENT_IO_ERROR);
182-
}
183-
}
168+
169+
cnt = sdsGetCount(rec->stream);
170+
while (cnt != 0U) {
171+
if (cnt > sizeof(RecBuf)) {
172+
cnt = sizeof(RecBuf);
173+
}
174+
sdsRead(rec->stream, RecBuf, cnt);
175+
if (sdsioWrite(rec->sdsio, RecBuf, cnt) != cnt) {
176+
if (sdsRecEvent != NULL) {
177+
sdsRecEvent(rec, SDS_REC_EVENT_IO_ERROR);
184178
}
179+
break;
185180
}
181+
cnt = sdsGetCount(rec->stream);
186182
}
183+
187184
if (rec->event_close != 0U) {
188185
rec->flags |= SDS_REC_FLAG_CLOSE;
189186
osEventFlagsSet(sdsRecCloseEventFlags, 1U << rec->index);
@@ -232,7 +229,7 @@ sdsRecId_t sdsRecOpen (const char *name, void *buf, uint32_t buf_size, uint32_t
232229
uint32_t index;
233230

234231
if ((name != NULL) && (buf != NULL) && (buf_size != 0U) &&
235-
(buf_size <= SDS_REC_MAX_RECORD_SIZE) && (io_threshold <= buf_size)) {
232+
(buf_size <= SDS_REC_BUF_SIZE) && (io_threshold <= buf_size)) {
236233

237234
rec = sdsRecAlloc(&index);
238235
if (rec != NULL) {
@@ -241,8 +238,6 @@ sdsRecId_t sdsRecOpen (const char *name, void *buf, uint32_t buf_size, uint32_t
241238
rec->event_close = 0U;
242239
rec->flags = 0U;
243240
rec->buf_size = buf_size;
244-
rec->cnt_in = 0U;
245-
rec->cnt_out = 0U;
246241
rec->stream = sdsOpen(buf, buf_size, 0U, io_threshold);
247242
rec->sdsio = sdsioOpen(name, sdsioModeWrite);
248243

@@ -300,7 +295,6 @@ uint32_t sdsRecWrite (sdsRecId_t id, uint32_t timestamp, const void *buf, uint32
300295
rec_head.data_size = buf_size;
301296
if (sdsWrite(rec->stream, &rec_head, sizeof(RecHead_t)) == sizeof(RecHead_t)) {
302297
num = sdsWrite(rec->stream, buf, buf_size);
303-
rec->cnt_in++;
304298
if (num == buf_size) {
305299
if (rec->event_threshold != 0U) {
306300
rec->event_threshold = 0U;

0 commit comments

Comments
 (0)