tcp socket工具中连接成功,显示发送接收数据都是对的
ccs里的expression的值就是

串口打印出来的数据长度也是对的

This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
您好,
图片看不清楚,如果收发正常,data_buf[]是否还存储其他数据,建议通过发送有规律的数据长度来检测data_buf[]显示。
请参考CCS用户手册“7.4.3.2. Expressions View'
7.1. Debug Overview — Code Composer Studio 12.8.0 Documentation
代码中除了前面声明了全局变量:unsigned char data_buf[1500] = {0};,然后就只在main函数中一个while(1)循环里调用tcp_server函数把data_buf作为参数传进去了:tcp_server(1, TCP_SERVER_PORT, data_buf, 0);
tcp_server函数:
void tcp_server(SOCKET s, uint16_t port, \
unsigned char *buf, uint16_t mode)
{
uint16_t len;
char printf_buf[64] = {0};
/* check the socket status */
switch(getSn_SSR(s)) {
case SOCK_ESTABLISHED://建立套接字
/* establish a connection */
if(getSn_IR(s) & Sn_IR_CON) {
memset(printf_buf, 0, sizeof(printf_buf));
sprintf(printf_buf, "%d : Connect OK\r\n", s);
SCI_writeCharArray(SCIA_BASE, (uint16_t *)printf_buf, sizeof(printf_buf));
setSn_IR(s, Sn_IR_CON);//设置与套接字s相关的中断请求状态寄存器(Sn_IR)的值
}
/* receive the data and send back */
if((len = getSn_RX_RSR(s)) > 0) {//获取套接字s的接收缓冲区中当前(剩余)可读取数据的字节数
len = recv(s, buf, len);//从套接字s接收数据到缓冲区buf中,返回实际接收到的数据长度
memset(printf_buf, 0, sizeof(printf_buf));
sprintf(printf_buf, "%d : Received %uBytes\r\n", s, len);
SCI_writeCharArray(SCIA_BASE, (uint16_t *)printf_buf, sizeof(printf_buf));
if(len !=send(s, buf, len)) {
memset(printf_buf, 0, sizeof(printf_buf));
sprintf(printf_buf, "%d : Send Fail.len=%d\r\n", s, len);
SCI_writeCharArray(SCIA_BASE, (uint16_t *)printf_buf, sizeof(printf_buf));
}
}
break;
case SOCK_CLOSE_WAIT:
/* disconnect */
disconnect(s);
break;
case SOCK_CLOSED:
/* close the socket and open it again */
close(s);
socket(s, Sn_MR_TCP, port, mode);
break;
case SOCK_INIT:
/* listen the tcp client connection requests */
listen(s);
memset(printf_buf, 0, sizeof(printf_buf));
sprintf(printf_buf, "%d : LOOPBACK_TCPS(%d) Started.\r\n", s, port);
SCI_writeCharArray(SCIA_BASE, (uint16_t *)printf_buf, sizeof(printf_buf));
break;
default:
break;
}
}