足球盘口

首页>>足球盘口资讯

应用笔记

W5100S-SOCKET-less PING功能解析

更新时间:2018-12-17 阅览次数: 719

PING SHIDOS MINGLING,TASHIYONGLAIJIANCHAWANGLUOSHIFOUTONGCHANGHUOZHEWANGLUOLIANJIESUDUDEMINGLING。

        LIYONGDEYUANLISHI:WANGLUOSHANGDEJIQIDOUYOUWEIYIQUEDINGDEIPDIZHI,WOMENJIMUBIAOIPDIZHIFASONGYIGESHUJUBAO,DUIFANGJIUYAOFANHUIYIGETONGYANGDAXIAODESHUJUBAO, GENJUFANHUIDESHUJUBAOWOMENKEYIQUEDINGMUBIAOZHUJIDECUNZAI。

        ERZUQIUPANKOUTUICHUDEW5100S,ZEJIANGPINGGONGNENGTONGGUOYINGJIANSHIXIAN,BINGGUHUAZAIXINPIANNEI,FANGBIANKEHUSHIYONG。WUXUBIANXIEPINGGONGNENGDEXIANGGUANCHENGXUDAIMA,ZHIXUJIANDANDEJICUNQIPEIZHIJIKESHIYONGPINGGONGNENG。


YI、SHIYONGScoket-lessMINGLINGLIUCHENG

新建位图图像.bmp

CONGSHANGTUWOMENKEYIKANCHU,Socket - less MINGLINGDESHIYONG,ZHENGTILIUCHENGHAISHISHIFENMINGLEDE。

KAISHI,PEIZHIXIANGGUANJICUNQIDESHUZHI,WANCHENGHOUQIDONGSocket - less MINGLING,QIDONGHOUZEPANDUANDUIDUANDEHUIYINGYUCHAOSHIDEPANDUAN。

ERZAIZHEIGEZHENGTILIUCHENGZHONG,ZUIZHUYAODENANDIANZAIYUJICUNQIPEIZHIBUFEN。


ER、GUANYUSocket - less PING GONGNENGDEJICUNQI

WOMENZAISHIYONGSocket - less MINGLINGSHI,ZHIXUYAOPEIZHIYIXIAJICUNQIJIKEWANCHENGPINGGONGNENGDEDIAOYONG。

1.SLRTR(SOCKET - less ZHONGCHUANCHAOSHISHIJIANJICUNQI)

PEIZHIPINGDECHAOSHIZHONGCHUANSHIJIANJIBENDANWEISHI100us,DANGGUOLESHIJIANZEHUIQIDONGZHONGCHUANJIZHI。

2.SLRCR(SOCKET - less ZHONGCHUANCISHUJICUNQI)

SHEDINGZHONGCHUANCISHU,RUODANGQIANZHONGCHUANCISHU >= ZHONGCHUANCISHU + 1SHI,ZEPANDINGWEITIMEOUT。

3.SLPIPR(SOCKET - less MUBIAOIPDIZHIJICUNQI)

YINGJIANPINGDEMUBIAOIP。

4.PINGSEQR(PINGXULIEHAOJICUNQI)

PINGQINGQIUSHUJUBAODEBAOTOUXULIEHAO。

5.PINGIDR(PING IDJICUNQI)

PINGQINGQIUSHUJUBAODEBAOTOUSHUJUBAOID。

6.SLIMR(SOCKET - less ZHONGDUANPINGBIJICUNQI)

XUANZEKAIQI/GUANBIPINGYUTIMEOUTZHONGDUAN。

7.SLCR(SOCKET-lessKONGZHIJICUNQI)

FASONGXIANGGUANQINGQIUDESHINENGJICUNQI。


SAN、XIANGGUANJICUNQIDEPEIZHIJISocket - less MINGLINGDIAOYONG

SHIYONGYINGJIANPINGSHIJINXUYAOSHEZHIZHEIJIGEXIANGGUANJICUNQIJIKE。JUTIPEIZHILIUCHENGRUXIADAIMA:

void hw_ping_init(void)
{
    setSLRTR(0x03E8);       // 重传超时时间设置:1000 * 100us
    setSLRCR(3);            // 重传次数设置:3次
    /* 使用中断时可开启该配置 */	
    setSLIMR(0x05);         // 中断开启 PING & TIMEOUT
 
    setPINGSEQR(0x03E8);    // 请求数据包序列号设置:1000
    setPINGIDR(0x0100);     // 请求数据包ID:100
}

SHANGSHUDAIMASHIYONGYINGJIANPINGGONGNENGSHI,WUTESHUYAOQIUNEIMESHEZHIYICIJIKE。SHEZHIXIANHOUSHUNXUBUZUOYAOQIU。

void hw_ping(uint8* ip)
{
    setSLPIPR(ip);                    // 目标IP设置:PING对象IP
    setSLCR(0x01);                    // 发送PING请求
}

ZHEIBUFENDAIMAZAIXUYAOSHIYONGYICIYINGJIANPINGGONGNENGSHI,JINXINGYICIDIAOYONG。

ERPANDUANPINGDEJIEGUO,ZEKESHIYONGZHONGDUANJINXINGPANDUAN,CHAOSHIHAISHIXIANGYINGDOUHUIFASHENGCIZHONGDUAN,JUTIRUXIA:

switch(getSLIR())
{
    case 0x01:             // PING回应标志
        setSLIR(0x01);
        getSLPHAR(remote_mac);
        printf("
已收到来自 %d.%d.%d.%d 的PING回应。",
        hw_ping_ip[0],hw_ping_ip[1],hw_ping_ip[2],hw_ping_ip[3]);
    break;
 
    case 0x04:
        setSLIR(0x04);
        printf("
来自 %d.%d.%d.%d 的回复:无法访问目标主机。",hw_ping_ip[0],
        hw_ping_ip[1],hw_ping_ip[2],hw_ping_ip[3]);
    break;
    default:break;
}

ZHONGDUANFASHENGHOU,GENJUPINGDESLIRJICUNQIDESHUZHI,PANDUANDUIFANGSHIJIYUFANKUI,HAISHIYIJINGCHAOSHI。


SI、DAIMAYUNXINGJIEGUO

DIANNAOIP:192.168.1.100

W5100S YUDIANNAOLIANJIEZAITONGYILUYOUQIXIA。

W5100S YINGJIANPING IP:192.168.1.100

DANGDIANNAOWANGXIANJIERUSHI:

image.png

当电脑网线拔掉时:

image.png