01-16-2018 02:58 PM
hi everyone please can anyone help me:
in my project, I want to receive data from Arduino client via ethernet based on lwip library, and then send the data to the pc also via lwip ethernet so the FPGA work as a server and Arduino work as a client. I'm trying to use the echo server to do that and I successfully received the data from Arduino but I couldn't send it to PC.
can anyone help me to modify the echo server to receive the data from a client and sent it to another different one?
thanks in advanced
01-23-2018 09:09 AM
no need to modify the start_application, just modify the accept_callback function. refer the attached echo.c file
Best Regards,
Srikanth
----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
01-19-2018 03:06 AM
Hi @ahmedkhazal,
Have you check xapp1026 application, in which the web server application is having the client computer.
Hope this helps.
01-19-2018 07:05 AM
dear as I think the web server example in this document send the data from pc to the fpga , but I need to send the data from fpga to pc.
01-19-2018 07:17 AM
In this application, there are a set of files stored in the memory of the development board. These files can be accessed by the PC when pointing to the IP address of the development board. Is this not what you are looking to do?
01-19-2018 09:10 AM
dear friend within the recv_callback in echo file I added the tcp_commend to send the data to my pc server
err_t recv_callback(void *arg, struct tcp_pcb *tpcb,
struct pbuf *p, err_t err)
{
//////////////////////////
int bufspace = 0;
struct ip_addr server;
err_t ret_val;
IP4_ADDR(&server, 192,168,1,6);
/////////////////////////
/* do not read the packet if we are not in ESTABLISHED state */
if (!p) {
tcp_close(tpcb);
tcp_recv(tpcb, NULL);
return ERR_OK;
}
/* indicate that the packet has been received */
tcp_recved(tpcb, p->len);
/* echo back the payload */
/* in this case, we assume that the payload is < TCP_SND_BUF */
if (tcp_sndbuf(tpcb) > p->len) {
err = tcp_write(tpcb, p->payload, p->len, 1);
}
//////////////////// code to sent data to pc server ////////////////////
tpcb = tcp_new(); // create tcp pcb
tcp_bind(tpcb, IP_ADDR_ANY, 7); //bind client port for outgoing connection
ret_val = tcp_connect(tpcb, &server, 77, NULL); //connect to the server
bufspace = tcp_sndbuf(tpcb); // get space which can be used to sent the data
tcp_write(tpcb, p->payload,p->len, 0);
while (ret_val == ERR_MEM);
tcp_output(tpcb);
tcp_sent(tpcb, NULL);
return ERR_OK;
}
what is my problem in this code, please
regards
01-19-2018 09:30 AM
Hi ahmedkazal,
are you running 2 client applications in your PC, one is to send the data and other is to receive the data?
if so then you need to understand one thing that the example code provided is to accept only one client and if any other client trying to connect then the first client connection lost. you need to modify this code in echo.c to accept the 2 clients at a time and keep the track of connected clients. check the accept call back function and modify it to accept 2 clients at a time.
then you will able to send the data to client which is received from the other client.
Best regards,
Srikanth
01-21-2018 10:43 AM
thank you for your information. do you main I have to modify the start_application() callback to accept the other client or I have to build second start_application() one for receiving and other for sending data?
01-23-2018 09:09 AM
no need to modify the start_application, just modify the accept_callback function. refer the attached echo.c file
Best Regards,
Srikanth
----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
01-24-2018 06:15 AM