Percepio Trace Recorder v4.8.0.hotfix1
Loading...
Searching...
No Matches
trcStreamPort.h
1/*
2 * Trace Recorder for Tracealyzer v4.8.0.hotfix1
3 * Copyright 2023 Percepio AB
4 * www.percepio.com
5 *
6 * SPDX-License-Identifier: Apache-2.0
7 *
8 * The interface definitions for trace streaming ("stream ports").
9 * This "stream port" sets up the recorder to use TCP/IP as streaming channel.
10 * The example is for Windows sockets (Winsock), for use with Windows ports.
11 */
12
13#ifndef TRC_STREAM_PORT_H
14#define TRC_STREAM_PORT_H
15
16#if (TRC_USE_TRACEALYZER_RECORDER == 1)
17
18#if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
19
20#include <stdint.h>
21#include <trcTypes.h>
22#include <trcStreamPortConfig.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28#define TRC_ALIGNED_STREAM_PORT_BUFFER_SIZE ((((TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_SIZE) + sizeof(TraceUnsignedBaseType_t) - 1) / sizeof(TraceUnsignedBaseType_t)) * sizeof(TraceUnsignedBaseType_t))
29
30#define TRC_USE_INTERNAL_BUFFER (TRC_CFG_STREAM_PORT_USE_INTERNAL_BUFFER)
31
32#define TRC_INTERNAL_EVENT_BUFFER_WRITE_MODE (TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_WRITE_MODE)
33
34#define TRC_INTERNAL_EVENT_BUFFER_TRANSFER_MODE (TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_TRANSFER_MODE)
35
36#define TRC_INTERNAL_BUFFER_CHUNK_SIZE (TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_CHUNK_SIZE)
37
38#define TRC_INTERNAL_BUFFER_CHUNK_TRANSFER_AGAIN_SIZE_LIMIT (TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_CHUNK_TRANSFER_AGAIN_SIZE_LIMIT)
39
40#define TRC_INTERNAL_BUFFER_CHUNK_TRANSFER_AGAIN_COUNT_LIMIT (TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_CHUNK_TRANSFER_AGAIN_COUNT_LIMIT)
41
42typedef struct TraceStreamPortBuffer /* Aligned */
43{
44#if (TRC_USE_INTERNAL_BUFFER)
45 uint8_t buffer[(TRC_ALIGNED_STREAM_PORT_BUFFER_SIZE)];
46#else
47 TraceUnsignedBaseType_t buffer[1];
48#endif
50
51int32_t prvTraceWriteToSocket(void* data, uint32_t size, int32_t* ptrBytesWritten);
52int32_t prvTraceReadFromSocket(void* data, uint32_t bufsize, int32_t* ptrBytesRead);
53
54traceResult xTraceStreamPortInitialize(TraceStreamPortBuffer_t* pxBuffer);
55
65#if (TRC_USE_INTERNAL_BUFFER == 1)
66 #if (TRC_INTERNAL_EVENT_BUFFER_WRITE_MODE == TRC_INTERNAL_EVENT_BUFFER_OPTION_WRITE_MODE_COPY)
67 #define xTraceStreamPortAllocate(uiSize, ppvData) ((void)(uiSize), xTraceStaticBufferGet(ppvData))
68 #else
69 #define xTraceStreamPortAllocate(uiSize, ppvData) ((void)(uiSize), xTraceInternalEventBufferAlloc(uiSize, ppvData))
70 #endif
71#else
72 #define xTraceStreamPortAllocate(uiSize, ppvData) ((void)(uiSize), xTraceStaticBufferGet(ppvData))
73#endif
74
87#if (TRC_USE_INTERNAL_BUFFER == 1)
88 #if (TRC_INTERNAL_EVENT_BUFFER_WRITE_MODE == TRC_INTERNAL_EVENT_BUFFER_OPTION_WRITE_MODE_COPY)
89 #define xTraceStreamPortCommit xTraceInternalEventBufferPush
90 #else
91 #define xTraceStreamPortCommit xTraceInternalEventBufferAllocCommit
92 #endif
93#else
94 #define xTraceStreamPortCommit xTraceStreamPortWriteData
95#endif
96
97#define xTraceStreamPortWriteData(pvData, uiSize, piBytesWritten) (prvTraceWriteToSocket(pvData, uiSize, piBytesWritten) == 0 ? TRC_SUCCESS : TRC_FAIL)
98
99#define xTraceStreamPortReadData(pvData, uiSize, piBytesRead) (prvTraceReadFromSocket(pvData, uiSize, piBytesRead) == 0 ? TRC_SUCCESS : TRC_FAIL)
100
101#define xTraceStreamPortOnEnable(uiStartOption) ((void)(uiStartOption), TRC_SUCCESS)
102
103#define xTraceStreamPortOnDisable() (TRC_SUCCESS)
104
105#define xTraceStreamPortOnTraceBegin() (TRC_SUCCESS)
106
107traceResult xTraceStreamPortOnTraceEnd(void);
108
109#ifdef __cplusplus
110}
111#endif
112
113#endif /*(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)*/
114
115#endif /*(TRC_USE_TRACEALYZER_RECORDER == 1)*/
116
117#endif /* TRC_STREAM_PORT_H */
A structure representing the trace stream port buffer.
Definition: trcStreamPort.h:93