當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Arduino Ethernet - Ethernet.hardwareStatus()用法及代碼示例

說明

以太網。hardwareStatus() 告訴您在以太網期間檢測到哪個 WIZnet 以太網控製器芯片。begin(),如果有的話。這可用於故障排除。如果未檢測到以太網控製器,則可能存在硬件問題。

用法

Ethernet.hardwareStatus()

參數

返回

  • 在以太網期間檢測到哪個 WIZnet 以太網控製器芯片。begin() (EthernetHardwareStatus):
EthernetNoHardware
EthernetW5100
EthernetW5200
EthernetW5500

示例

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(10, 0, 0, 177);

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  Ethernet.begin(mac, ip);

  if (Ethernet.hardwareStatus() == EthernetNoHardware) {
    Serial.println("Ethernet shield was not found.");
  }
  else if (Ethernet.hardwareStatus() == EthernetW5100) {
    Serial.println("W5100 Ethernet controller detected.");
  }
  else if (Ethernet.hardwareStatus() == EthernetW5200) {
    Serial.println("W5200 Ethernet controller detected.");
  }
  else if (Ethernet.hardwareStatus() == EthernetW5500) {
    Serial.println("W5500 Ethernet controller detected.");
  }
}

void loop () {}

相關用法


注:本文由純淨天空篩選整理自arduino.cc大神的英文原創作品 Ethernet - Ethernet.hardwareStatus()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。