日本免费全黄少妇一区二区三区-高清无码一区二区三区四区-欧美中文字幕日韩在线观看-国产福利诱惑在线网站-国产中文字幕一区在线-亚洲欧美精品日韩一区-久久国产精品国产精品国产-国产精久久久久久一区二区三区-欧美亚洲国产精品久久久久

以太網(wǎng)電纜被拔出什么意思 筆記本以太網(wǎng)網(wǎng)絡(luò)電纜被拔出

在此之前可以閱讀前篇博文Arduino-Ethernet庫(kù)學(xué)習(xí)筆記(1) 。這篇博文是關(guān)于該庫(kù)的簡(jiǎn)介、調(diào)試工具之UDP/TCP網(wǎng)絡(luò)調(diào)試助手NetAssist介紹、Postman介紹以及網(wǎng)絡(luò)方面的小經(jīng)驗(yàn) 。下面開(kāi)始來(lái)學(xué)習(xí)Arduino-Ethernet庫(kù)中的Ethernet 類 。
1 Ethernet 類以太網(wǎng)類初始化以太網(wǎng)庫(kù)和網(wǎng)絡(luò)設(shè)置 。
1.1 Ethernet.begin()

  • 描述
初始化以太網(wǎng)庫(kù)和網(wǎng)絡(luò)設(shè)置 。在1.0版中,該庫(kù)支持DHCP 。在正確的網(wǎng)絡(luò)設(shè)置下使用Ethernet.begin(mac),以太網(wǎng)板將自動(dòng)獲取IP地址 。這會(huì)大大增加案例的大小 。為確保在需要時(shí)正確續(xù)訂DHCP租約,請(qǐng)確保定期調(diào)用Ethernet.maintain() 。
  • 語(yǔ)法
Ethernet.begin(mac);
Ethernet.begin(mac, ip);
Ethernet.begin(mac, ip, dns);
Ethernet.begin(mac, ip, dns, gateway);
Ethernet.begin(mac, ip, dns, gateway, subnet);
  • 參數(shù)
mac:設(shè)備的MAC(媒體訪問(wèn)控制)地址(6個(gè)字節(jié)的數(shù)組) 。這是屏蔽的以太網(wǎng)硬件地址 。較新的Arduino以太網(wǎng)板包含帶有設(shè)備MAC地址的標(biāo)簽 。對(duì)于較舊的板,請(qǐng)選擇您自己的;
ip:設(shè)備的IP地址(4個(gè)字節(jié)的數(shù)組);
gateway:網(wǎng)絡(luò)網(wǎng)關(guān)的IP地址(4個(gè)字節(jié)的數(shù)組) ???。耗銜璞窱P地址,最后一個(gè)八位位組設(shè)置為1;
subnet:網(wǎng)絡(luò)的子網(wǎng)掩碼(4個(gè)字節(jié)的數(shù)組) ???。耗銜?55.255.255.0 。
  • 返回值
此函數(shù)的DHCP版本Ethernet.begin(mac)返回一個(gè)int:成功的DHCP連接為1,失敗的則為0 。其他版本不返回任何內(nèi)容 。
  • 例子
#include <SPI.h>
#include <Ethernet.h>
// 板的媒體訪問(wèn)控制(以太網(wǎng)硬件)地址:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
//板的IP地址:
byte ip[] = { 10, 0, 0, 177 };
void setup()
{
Ethernet.begin(mac, ip);
}
void loop () {}
1.2 Ethernet.dnsServerIP()
  • 描述
返回設(shè)備的DNS服務(wù)器IP地址 。
  • 語(yǔ)法
Ethernet.dnsServerIP()
  • 參數(shù)
無(wú)
  • 返回值
設(shè)備的DNS服務(wù)器IP地址(IPAddress)
  • 例子
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(10, 0, 0, 177);
void setup() {
Serial.begin(9600);
while (!Serial) {
; // 等待串行端口連接 。僅本地USB端口需要
}
Ethernet.begin(mac, ip);
Serial.print("The DNS server IP address is: ");
Serial.println(Ethernet.dnsServerIP());
}
void loop () {}
  • 串口打印結(jié)果:
The DNS server IP address is: 10.0.0.1
1.3 Ethernet.gatewayIP()
  • 描述
返回設(shè)備的網(wǎng)關(guān)IP地址 。
  • 語(yǔ)法
Ethernet.gatewayIP()
  • 參數(shù)
無(wú)
  • 返回值
設(shè)備的網(wǎng)關(guān)IP地址(IPAddress) 。
  • 例子
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(10, 0, 0, 177);
void setup() {
Serial.begin(9600);
while (!Serial) {
; // 等待串行端口連接 。僅本地USB端口需要
}
Ethernet.begin(mac, ip);
Serial.print("The gateway IP address is: ");
Serial.println(Ethernet.gatewayIP());
}
void loop () {}
  • 串口打印結(jié)果:
The gateway IP address is: 10.0.0.1
1.4 Ethernet.hardwareStatus()
  • 描述
Ethernet.hardwareStatus()告訴您在Ethernet.begin()期間檢測(cè)到哪個(gè)WIZnet以太網(wǎng)控制器芯片(如果有) 。這可用于故障排除 。如果未檢測(cè)到以太網(wǎng)控制器,則可能是硬件問(wèn)題 。

推薦閱讀