云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > LwIP Application Developers Manual 中文翻译

LwIP Application Developers Manual 中文翻译

  • 62 次阅读
  • 3 次下载
  • 2025/12/2 20:46:25

/**

* Reads from the serial device. *

* @param fd serial device handle

* @param data pointer to data buffer for receiving

* @param len maximum length (in bytes) of data to receive * @return number of bytes actually received - may be 0 if aborted by sio_read_abort * */

u32_t sio_read(sio_fd_t fd, u8_t *data, u32_t len);

sio_read_abort函数将会导致sio_read操作马上退出。当要结束一个PPP会话时(终止、断开连接、明确关闭),tcpip_thread将调用sio_read_abord函数。该函数模型如下所示: /**

* Aborts a blocking sio_read() call. *

* @param fd serial device handle */

void sio_read_abort(sio_fd_t fd);

25 / 88

必须的回调函数

该回调函数的模型如下所示:

void (*linkStatusCB)(void *ctx, int errCode, void *arg) 该函数主要被如下事件所调用:

? 链接终止。errCode是一个非零值,arg为null

? sigup(Interface Up)。errCode为PPPERR_NONE,arg是一个指向ppp_addrs结构体的指针,该结构体包含了IP地址

? sifdown(Interface

Down)

errCode

PPPERR_CONNECT,arg为null errCode可以为如下一些数值:

#define PPPERR_NONE 0 /* No error. */

#define PPPERR_PARAM -1 /* Invalid parameter. */ #define PPPERR_OPEN -2 /* Unable to open PPP session. */

#define PPPERR_DEVICE -3 /* Invalid I/O device for PPP. */

#define PPPERR_ALLOC -4 /* Unable to allocate resources. */

#define PPPERR_USER -5 /* User interrupt. */ #define PPPERR_CONNECT -6 /* Connection lost. */ #define PPPERR_AUTHFAIL -7 /* Failed authentication

26 / 88

challenge. */

#define PPPERR_PROTOCOL -8 /* Failed to meet protocol. */

ctx指针是一个可选的用户自定义的指针,且该指针被定义为函数topppOverSerialOpen的参数,该指针指向用户定义的数据,。

没有任务的支持时

你需要在主线程里面调用函数pppos_input(int pd, u_char*

data, int len)来接收串行数据。

应用任务的代码

这个例子显示了TCP和PPP线程的初始化。假设你将会处

理你的socket在main()函数中上下文中。 #include \

#define PPP_SERIAL_PORT 0

static void linkStatusCB(void* ctx, int errCode, void* arg);

int main(void) { int connected = 0; int setup = 0;

27 / 88

int pd;

const char *username = \ const char *password = \

/* initialise lwIP. This creates a new thread, tcpip_thread, that

* communicates with the pppInputThread (see below) */ tcpip_init(tcpip_init_done, &setup); while (!setup) { sleep(1); }

/* initialise PPP. This needs to be done only once after boot up, to

* initialize global variables, etc. */ pppInit(); /*

set

the

method

of

authentication.

Use

PPPAUTHTYPE_PAP, or

* PPPAUTHTYPE_CHAP for more security . *

If

this

is

not

called,

the

default

is

PPPAUTHTYPE_NONE.

28 / 88

搜索更多关于: LwIP Application Developers Ma 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

/** * Reads from the serial device. * * @param fd serial device handle * @param data pointer to data buffer for receiving * @param len maximum length (in bytes) of data to receive * @return number of bytes actually received - may be 0 if aborted by sio_read_abort * */ u32_t sio_read(sio_fd_t fd, u8_t *data, u32_t len); sio_read_abort函数将会导致sio

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com