Hi,
I’m hoping someone can help me with a problem that has been causing me grief 
for a few days now!

I am writing an RTP audio system, that needs to send a packet of audio data 
every 4mS.  This is in a multi-thread RTOS environment, running on STM32F427, 
with initial code generated using ST’s “Cube” (wish I hadn’t!).  I have threads 
to handle NetBIOS and HTTP, but they are all disabled at the moment.

The problem I’m having is that after a variable length of time – sometimes 
immediately on start-up, sometimes after half an hour – the code stops working. 
 The central “netconn_send” returns with “ERR_USE”.  I have tried many 
variations with this code, all showing the same problem.  None of the other 
error warnings get activated, only the GPIO pins set to indicate the error.

Question 1: Why should send return with ERR_USE?  At present there is only one 
connection and it is only bound/connected once – outside the loop.  I get the 
same error with connection within the loop, or if I use sendto instead.

Question 2: Why does this supposedly non-fatal error cause all lower level LWIP 
functions to stop?  If I have the HTTP thread running (to show status/fault 
information) it also stops.

Question 3: Why does not SOF_REUSEADDR mask the error (SO_REUSE is enabled in 
lwipopts)?

Many thanks,
Mike.

void udp_test(void *arg)
{
  struct netconn *conn;
  struct netbuf *buf;
  char *data;
  err_t err;
  uint16_t index;
  size_t bufsize = 100;

  conn = netconn_new(NETCONN_UDP);
  if (conn == NULL) debugmessage("Could not create new netconn for UDP 
test<br>");
  if (conn != NULL)
  {
    ip_set_option(conn->pcb.udp, SOF_REUSEADDR);
  
    err = netconn_bind(conn, IP_ADDR_ANY, 5004);
    if (err != ERR_OK) debugmessage("Could not bind to port 5004 for RTP 
data<br>");

//    err = netconn_connect(conn, IP_ADDR_BROADCAST, 5004);
//    if (err != ERR_OK) debugmessage("Could not connect port 5004 to BROADCAST 
for RTP data<br>");
    
//    while(1)
    {
      buf = netbuf_new();
      if (buf == NULL) debugmessage("Could not create netbuf for UDP 
test<br>"); 
      if (buf != NULL)
      {
        data = netbuf_alloc(buf, bufsize);
        if (data == NULL) debugmessage("Could not allocate pointer to UDP test 
data in netbuf<br>"); 
        if (data != NULL)
        {
          while(1)
          {
            HAL_GPIO_WritePin(CONT6_GPIO_Port, CONT6_Pin, GPIO_PIN_SET);
            for (index = 0; index <bufsize; index++)
            {
              data[index] = index;
            }
//            err = netconn_send(conn, buf);
            err = netconn_sendto(conn, buf, IP_ADDR_BROADCAST, 5004);
            if (err == ERR_USE) HAL_GPIO_WritePin(CONT3_GPIO_Port, CONT3_Pin, 
GPIO_PIN_SET);
            if (err == ERR_MEM) HAL_GPIO_WritePin(CONT4_GPIO_Port, CONT4_Pin, 
GPIO_PIN_SET);
            if (err != ERR_OK) HAL_GPIO_WritePin(CONT5_GPIO_Port, CONT5_Pin, 
GPIO_PIN_SET);
            HAL_GPIO_WritePin(CONT6_GPIO_Port, CONT6_Pin, GPIO_PIN_RESET);
            osDelay(4);
          }
          netbuf_delete(buf);
        }
      }
//      osDelay(4);
    }
  }
}
Sent from Mail for Windows 10

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

Reply via email to