首页 / C/C++编程 / 帖子

在嵌入式系统里面如何实现Callback函数

作者 uisrc 2016-06-05 10133 次浏览 0 条回复 论坛存档
uisrc
uisrc
2016-06-05
楼主
[mw_shl_code=c,true]/** Function prototype for tcp accept callback functions. Called when a new
& `9 M. m8 K; k3 Q * connection can be accepted on a listening pcb.
4 ?# o+ K$ G7 X% A0 @9 p *
* s( @% T% w8 [% O6 T * @param arg Additional argument to pass to the callback function (@see tcp_arg())
* @param newpcb The new connection pcb
- T( A# r5 v. B2 Z8 w; n2 a) \ * @param err An error code if there has been an error accepting.
*            Only return ERR_ABRT if you have called tcp_abort from within the
*            callback function!
*/
typedef err_t (*tcp_accept_fn)(void *arg, struct tcp_pcb *newpcb, err_t err);

/** Function prototype for tcp receive callback functions. Called when data has
5 Z& n1 O& J! m3 T+ J) T- Z * been received.
6 P* {  ?5 q$ Z1 ^ *
9 U- N+ K% m- K+ x7 k * @param arg Additional argument to pass to the callback function (@see tcp_arg())
/ {1 |' a: L. l, L/ j* L( M7 | * @param tpcb The connection pcb which received data
4 M: ~- K" ~$ S * @param p The received data (or NULL when the connection has been closed!)
* @param err An error code if there has been an error receiving
; z" P) o6 {) _ *            Only return ERR_ABRT if you have called tcp_abort from within the
*            callback function!
3 u2 b4 ^* w) ^ */
& B6 _* f+ h( k4 ^, n# ]. Ltypedef err_t (*tcp_recv_fn)(void *arg, struct tcp_pcb *tpcb,
0 W8 m& g  J+ y' n$ k                             struct pbuf *p, err_t err);

% S* L& W# y+ C6 [: r  K/** Function prototype for tcp sent callback functions. Called when sent data has
9 G2 y, A; ^* t * been acknowledged by the remote side. Use it to free corresponding resources.
* This also means that the pcb has now space available to send new data.
5 M1 i/ A& [  P; A& ~% ~+ n *
0 v* H/ T, Y- H' C! y7 L3 p * @param arg Additional argument to pass to the callback function (@see tcp_arg())
* @param tpcb The connection pcb for which data has been acknowledged
* @param len The amount of bytes acknowledged
* @return ERR_OK: try to send some data by calling tcp_output
*            Only return ERR_ABRT if you have called tcp_abort from within the
' M' F  \( `2 ]  { *            callback function!
*/
typedef err_t (*tcp_sent_fn)(void *arg, struct tcp_pcb *tpcb,
                              u16_t len);
[/mw_shl_code]

这是论坛时期的原帖存档,只读。新的讨论请到 提问, 沉淀下来的内容会进 知识库 和 方案库。