cancel
Showing results for 
Search instead for 
Did you mean: 

lwip tcp server problem solution please

ark2
Associate III

I made this sauce to implement lwip tcp server

If you try to remove the st-link wire and do it without debugging, the server itself doesn't work

I try to find a way, but I don't know where the problem is

If the LED on the board blinks, it means it's down

Is there a problem with why the server is not working?

If you turn it to debugging, you receive it without any problems, generate a message, and then send it

Then isn't there a problem with the sauce?

If the connection itself is not working when there is no debugging, I don't think the server is created

But if it's a circuit problem, I think it's weird to be a server when you debug it

I don't know where to look

When debugging, the client sent and received properly when it connected to the client from hercules or Raspberry Pi

void Tcp_Task(void const * argument)
 
{
 
  /* USER CODE BEGIN Tcp_Task */
 
  
 
  struct netconn *conn, *newconn;
 
  err_t err, accept_err;
 
  struct netbuf *buf;
 
  void *data;
 
  u16_t len;
 
  
 
  LWIP_UNUSED_ARG(argument);
 
  
 
  conn = netconn_new(NETCONN_TCP);
 
  
 
  if (conn!=NULL)
 
  {  
 
    // netconn_bind(conn, NULL, port 번호)
 
    err = netconn_bind(conn, NULL, 5001);
 
    
 
    if (err == ERR_OK)
 
    {
 
      netconn_listen(conn);
 
      
 
      while (1) 
 
      {
 
        accept_err = netconn_accept(conn, &newconn);
 
    
 
        if (accept_err == ERR_OK) 
 
        {
 
          while (netconn_recv(newconn, &buf) == ERR_OK) 
 
          {
 
            do 
 
            {
 
              netbuf_data(buf, &data, &len);
 
              memcpy(receivemsg, data, len);
 
              
 
              // 송신 메시지 �?성
 
              transmitmsg = procPacket();
 
              
 
              // 메시지 길�?�를 불러오는 함수
 
              msg_len = getsendPackSize();
 
              
 
              // 메시지 송신
 
              netconn_write(newconn, transmitmsg, msg_len, NETCONN_COPY);
 
              
 
            } 
 
            while (netbuf_next(buf) >= 0);
 
            
 
            netbuf_delete(buf);
 
          }
 
          netconn_close(newconn);
 
          netconn_delete(newconn);
 
        }
 
       
 
       osDelay(100);
 
      }
 
    }
 
    else
 
    {
 
      netconn_delete(newconn);
 
    }
 
  }
 
 
 
  
 
  /* Infinite loop */
 
    for(;;)
 
    {
 
      osDelay(100);
 
    }
 
  /* USER CODE END Tcp_Task */
 
}

0 REPLIES 0