@@ -31,9 +31,6 @@ namespace
31
31
static const int SIGIO_TIMEOUT = 5000 ; // [ms]
32
32
33
33
static const int BUFF_SIZE = 1200 ;
34
- char rx_buffer[BUFF_SIZE] = {0 };
35
- char tx_buffer[BUFF_SIZE] = {0 };
36
-
37
34
static const int PKTS = 22 ;
38
35
static const int pkt_sizes[PKTS] = {1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 , \
39
36
100 ,200 ,300 ,400 ,500 ,600 ,700 ,800 ,900 ,1000 ,\
@@ -54,24 +51,24 @@ void TCPSOCKET_ECHOTEST()
54
51
int sent;
55
52
int x = 0 ;
56
53
for (int pkt_s = pkt_sizes[x]; x < PKTS; pkt_s = pkt_sizes[x++]) {
57
- fill_tx_buffer_ascii (tx_buffer, BUFF_SIZE);
54
+ fill_tx_buffer_ascii (tcp_global:: tx_buffer, BUFF_SIZE);
58
55
59
- sent = sock.send (tx_buffer, pkt_s);
56
+ sent = sock.send (tcp_global:: tx_buffer, pkt_s);
60
57
if (sent < 0 ) {
61
58
printf (" [Round#%02d] network error %d\n " , x, sent);
62
59
TEST_FAIL ();
63
60
}
64
61
65
62
int bytes2recv = sent;
66
63
while (bytes2recv) {
67
- recvd = sock.recv (&(rx_buffer[sent-bytes2recv]), bytes2recv);
64
+ recvd = sock.recv (&(tcp_global:: rx_buffer[sent-bytes2recv]), bytes2recv);
68
65
if (recvd < 0 ) {
69
66
printf (" [Round#%02d] network error %d\n " , x, recvd);
70
67
TEST_FAIL ();
71
68
}
72
69
bytes2recv -= recvd;
73
70
}
74
- TEST_ASSERT_EQUAL (0 , memcmp (tx_buffer, rx_buffer, sent));
71
+ TEST_ASSERT_EQUAL (0 , memcmp (tcp_global:: tx_buffer, tcp_global:: rx_buffer, sent));
75
72
}
76
73
TEST_ASSERT_EQUAL (NSAPI_ERROR_OK, sock.close ());
77
74
}
@@ -81,7 +78,7 @@ void tcpsocket_echotest_nonblock_receiver(void *receive_bytes)
81
78
int bytes2recv = *(int *)receive_bytes;
82
79
int recvd;
83
80
while (bytes2recv) {
84
- recvd = sock.recv (&(rx_buffer[*(int *)receive_bytes-bytes2recv]), bytes2recv);
81
+ recvd = sock.recv (&(tcp_global:: rx_buffer[*(int *)receive_bytes-bytes2recv]), bytes2recv);
85
82
if (recvd == NSAPI_ERROR_WOULD_BLOCK) {
86
83
wait (1 );
87
84
continue ;
@@ -91,7 +88,7 @@ void tcpsocket_echotest_nonblock_receiver(void *receive_bytes)
91
88
bytes2recv -= recvd;
92
89
}
93
90
94
- TEST_ASSERT_EQUAL (0 , memcmp (tx_buffer, rx_buffer, *(int *)receive_bytes));
91
+ TEST_ASSERT_EQUAL (0 , memcmp (tcp_global:: tx_buffer, tcp_global:: rx_buffer, *(int *)receive_bytes));
95
92
96
93
static int round = 0 ;
97
94
printf (" [Recevr#%02d] bytes received: %d\n " , round++, *(int *)receive_bytes);
@@ -110,22 +107,22 @@ void TCPSOCKET_ECHOTEST_NONBLOCK()
110
107
int sent;
111
108
int s_idx = 0 ;
112
109
Thread *thread;
113
- unsigned char *stack_mem = (unsigned char *)malloc (OS_STACK_SIZE );
110
+ unsigned char *stack_mem = (unsigned char *)malloc (tcp_global::TCP_OS_STACK_SIZE );
114
111
TEST_ASSERT_NOT_NULL (stack_mem);
115
112
116
113
for (int pkt_s = pkt_sizes[s_idx]; s_idx < PKTS; ++s_idx) {
117
114
pkt_s = pkt_sizes[s_idx];
118
115
thread = new Thread (osPriorityNormal,
119
- OS_STACK_SIZE ,
116
+ tcp_global::TCP_OS_STACK_SIZE ,
120
117
stack_mem,
121
118
" receiver" );
122
119
TEST_ASSERT_EQUAL (osOK, thread->start (callback (tcpsocket_echotest_nonblock_receiver, &pkt_s)));
123
120
124
- fill_tx_buffer_ascii (tx_buffer, pkt_s);
121
+ fill_tx_buffer_ascii (tcp_global:: tx_buffer, pkt_s);
125
122
126
123
bytes2send = pkt_s;
127
124
while (bytes2send > 0 ) {
128
- sent = sock.send (&(tx_buffer[pkt_s-bytes2send]), bytes2send);
125
+ sent = sock.send (&(tcp_global:: tx_buffer[pkt_s-bytes2send]), bytes2send);
129
126
if (sent == NSAPI_ERROR_WOULD_BLOCK) {
130
127
TEST_ASSERT_NOT_EQUAL (osEventTimeout, osSignalWait (SIGNAL_SIGIO, SIGIO_TIMEOUT).status );
131
128
continue ;
0 commit comments