新手上路
- 积分
- 20
- 金钱
- 20
- 注册时间
- 2021-11-28
- 在线时间
- 4 小时
|
1金钱
使用STM32H723做以太网功能时,,移植LWIP,调用NETCONN API,单片机做服务端,通过网络调试助手与单片机做数据回环测试时发现,在50H在,大于100字节的情况下,会导致单片机以太网宕机。请问有做过类似功能的朋友能分享一下要如何实现么?测试代码如下:- void tcpechp_thread(void *arg) {
- struct netconn *conn, *newconn;
- err_t err;
- LWIP_UNUSED_ARG(arg);
- /* 创建服务器 */
- conn = netconn_new(NETCONN_TCP);
- netconn_bind(conn, IP_ADDR_ANY, PORT_NUM);
- /* 设置监听 */
- netconn_listen(conn);
- while (1) {
- // printf("go to this netconn\n");
- /* 等待接收新的连接 */
- err = netconn_accept(conn, &newconn);
- /* 处理新连接 */
- if (err == ERR_OK) {
- struct netbuf *buf;
- void *data;
- u16_t len;
- /* 简单的数据回环 */
- while ((err = netconn_recv(newconn, &buf)) == ERR_OK) {
- do {
- netbuf_data(buf, &data, &len);
- err = netconn_write(newconn, data, len, NETCONN_COPY);
- if (err != ERR_OK) {
- printf("Send failed: %d\n", err);
- netbuf_delete(buf);
- break; // 跳出循环,避免不一致
- }
- } while (netbuf_next(buf) >= 0);
- netbuf_delete(buf);
- }
- netconn_close(newconn);
- netconn_delete(newconn);
- }
- osDelay(2);
- }
- }
复制代码
|
|