Hello! The packets are almost always recieved, but sometimes after receiving a packet lights LINK, 100M, FULLO and COLL will just turn off for a second and then turn on back again and then the LINK light would just start to rapidly blink and the arduino just becomes unresponsive and won't receive packets. What causes that?
Code:
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <SPI.h>byte mac[] = {0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02};
unsigned int localPort = 8888;
char packetBuffer[UDP_TX_PACKET_MAX_SIZE];
char replyBuffer[UDP_TX_PACKET_MAX_SIZE];
EthernetUDP Udp;void setup() {
// put your setup code here, to run once:
// Serijski port
Serial.begin(9600);
Serial.println("Serijski port odprt!");digitalWrite(9, HIGH);
pinMode(9, OUTPUT);// Nastavitve ethernet povezave
boolean receiving = false;
Ethernet.begin(mac);
Udp.begin(localPort);
Serial.println("UDP zagnan!");
Serial.println("");
}void loop() {
// put your main code here, to run repeatedly:
// UDP prejemanje/oddajanje
int packetSize = Udp.parsePacket();
if(packetSize) {
Udp.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);
Serial.println(packetBuffer);
if(strcmp(packetBuffer, "mode") == 0) {
if(digitalRead(9) == LOW) {
digitalWrite(9, HIGH);
}
else {
digitalWrite(9, LOW);
}
}
}
}