Incomprehensible behavior with the LWIP library on STM32

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Incomprehensible behavior with the LWIP library on STM32

MrFord
Recently I switched to STM32F767ZI using LAN8742A and the LWIP library. Began
to develop a web configurator based on this STM. And there is such a
problem. <http://lwip.100.n7.nabble.com/file/t2256/LWIP_problem1.png>
where 192.168.97.200 is a device, 192.168.97.1 is a client (computer).

During data transfer to get, the request goes to a packet with the SYN flag,
after which the device does not transmit data, does not respond to ping.

The code is presented below.

char *buf;
 
struct http_state
{
  char *file;
  u32_t left;
};
 
static void
conn_err(void *arg, err_t err)
{
  struct http_state *hs;
 
  hs = arg;
  mem_free(hs);
}
/*-----------------------------------------------------------------------------------*/
static void
close_conn(struct tcp_pcb *pcb, struct http_state *hs)
{
 
  tcp_arg(pcb, NULL);
  tcp_sent(pcb, NULL);
  tcp_recv(pcb, NULL);
  mem_free(hs);
  tcp_close(pcb);
}
/*-----------------------------------------------------------------------------------*/
static void
send_data(struct tcp_pcb *pcb, struct http_state *hs)
{
  err_t err;
  u16_t len;
 
  /* We cannot send more data than space avaliable in the send
     buffer. */
  if (tcp_sndbuf(pcb) < hs->left)
  {
    len = tcp_sndbuf(pcb);
  }
  else
  {
    len = hs->left;
  }
 
  err = tcp_write(pcb, hs->file, len, 0);
 
  if (err == ERR_OK)
  {
    hs->file += len;
    hs->left -= len;
  }
}
 
/*-----------------------------------------------------------------------------------*/
static err_t
http_poll(void *arg, struct tcp_pcb *pcb)
{
  if (arg == NULL)
  {
    /*    printf("Null, close\n");*/
    tcp_close(pcb);
  }
  else
  {
    send_data(pcb, (struct http_state *)arg);
  }
 
  return ERR_OK;
}
/*-----------------------------------------------------------------------------------*/
static err_t
http_sent(void *arg, struct tcp_pcb *pcb, u16_t len)
{
  struct http_state *hs;
 
  hs = arg;
 
  if (hs->left > 0)
  {
    send_data(pcb, hs);
  }
  else
  {
    close_conn(pcb, hs);
  }
 
  return ERR_OK;
}
static err_t
http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
{
  int i, j;
  char *buf;
  struct http_state *hs;
 
  hs = arg;
 
  if (err == ERR_OK && p != NULL)
  {
 
    /* Inform TCP that we have taken the data. */
    tcp_recved(pcb, p->tot_len);
    if (hs->file == NULL)
    {
       //handler
    }
else
    {
      pbuf_free(p);
    }
  }
  return ERR_OK;
}
static err_t
http_accept(void *arg, struct tcp_pcb *pcb, err_t err)
{
  struct http_state *hs;
 
  /* Allocate memory for the structure that holds the state of the
     connection. */
  hs = mem_malloc(sizeof(struct http_state));
 
  if (hs == NULL)
  {
    return ERR_MEM;
  }
 
  /* Initialize the structure. */
  hs->file = NULL;
  hs->left = 0;
 
  /* Tell TCP that this is the structure we wish to be passed for our
     callbacks. */
  tcp_arg(pcb, hs);
 
  /* Tell TCP that we wish to be informed of incoming data by a call
     to the http_recv() function. */
  tcp_recv(pcb, http_recv);
 
  tcp_err(pcb, conn_err);
 
  tcp_poll(pcb, http_poll, 10);
  return ERR_OK;
}
/*-----------------------------------------------------------------------------------*/
void
httpd_init1(void)
{
  struct tcp_pcb *pcb;
 
  pcb = tcp_new();
  tcp_bind(pcb, IP_ADDR_ANY, 80);
  pcb = tcp_listen(pcb);
  tcp_accept(pcb, http_accept);
}
Who knows what the problem is? Thank you in advance. (I want to add that I'm
doing a multiplayer web configurator.)




--
Sent from: http://lwip.100.n7.nabble.com/lwip-users-f3.html

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Incomprehensible behavior with the LWIP library on STM32

goldsimon@gmx.de
Am 24.06.2019 um 15:18 schrieb MrFord:
> Recently I switched to STM32F767ZI using LAN8742A and the LWIP library. Began
> to develop a web configurator based on this STM. And there is such a
> problem. <http://lwip.100.n7.nabble.com/file/t2256/LWIP_problem1.png>
> where 192.168.97.200 is a device, 192.168.97.1 is a client (computer).

A picture is your problem? I think I should change the subject of this
mail to 'incomprehensible mail' :-)

Ok, seriously, I don't see what exactly the problem is.

I don't know how often this has been written here:
- post pcaps, not images
- describe what you think you monitored and what you think the problem
is, by referencing packets in the pcap.

I won't try to look at the image again...

Regards,
Simon

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Incomprehensible behavior with the LWIP library on STM32

MrFord
This post was updated on .
goldsimon@gmx.de - here is the file you requested. All problems start with
package № 1467Problem_LWIP.pcapng. After that, the device does not respond to the ping and tcp
connection.



--
Sent from: http://lwip.100.n7.nabble.com/lwip-users-f3.html

_______________________________________________
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Incomprehensible behavior with the LWIP library on STM32

MrFord
Please! Solve this problem. Thank!



--
Sent from: http://lwip.100.n7.nabble.com/lwip-users-f3.html

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Incomprehensible behavior with the LWIP library on STM32

MrFord
This post was updated on .
This is another file.  LWIP_problem1.pcapng
<http://lwip.100.n7.nabble.com/file/t2256/LWIP_problem1.pcapng
And I would like to add that this library does not respond to other packets during data transfer except for an empty packet with the ACK flag. I ask the developers of this library to solve this problem.


--
Sent from: http://lwip.100.n7.nabble.com/lwip-users-f3.html

_______________________________________________
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Incomprehensible behavior with the LWIP library on STM32

MrFord
Dear developers of the LWIP library !!! After some time, your library does
not listen to incoming data in the tcpip.c file, the tcpip_thread ()
routine. msg-> type all the time remains in the same state
(TCPIP_MSG_CALLBACK) and does not fall into TCPIP_MSG_INPKT. Please fix this
bug.



--
Sent from: http://lwip.100.n7.nabble.com/lwip-users-f3.html

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users