Hi leute, heute mal etwas einfaches hoffe ich. ich möchte alle daten die an meinen arduino via lan auf mein Ethernetshield gesendet werden via usb anzeigen lassen, um zu sehen welche daten empfangen werden. doch irgendwie wird mir nichts angezeigt.
#include <Ethernet.h>
#include <SPI.h>
// the media access control (ethernet hardware) address for the shield:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
//the IP address for the shield:
byte ip[] = { 192, 168, 178, 42 };
// the router's gateway address:
byte gateway[] = { 192, 168, 178, 1 };
// the subnet:
byte subnet[] = { 255, 255, 0, 0 };
// telnet defaults to port 23
EthernetServer server = EthernetServer(65506);
void setup()
{
Serial.begin(9600);
// this check is only needed on the Leonardo:
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
for (;;)
;
}
// print your local IP address:
Serial.print("My IP address: ");
for (byte thisByte = 0; thisByte < 4; thisByte++) {
// print the value of each byte of the IP address:
Serial.print(Ethernet.localIP()[thisByte], DEC);
Serial.print(".");
}
Serial.println();
}
int i=1;
void loop() {
// if an incoming client connects, there will be bytes available to read:
EthernetClient client = server.available();
if (client) {
Serial.print(client.read());
Serial.println();
// read bytes from the incoming client and write them back
// to any clients connected to the server:
//server.write(client.read());
}
else{
Serial.print(i);
Serial.println();
delay(2000);
i++;
}
}
Gibt es alternativ auch die möglichkeit mehrere Ports auszulesen? der angegebene port ist der auf dem mir daten zugesendet werden.
um von Vornhinein die frage zu eleminieren ob ich auch die ip adresse habe, ja diese wird meinem Arduino immer zugewiesen, das wurde so in meinem modem so eingestellt.