Skip to content

Commit 22cdd95

Browse files
authored
Updated socket-stats.log (#46)
1 parent fb57b48 commit 22cdd95

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

main.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,11 @@ EventFlags threadFlag;
2828

2929
void print_socket_stats()
3030
{
31-
mbed_stats_socket_t stats[MBED_CONF_NSAPI_SOCKET_STATS_MAX_COUNT];
32-
static int iteration = 0;
33-
int count;
31+
mbed_stats_socket_t stats[MBED_CONF_NSAPI_SOCKET_STATS_MAX_COUNT] = {0};
32+
int iteration = 0;
3433

35-
memset(&stats[0], 0, sizeof(mbed_stats_socket_t) * MBED_CONF_NSAPI_SOCKET_STATS_MAX_COUNT);
3634
while (COMPLETED_FLAG != threadFlag.get()) {
37-
count = SocketStats::mbed_stats_socket_get_each(&stats[0], MBED_CONF_NSAPI_SOCKET_STATS_MAX_COUNT);
35+
int count = SocketStats::mbed_stats_socket_get_each(&stats[0], MBED_CONF_NSAPI_SOCKET_STATS_MAX_COUNT);
3836
for (int i = 0; i < count; i++) {
3937
stdio_mutex.lock();
4038
printf("Iteration: %d ", iteration);
@@ -170,10 +168,13 @@ int main()
170168

171169
// Close the socket to return its memory and bring down the network interface
172170
socket.close();
173-
174171
// Bring down the ethernet interface
175172
net->disconnect();
173+
ThisThread::sleep_for(SAMPLE_TIME_MS);
174+
176175
threadFlag.set(COMPLETED_FLAG);
177176
thread->join();
178177
delete thread;
178+
179+
printf("End of Mbed OS Socket statistics example\n");
179180
}

tests/socket-stats.log

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
11
Mbed OS Socket statistics example
2-
Mbed OS version:
3-
42
IP address: (?:[0-9]{1,3}\.){3}[0-9]{1,3}
53
Netmask: (?:[0-9]{1,3}\.){3}[0-9]{1,3}
64
Gateway: (?:[0-9]{1,3}\.){3}[0-9]{1,3}
7-
Num: \d+ ID: (0x)?[0-9a-fA-F]+ State: Open Proto: TCP Sent: \d+ Recv: \d+ Time: \d+
8-
Num: \d+ ID: (0x)?[0-9a-fA-F]+ State: Closed Proto: UDP Sent: \d+ Recv: \d+ Time: \d+
9-
sent \d+ \[GET \/ HTTP\/\d.\d\]
10-
Num: \d+ ID: (0x)?[0-9a-fA-F]+ State: Connected Proto: TCP Sent: \d+ Recv: \d+ Time: \d+
11-
Num: \d+ ID: (0x)?[0-9a-fA-F]+ State: Closed Proto: UDP Sent: \d+ Recv: \d+ Time: \d+
12-
recv \d+ \[HTTP\/\d.\d \d+ OK\]
13-
Num: \d+ ID: (0x)?[0-9a-fA-F]+ State: Connected Proto: TCP Sent: \d+ Recv: \d+ Time: \d+
14-
Num: \d+ ID: (0x)?[0-9a-fA-F]+ State: Closed Proto: UDP Sent: \d+ Recv: \d+ Time: \d+
15-
External IP address: (?:[0-9]{1,3}\.){3}[0-9]{1,3}
16-
Num: \d+ ID: (0x)?[0-9a-fA-F]+ State: Connected Proto: TCP Sent: \d+ Recv: \d+ Time: \d+
17-
Num: \d+ ID: (0x)?[0-9a-fA-F]+ State: Closed Proto: UDP Sent: \d+ Recv: \d+ Time: \d+
18-
Done
5+
6+
Iteration: \d+ ID: (0x)?[0-9a-fA-F]+ State: Open Proto: TCP Sent: \d+ Recv: \d+ Time: \d+
7+
Iteration: \d+ ID: (0x)?[0-9a-fA-F]+ State: Closed Proto: UDP Sent: \d+ Recv: \d+ Time: \d+
8+
Iteration: \d+ ID: (0x)?[0-9a-fA-F]+ State: Connected Proto: TCP Sent: \d+ Recv: \d+ Time: \d+
9+
Iteration: \d+ ID: (0x)?[0-9a-fA-F]+ State: Closed Proto: UDP Sent: \d+ Recv: \d+ Time: \d+
10+
End of Mbed OS Socket statistics example

0 commit comments

Comments
 (0)