1 /*******************************************************************************
\r
2 * Trace Recorder Library for Tracealyzer v3.0.2
\r
3 * Percepio AB, www.percepio.com
\r
7 * Trace TCP/IP configuration. Modify these includes and functions to perform
\r
8 * the same functionality using your specific TCP/IP stack.
\r
9 * Will only be included by trcTCPIP.c.
\r
12 * This software (the "Tracealyzer Recorder Library") is the intellectual
\r
13 * property of Percepio AB and may not be sold or in other ways commercially
\r
14 * redistributed without explicit written permission by Percepio AB.
\r
16 * Separate conditions applies for the SEGGER branded source code included.
\r
18 * The recorder library is free for use together with Percepio products.
\r
19 * You may distribute the recorder library in its original form, but public
\r
20 * distribution of modified versions require approval by Percepio AB.
\r
23 * The trace tool and recorder library is being delivered to you AS IS and
\r
24 * Percepio AB makes no warranty as to its use or performance. Percepio AB does
\r
25 * not and cannot warrant the performance or results you may obtain by using the
\r
26 * software or documentation. Percepio AB make no warranties, express or
\r
27 * implied, as to noninfringement of third party rights, merchantability, or
\r
28 * fitness for any particular purpose. In no event will Percepio AB, its
\r
29 * technology partners, or distributors be liable to you for any consequential,
\r
30 * incidental or special damages, including any lost profits or lost savings,
\r
31 * even if a representative of Percepio AB has been advised of the possibility
\r
32 * of such damages, or for any claim by any third party. Some jurisdictions do
\r
33 * not allow the exclusion or limitation of incidental, consequential or special
\r
34 * damages, or the exclusion of implied warranties or limitations on how long an
\r
35 * implied warranty may last, so the above limitations may not apply to you.
\r
37 * Tabs are used for indent in this file (1 tab = 4 spaces)
\r
39 * Copyright Percepio AB, 2015.
\r
41 ******************************************************************************/
\r
43 #ifndef TRC_TCPIP_CONFIG_H
\r
44 #define TRC_TCPIP_CONFIG_H
\r
50 /* TCP/IP includes*/
\r
53 #define TRC_TCPIP_PORT 12000
\r
55 socket* sock = NULL;
\r
56 socket* listenerSocket = NULL;
\r
58 int32_t trcSocketSend(void* data, int32_t size, int32_t* bytesWritten)
\r
64 error = socket_send(sock, data, size, (size_t*)bytesWritten, 0);
\r
71 return (int32_t)error;
\r
74 int32_t trcSocketReceive(void* data, int32_t size, int32_t* bytesRead)
\r
80 error = socket_receive(sock, data, size, (size_t*)bytesRead, SOCKET_WAIT_ALL);
\r
81 if (error != ERROR_NONE && error != ERROR_TIMEOUT) /* Timeout may be expected when there is no data */
\r
91 int32_t trcSocketInitializeListener()
\r
98 //Start of exception handling block
\r
101 listenerSocket = socket_open(SOCKET_STREAM, SOCKET_TCP);
\r
102 if(listenerSocket == NULL)
\r
108 error = socket_set_timeout(listenerSocket, INFINITE);
\r
111 error = socket_set_tx_buffer_size(listenerSocket, 1440 * 2);
\r
114 error = socket_set_rx_buffer_size(listenerSocket, 128);
\r
117 error = socket_bind_to_interface(listenerSocket, pNetInterface);
\r
120 error = socket_bind(listenerSocket, ADDR_ANY, TRC_TCPIP_PORT);
\r
123 error = socket_listen(listenerSocket);
\r
129 socket_close(listenerSocket);
\r
130 listenerSocket = NULL;
\r
136 int32_t trcSocketAccept()
\r
138 ip_addr clientIpAddr;
\r
139 uint16_t clientPort;
\r
144 if (listenerSocket == NULL)
\r
147 /* Wait for connection */
\r
148 sock = socket_accept(listenerSocket, &clientIpAddr, &clientPort);
\r
151 socket_set_timeout(sock, 20);
\r
163 #endif /*TRC_TCPIP_CONFIG_H*/