Intel Galileo Gen 2 보드가 있으며 Arduino IDE로 일부 코드를 테스트하고 있습니다. 이더넷 네트워크를 구성 할 때 문제가 있습니다. 다음 코드, 기본적으로 예에서 진화 :Arduino + Intel Galileo Gen 2 이더넷 IP가 설정되지 않았습니다.
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0x98, 0x4F, 0xEE, 0x05, 0x65, 0x02 };
IPAddress server(192, 168, 15, 64);
IPAddress ip(192, 168, 15, 177);
IPAddress dnServer(8, 8, 8, 8);
IPAddress gateway(192, 168, 15, 1);
IPAddress subnet(255, 255, 255, 0);
EthernetClient client;
void setup() {
Serial.begin(9600);
Serial.print("ip - ");
Serial.println(ip);
Ethernet.begin(mac, ip, dnServer, gateway, subnet);
delay(1000);
system("ifup eth0");
delay(1000);
Serial.println(Ethernet.localIP());
Serial.println("connecting...");
if (client.connect("www.google.com", 80)) {
Serial.println("connected");
client.println("GET /search?q=arduino HTTP/1.1");
client.println("Host: www.google.com");
client.println("Connection: close");
client.println();
}
else {
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
}
// the loop function runs over and over again forever
void loop() {
if (client.available()) {
char c = client.read();
Serial.print(c);
}
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
for(;;)
;
}
}
이 나는 결과로 볼 것입니다 :
ip - 192.168. 15.177
255.255.255.255
connecting...
connection failed
disconnecting.
내가 볼 것은 LOCALIP는 표시로 어떤 IP 주소가 aparently 할당되지이다 255.255.255.255.
포럼에서 발견 된 몇 가지 해결 방법을 시도했지만 인터페이스는 작동하지 않지만 SD 카드는 사용할 수 없습니다.
내가 뭘 잘못하고 있니?
덕분에 내가 잘못된 MAC 주소를 수정 한
업데이트. ifup 명령이 추가되었습니다. 변경 사항 없음.
system("ifconfig -a > /dev/ttyGS0");
명령을 추가 한 후 나는이 얻을 : 나는 IP를 설정하려고하지만 여전히 DHCP 검색되지 알고있는 것처럼
enp0s20f6 Link encap:Ethernet HWaddr 98:4F:EE:05:65:02
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:980 (980.0 B)
Interrupt:50 Base address:0x4000
enp0s20f6:avahi Link encap:Ethernet HWaddr 98:4F:EE:05:65:02
inet addr:169.254.4.217 Bcast:169.254.255.255 Mask:255.255.0.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
Interrupt:50 Base address:0x4000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:584 errors:0 dropped:0 overruns:0 frame:0
TX packets:584 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:45040 (43.9 KiB) TX bytes:45040 (43.9 KiB)
.
설명이 결과로 업데이트되었습니다. – jordi