static void udp_server_receive_callback(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16_t port) { uint32_t i; /* 数据回传 */ udp_sendto(upcb, p, addr, port); /* 打印接收到的数据 */ printf("get msg from %d:%d:%d:%d port:%d:\r\n", *((uint8_t *)&addr->addr), *((uint8_t *)&addr->addr + 1), *((uint8_t *)&addr->addr + 2), *((uint8_t *)&addr->addr + 3), port); if (p != NULL) { struct pbuf *q = p; while(q != NULL) { //此处接收长度由问题 printf("len=%u\r\n", q->len); for (i = 0; i < q->len; i++) { printf("%X ", *((char *)q->payload + i)); } q = q->next; } printf("\r\n"); } /* 释放缓冲区数据 */ pbuf_free(p); } 这个接收回调函数数据回传是对的,但是打印出来的长度和数据都不对 发送:1234567890 接收打印信息: get msg from 192:168:68:100 port:777: len=52 3C 52 82 51 3A 6C 0 80 E1 0 0 0 8 0 45 0 0 26 0 35 0 0 FF 11 B1 98 C0 A8 44 44 C0 A8 44 64 22 B0 3 9 0 12 C6 12 31 32 33 34 35 36 37 38 39 30 请教一下是哪里出了问题? |
firmware:STM32Cube FW_F1 V1.8.1
网口芯片:DP83848IVVX