0

我想使用我的 STM32F4 开发板使用 freeRTOS 实现一个网络项目。一开始。我使用 tcp/udp 回显服务器。这是我的代码

static struct netconn *conn;
static struct netbuf *buf;
static struct ip_addr *addr;
static unsigned short port;

   static void udpecho_thread(void *arg)
{
  err_t err;

  LWIP_UNUSED_ARG(arg);
  conn = netconn_new(NETCONN_UDP);
  if (conn!= NULL) {
    err = netconn_bind(conn, IP_ADDR_ANY, 7);
    if (err == ERR_OK) {
      while (1) {
        buf = netconn_recv(conn,&buf);

        if (buf!= NULL) {
          addr = netbuf_fromaddr(buf);
          port = netbuf_fromport(buf);
          netconn_connect(conn, addr, port);
          buf->addr = NULL;
          netconn_send(conn,buf);
          netbuf_delete(buf);
        }
      }
    } else {
      printf("can not bind netconn");
    }
  } else {
    printf("can create new UDP netconn");
  }
}

但是我在 buf = netconn_recv(conn,&buf) 和 buf->addr = NULL 上得到一个错误。它显示:

“err_t”类型的值不能分配给“struct netbuf *”类型的实体

在 buf->addr 上:

“int”类型的值不能分配给“ip_addr_t”类型的实体

我该如何解决?

4

0 回答 0