2 * Copyright (C) 2012-2019 Czech Technical University in Prague
4 * Created on: 25.3.2019
9 * Permission is hereby granted, free of charge, to any person
10 * obtaining a copy of this software and associated documentation
11 * files (the "Software"), to deal in the Software without
12 * restriction, including without limitation the rights to use,
13 * copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following
18 * The above copyright notice and this permission notice shall be
19 * included in all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 * OTHER DEALINGS IN THE SOFTWARE.
37 #include "cmd_iperf.h"
42 #include "cmdproc_freertos.h"
50 static err_t lwiperf_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err){
54 if (err == ERR_OK && p != NULL) {
55 tcp_recved(pcb, p->tot_len);
58 } else if (err != ERR_OK && p != NULL) {
63 if (err == ERR_OK && p == NULL) {
72 static err_t lwiperf_accept(void *arg, struct tcp_pcb *pcb, err_t err){
79 tcp_recv(pcb, lwiperf_recv);
86 int cmd_do_eth_lwiperf(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]){
89 if (!isPostInitialized()) {
90 rpp_sci_printf("Eth not initialized run 'ethinit' command first.\n");
99 tcp_bind(pcb, IP_ADDR_ANY, 5001); // bind to iperf port
100 pcb = tcp_listen(pcb);
101 tcp_accept(pcb, lwiperf_accept);
103 rpp_sci_printf("Iperf initialized \r\n");
113 cmd_des_t const cmd_des_ethiperf = {
115 "ethiperf","Command to test IP Bandwidth",
116 "### Command syntax ###\n"
120 "### Description ###\n"
121 "Command start iperf server on platform. To test internet bandwidth run iperf -c [board_IP] at testing computer."
126 "At testing computer\n"
127 " --> ethiperf -c 10.35.95.25\n",
128 CMD_HANDLER(cmd_do_eth_lwiperf), (void *)&cmd_list_iperf
131 /** List of commands for adc, defined as external */
132 cmd_des_t const *cmd_list_iperf[] = {