Lateralleap
Well-known member
I have tried two different boards and ethernet kits
The green link LED never lights
I have tried the NativeEthernet UPD example but cannot ping the board
I have tried the code below, still no ping:
When I run this, the MAC address and IP address are printed out with no other errors
Any suggestions?
Thanks
The green link LED never lights
I have tried the NativeEthernet UPD example but cannot ping the board
I have tried the code below, still no ping:
Code:
#include <NativeEthernet.h>
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network.
// gateway and subnet are optional:
byte mac[6];
IPAddress ip(??, ??, ??, ??); // Ethernet address obfuscated
EthernetServer server(80);
boolean alreadyConnected = false; // whether or not the client was connected previously
void teensyMAC(uint8_t *mac) {
for (uint8_t by = 0; by < 2; by++) mac[by] = (HW_OCOTP_MAC1 >> ((1 - by) * 8)) & 0xFF;
for (uint8_t by = 0; by < 4; by++) mac[by + 2] = (HW_OCOTP_MAC0 >> ((3 - by) * 8)) & 0xFF;
Serial.printf("MAC: %02x:%02x:%02x:%02x:%02x:%02x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
}
void setup() {
// Set the MAC address.
teensyMAC(mac);
Ethernet.begin(mac, ip);
// 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
}
// Check for Ethernet hardware present
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :(");
while (true) {
delay(1); // do nothing, no point running without Ethernet hardware
}
}
if (Ethernet.linkStatus() == LinkOFF) {
Serial.println("Ethernet cable is not connected.");
}
// start listening for clients
server.begin();
Serial.print("Chat server address:");
Serial.println(Ethernet.localIP());
}
void loop() {
// wait for a new client:
EthernetClient client = server.available();
// when the client sends the first byte, say hello:
if (client) {
while (client.connected()) {
while (client.available() > 0) {
char c = client.read();
Serial.write(c);
}
}
client.stop();
Serial.println("Client disconnected");
}
}
When I run this, the MAC address and IP address are printed out with no other errors
Any suggestions?
Thanks
Last edited by a moderator: