微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > TI WIFI设计交流 > CC3200数据包发送

CC3200数据包发送

时间:10-02 整理:3721RD 点击:

Hi

我们用CC3200 UDP socket开发我们的应用,我的一个问题,在我调用sl_SendTo发送数据包之后,我怎么知道/什么时候知道我的包发送出去了?如果发送失败,我怎么知道?

如果使用阻塞和非阻塞的UDP socket对于我前面的问题又会有什么不一样的情况?

谢谢

HH

可以通过返回值判断,如果有错误,会返回SL_SOCKET_TX_FAILED_EVENT

具体请看: http://processors.wiki.ti.com/index.php/CC32xx_UDP_Socket_Application

Hi Viki

你的意思是当我以阻塞的方式调用sl_SendTo发送数据包,当这个函数调用返回正确,这个包已经通过sl_SendTo的RF发送到AP,并且这个包也已经得到了对方MAC layer 的ACK了?

那以非阻塞的方式调用sl_SendTo,也是这样么?

谢谢

HH

 sl_SetSockOpt(TcpID,SL_SOL_SOCKET,SL_SO_NONBLOCKING, (_u8 *)&enableOption,sizeof(enableOption));                 阻塞、非阻塞状态设置函数

详细的信息请参考CC3200 Network Programmer Guide-swru368a

Socket Options
6.5.1 Blocking vs NonBlocking
Depending on the implementation, choose to run the application with or without OS. Normally, when the
application is run without OS, set the socket option to nonblocking with sl_SetSockOpt() with the third
parameter as SL_SO_NONBLOCKING. An OS-based application, however, has the option to perform
multithreading and can handle blocking functions.
Status = sl_SetSockOpt(SockID, SL_SOL_SOCKET, SL_SO_NONBLOCKING,
&nonBlockingValue, sizeof(nonBlockingValue)) ;
If the blocking mechanism is used, these functions block until execution is finished.
If the nonblocking mechanism is used, these functions return with an error code. The value of the error
codes depends the function used. For details, see the online documentation.
sl_Connect(), sl_Accept(), sl_Aend(), sl_Aendto(), sl_Recv(), and sl_Recvfrom() are affected by this flag. If
not set, the default is blocking.
An example with sl_Connect() on a client application:
• Blocking: sl_Connect() blocks until it is connecting to a server, or until an error occurs. Do not use
blocking if the application is single-threaded and needs to perform other tasks (such as handling
multiple sockets to read/write). However, using blocking is fine if the application is OS-based (like
FreeRTOS).
Status = sl_Connect(SockID, ( SlSockAddr_t *) &Addr, AddrSize);
• Non-Blocking: sl_Connect() returns immediately, regardless of connection. If connection is successful,
a value of 0 returns. If not, the function returns SL_EALREADY under normal conditions. TI
recommends that the function is called in a loop so that the function keeps retrying the connection until
the user decideds to quit. The advantage of a non-blocking mechanism is to prevent the application
from getting stuck in one place forever. This is particularly useful if your application needs to perform
other tasks (such as blinking LED, reading sensor data, or having other connections simultaneously) at
the same time.

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top