Ethernet.linkStatus()

名称

Ethernet.linkStatus()

説明

リンクがアクティブかどうかを返却する。LinkOFFはイーサネットケーブルが接続されていないか、不良であるかを示す。この機能は、W5200かw5500イーサネットコントローラチップを使っているときだけ利用できる。

書式

EthernetLinkStatus EthernetClass::linkStatus();

引数

なし。

戻り値

リンク状態。

  • Unknown
  • LinkON
  • LinkOFF

使用例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <SPI.h>
#include <Ethernet.h>

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
  }
}

void loop () {
  if (Ethernet.linkStatus() == Unknown) {
    Serial.println("Link status unknown. Link status detection is only available with W5200 and W5500.");
  }
  else if (Ethernet.linkStatus() == LinkON) {
    Serial.println("Link status: On");
  }
  else if (Ethernet.linkStatus() == LinkOFF) {
    Serial.println("Link status: Off");
  }
}

オリジナルのページ

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

最終更新日

January 7, 2024

inserted by FC2 system