我在MSP430FF5529上使用网络微控制器CC3100
我试图从我的Android设备向主板发送数据。 微控制器的程序是从德克萨斯仪器开发的示例p2p应用程序。它应该能够接收数据。它打开TCP服务器套接字并等到连接
我在本教程Android TCP Connection Tutorial上开发了一个仅基于TCP客户端部分的android应用程序。 但它没有正确连接。 这是cc3100打开服务器时的功能;我放置了一些CLIwrite以查看tera术语(终端/控制台)的进度。
static _i32 BsdTcpServer(_u16 Port){
SlSockAddrIn_t Addr;
SlSockAddrIn_t LocalAddr;
_u16 idx = 0;
_u16 AddrSize = 0;
_i16 SockID = 0;
_i32 Status = 0;
_i16 newSockID = 0;
_u16 LoopCount = 0;
_u16 recvSize = 0;
CLI_Write(" [TCP Server] var declared \n\r");
for (idx=0 ; idx<BUF_SIZE ; idx++)
{
uBuf.BsdBuf[idx] = (_u8)(idx % 10);
}
CLI_Write(" [TCP Server] exit: for (idx=0 ; idx<BUF_SIZE ; idx++) \n\r");
LocalAddr.sin_family = SL_AF_INET;
LocalAddr.sin_port = sl_Htons((_u16)Port);
LocalAddr.sin_addr.s_addr = 0;
SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
CLI_Write(" [TCP Server] sl_Socket \n\r");
if( SockID < 0 )
{
CLI_Write(" [TCP Server] sockID < 0 \n\r");
CLI_Write(" [TCP Server] Create socket Error \n\r");
ASSERT_ON_ERROR(SockID);
}
CLI_Write(" [TCP Server] Socket created \n\r");
AddrSize = sizeof(SlSockAddrIn_t);
Status = sl_Bind(SockID, (SlSockAddr_t *)&LocalAddr, AddrSize);
if( Status < 0 )
{
CLI_Write(" [TCP Server] status2 < 0 \n\r");
sl_Close(SockID);
CLI_Write(" [TCP Server] Socket address assignment Error \n\r");
ASSERT_ON_ERROR(Status);
}
CLI_Write(" [TCP Server] socket adress ok \n\r");
Status = sl_Listen(SockID, 0);
CLI_Write(" [TCP Server] sl listen \n\r");
if( Status < 0 )
{
CLI_Write(" [TCP Server] status1 < 0 \n\r");
sl_Close(SockID);
CLI_Write(" [TCP Server] Listen Error \n\r");
ASSERT_ON_ERROR(Status);
}
CLI_Write(" [TCP Server] status > 0 \n\r");newSockID = sl_Accept(SockID, ( struct SlSockAddr_t *)&Addr,(SlSocklen_t*)&AddrSize); if( newSockID < 0 )
{
CLI_Write(" [TCP Server] newsockID < 0 \n\r");
sl_Close(SockID);
CLI_Write(" [TCP Server] Accept connection Error \n\r");
ASSERT_ON_ERROR(newSockID);
}
while (LoopCount < NO_OF_PACKETS)
{
recvSize = BUF_SIZE;
do
{
Status = sl_Recv(newSockID, &uBuf.BsdBuf[BUF_SIZE - recvSize], recvSize, 0);
if( Status <= 0 )
{
CLI_Write(" [TCP Server] status < 0 \n\r");
sl_Close(newSockID);
sl_Close(SockID);
CLI_Write(" [TCP Server] Data recv Error \n\r");
ASSERT_ON_ERROR(TCP_RECV_ERROR);
}
recvSize -= Status;
}while(recvSize > 0);
LoopCount++;
}
Status = sl_Close(newSockID);
ASSERT_ON_ERROR(Status);
Status = sl_Close(SockID);
ASSERT_ON_ERROR(Status);
CLI_Write(" return function \n\r");
return SUCCESS;}
当我尝试发送字符串时,它不起作用,并且在此ligne处被阻止
Status = sl_Recv(newSockID, &uBuf.BsdBuf[BUF_SIZE - recvSize], recvSize, 0);
示例中的应用程序应连接到右侧PORT的卡IP,但是当我尝试发送某些内容时,它不会发送任何内容。 我下载了应用程序TCPclient,它发送了消息,但是在控制台上我没有看到建立的TCP连接。
使用Iperf我可以检查我的Android设备和主板之间的连接,它可以正常工作。
某人有什么建议吗?