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.

关于CC3200的TCP通信问题

Other Parts Discussed in Thread: CC3200, CC3100

我想要将我的CC3200为STM32进行通信,CC3200处理STM32的串口传来的数据,发送给TCP服务器。TCP服务器发送的数据我又能够传回STM32。

目前我能实现的STM32的串口通信没有问题,能发送出我想要的数据。但是TCP服务器服务器并没有显示我发送的数据,所以我认为应该是CC3200处理接收数据程序的问题。反之,TCP服务器发送的数据,STM32也并没有收到,这里我认为应该是CC3200处理发送数据程序的问题。(关于STM32的程序,我打算一个串口用于串口调试助手,另一个串口负责与CC3200完成通信。这方面的功能我有测试过是实现了的。所以认为是CC3200的程序出了问题)

下面是我的接收数据和发送数据的程序。请问我要如何改进。望不吝赐教!

int WuartTransfer(unsigned long ulBase, int iSockID)
{
char cTxBuf[100],i;
char cRxBuf[100];
char cGetChar;
int iStatus,iStatusRecv;
int iCounter=0;
// int iStatus,iStatusRecv;
UART_PRINT("\r\n");
while(1)
{//UART接收字符
cGetChar=MAP_UARTCharGetNonBlocking(ulBase);//接收串口1字符
if(cGetChar!=0xff)
{//UART回显字符
MAP_UARTCharPut(ulBase,cGetChar);
//保存接收字符
cTxBuf[iCounter++]=cGetChar;
//Enter(回车)键(0x0d)或Esc(退出)键(0x1b)
if((cGetChar==0x0d)||(cGetChar==0x1b))
{//回显并保存“换行"(0x0a)
MAP_UARTCharPut(ulBase,0x0a);
cTxBuf[iCounter++]=0x0a;
iStatus=sl_Send(iSockID,cTxBuf,iCounter,0);//将串口1的字符发送给TCP服务器
if(iStatus<=0)
{//错误处理
ASSERT_ON_ERROR(sl_Close(iSockID));
UART_PRINT("发送数据失败\n\r");
break;
}
// Enter(回车)键(0x0d)
if(cGetChar==0x0d)
{
UART_PRINT("发送:");
iCounter=0;
}
//Esc(退出)键(0x1b),退出循环
else
break;
}
}
//recv tcp
iStatus = sl_Recv(iSockID,cRxBuf,100,0);
if(iStatus > 0)
{
iStatusRecv = sl_Send(iSockID, cRxBuf, iStatus, 0);
MAP_UARTCharPut(ulBase,iStatus);
if(iStatusRecv <= 0)
{
ASSERT_ON_ERROR(sl_Close(iSockID));
UART_PRINT("发送数据失败\n\r:");
break;
}
for(i = 0; i < iStatus; i++ )
{
UART_PRINT("send2: %2c \n\r", cRxBuf[i]);
}
}
}
return(iStatus);
}