You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/theory.md
+55-68Lines changed: 55 additions & 68 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,42 +19,57 @@ The core of the SDS-Framework is a circular buffer handling (`sds.c/h`) that is
19
19
20
20
## Usage
21
21
22
-
The following diagram shows the usage of the SDS Recorder and Player functions. Management is a separate thread that controls the overall execution. Algorithm is a thread that executes Signal Conditioning (SC) and ML Model.
22
+
The following diagram shows the usage of the SDS Recorder and Player functions (executed in `sdsRecPlayThread`). The `sdsControlThread`controls the overall execution. `AlgorithmThread` is the thread that executes Signal Conditioning (SC) and ML Model.
Each data stream is stored in a separate SDS data file. In the diagram below `SCinput.0.sds` is the input to Signal Conditioning, `SCoutput.0.sds` is the output of Signal Conditioning, and `MLoutput.0.sds` is the output of the ML Model. Each execution of the algorithm is represented in a data block with a `timestamp`. The `timestamp` allows to correlate the blocks of different streams. In the above example, all blocks of one algorithm execution have the same timestamp value.
50
51
51
52

52
53
53
-
ToDo When does sdsRecInit require an event handler?
54
+
### Timestamp
54
55
55
-
**Example:** Recording of an accelerometer data stream
56
+
The timestamp is a 32-bit unsigned value and is used for:
56
57
57
-
The following code snippets show the usage of the **Recorder Interface**.
58
+
- Alignment of different data streams that have the same timestamp value.
59
+
- Order of the SDS data files captured during execution.
60
+
- Combining multiple SDS file records with the same timestamp value.
61
+
62
+
The same timestamp connects different SDS file records. It is therefore useful to
63
+
use the same timestamp for the recording of one iteration of a DSP or ML algorithm.
64
+
In most cases the granularity of an RTOS tick (typically 1ms) is a good choice for a timestamp value.
65
+
66
+
### SDS Data File Format
67
+
68
+
The SDS data file format is described [here](https://github.com/ARM-software/SDS-Framework/tree/main/schema). Each call to `sdsRecWrite` writes one data block.
69
+
70
+
## Code Example
71
+
72
+
The following code snippets show the usage of the **Recorder Interface**. In this case an accelerometer data stream is recorded.
58
73
59
74
```c
60
75
// *** variable definitions ***
@@ -65,7 +80,7 @@ struct { // sensor data stream format
65
80
} accelerometer [30]; // number of samples in one data stream record
66
81
67
82
sdsRecId_t *accel_id, // data stream id
68
-
uint8_t accel_buf[1000]; // data stream buffer for circular buffer handling
83
+
uint8_t accel_buf[(sizeof(accel_buf)*2)+0x800];// data stream buffer for circular buffer handling
69
84
:
70
85
// *** function calls ***
71
86
sdsRecInit(NULL); // init SDS Recorder
@@ -91,38 +106,7 @@ The size of the data stream buffer depends on several factors such as:
91
106
- the size of the data stream as it is recommended that the buffer is at least three the size of a single data stream.
92
107
- the frequency of the algorithm execution. Fast execution speeds may require a larger buffer.
93
108
94
-
A a guideline, the buffer size should be 3 times the **block size**. As a minimum 0x1000 (4 KB) is recommended.
95
-
96
-
ToDo: Threshold should be optional
97
-
98
-
**Recommended Buffer Size:**
99
-
100
-
The table below contains recommended buffer sizes depending on the communication technology used:
101
-
102
-
ToDo
103
-
104
-
Communication | Buffer Size | Description
105
-
:--------------|:------------|:----------------
106
-
Network | 4096 | Default size of Ethernet record is xxxx bytes
107
-
USB Device | xxx | .
108
-
FileSystem | xxx | .
109
-
110
-
## Timestamp
111
-
112
-
The timestamp is a 32-bit unsigned value and is used for:
113
-
114
-
- Alignment of different data streams that have the same timestamp value.
115
-
- Order of the SDS data files captured during execution.
116
-
- Combining multiple SDS file records with the same timestamp value.
117
-
118
-
The same timestamp connects different SDS file records. It is therefore useful to
119
-
use the same timestamp for the recording of one iteration of a DSP or ML algorithm.
120
-
In most cases the granularity of an RTOS tick (typically 1ms) is a good choice for a timestamp value.
121
-
122
-
## SDS File Format
123
-
124
-
The SDS file format is described [here](https://github.com/ARM-software/SDS-Framework/tree/main/schema). Each call to
125
-
`sdsRecWrite` writes one data block.
109
+
A a guideline, the buffer size should be 2 times the **block size** + 2KB. As a minimum 0x1000 (4 KB) is recommended.
126
110
127
111
## SDSIO Server Protocol
128
112
@@ -238,24 +222,26 @@ ToDo: I don't understand why this command is needed as **SDSIO_CMD_READ** return
238
222
This is the message sequence of the SDS DataTest example when connected to MDK-Middleware Ethernet.
239
223
It contains the following threads that executes on the target.
240
224
241
-
-Management: Overall execution management
225
+
-Control: Overall execution Control
242
226
- Algorithm: Algorithm under test
243
227
- Recorder: SDS Recorder thread (sdsRecThread)
244
228
- Playback: SDS Playback thread (sdsPlayThread)
245
229
246
230
The Server is the SDSIO Server executing on the target system.
247
231
232
+
ToDo rework this diagram
233
+
248
234
```mermaid
249
235
sequenceDiagram
250
-
participant Management
236
+
participant Control
251
237
participant Algorithm
252
238
create participant Recorder as SDS Recorder
253
239
participant Server as SDSIO Server
254
-
Management->>Recorder: sdsRecInit
255
-
Note over Management: sdsRecOpen
256
-
Management->>Server: SDSIO_CMD_OPEN
240
+
Control->>Recorder: sdsRecInit
241
+
Note over Control: sdsRecOpen
242
+
Control->>Server: SDSIO_CMD_OPEN
257
243
activate Server
258
-
Server-->>Management: Response
244
+
Server-->>Control: Response
259
245
activate Algorithm
260
246
loop periodic
261
247
Note over Algorithm: sdsRecWrite
@@ -265,13 +251,13 @@ sequenceDiagram
265
251
end
266
252
end
267
253
deactivate Algorithm
268
-
Note over Management: sdsRecClose
269
-
Management->>Recorder: Close Trigger
254
+
Note over Control: sdsRecClose
255
+
Control->>Recorder: Close Trigger
270
256
loop send all data
271
257
Recorder->>Server: SDSIO_CMD_WRITE
272
258
end
273
-
Recorder->>Management: Close Confirm
274
-
Management->>Server: SDSIO_CMD_CLOSE
259
+
Recorder->>Control: Close Confirm
260
+
Control->>Server: SDSIO_CMD_CLOSE
275
261
deactivate Server
276
262
```
277
263
@@ -293,8 +279,9 @@ but sds_rec.c does not really use this information
293
279
294
280
- Threshold event is only set when complete write was possible, is this correct? https://github.com/ARM-software/SDS-Framework/blob/main/sds/source/sds_rec.c#L298
0 commit comments