Ethernet.MACAddress()

名称

Ethernet.MACAddress()

説明

与えられたバッファに、デバイスのMACアドレスを設定する。

書式

void EthernetClass::MACAddress(uint8_t *mac_address);

引数

mac_addressMACアドレスを格納するためのバッファ(6バイトの配列)。

戻り値

なし。

使用例

 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
#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) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  Ethernet.begin(mac, ip);

  byte macBuffer[6];  // create a buffer to hold the MAC address
  Ethernet.MACAddress(macBuffer); // fill the buffer
  Serial.print("The MAC address is: ");
  for (byte octet = 0; octet < 6; octet++) {
    Serial.print(macBuffer[octet], HEX);
    if (octet < 5) {
      Serial.print('-');
    }
  }
}

void loop () {}

オリジナルのページ

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

最終更新日

January 7, 2024

inserted by FC2 system