cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
ahmedkhazal
Observer
Observer
3,540 Views
Registered: ‎07-08-2017

zynq zc7020 lwip client_server

Jump to solution

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

0 Kudos
1 Solution

Accepted Solutions
savula
Moderator
Moderator
4,238 Views
Registered: ‎10-30-2017

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.

 

View solution in original post

0 Kudos
8 Replies
nanz
Moderator
Moderator
3,488 Views
Registered: ‎08-25-2009

Hi @ahmedkhazal,

 

Have you check xapp1026 application, in which the web server application is having the client computer.

 

Hope this helps.


-------------------------------------------------------------------------------------------

Don’t forget to reply, kudo, and accept as solution.

If starting with Versal take a look at our Versal Design Process Hub and our Versal Blogs and our Versal Ethernet Sticky Note.

-------------------------------------------------------------------------------------------
0 Kudos
ahmedkhazal
Observer
Observer
3,482 Views
Registered: ‎07-08-2017

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. 

0 Kudos
nanz
Moderator
Moderator
3,480 Views
Registered: ‎08-25-2009

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?


-------------------------------------------------------------------------------------------

Don’t forget to reply, kudo, and accept as solution.

If starting with Versal take a look at our Versal Design Process Hub and our Versal Blogs and our Versal Ethernet Sticky Note.

-------------------------------------------------------------------------------------------
0 Kudos
ahmedkhazal
Observer
Observer
3,471 Views
Registered: ‎07-08-2017

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 

0 Kudos
savula
Moderator
Moderator
3,466 Views
Registered: ‎10-30-2017

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

0 Kudos
ahmedkhazal
Observer
Observer
3,433 Views
Registered: ‎07-08-2017

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? 

0 Kudos
savula
Moderator
Moderator
4,239 Views
Registered: ‎10-30-2017

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.

 

View solution in original post

0 Kudos
ahmedkhazal
Observer
Observer
3,401 Views
Registered: ‎07-08-2017
thank you v. much for your help
regards
0 Kudos