Ethernet.hardwareStatus()

名称

Ethernet.hardwareStatus()

説明

Ethernet.hardwareStatus()は、Ethernet.begin()によって認識した、WIZnetイーサネットコントローラの種類を返却する。これは、トラブルシューティングに利用することができる。もしもイーサネットコントローラが検出できなかった場合は、ハードウェアに問題があることが疑われる。

書式

EthernetHardwareStatus EthernetClass::hardwareStatus();

引数

なし。

戻り値

Ethernet.begin()によって認識した、WIZnetイーサネットコントローラの種類。

  • EthernetNoHardware
  • EthernetW5100
  • EthernetW5200
  • EthernetW5500

使用例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#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 () {}

オリジナルのページ

https://www.arduino.cc/reference/en/libraries/ethernet/ethernet.hardwarestatus/

最終更新日

January 7, 2024

inserted by FC2 system