Hello,
I'm attempting to transmit/receive data with an arduino over an ethernet cable plugged directly into my computer. I've gotten to the point where the arduino is definitely receiving data from my computer, but for an unknown reason, never responds. I downloaded wireshark to attempt to diagnose this. At the time the arduino is cycling through the Udp.write area of code, it spams "ARP Announcement for 169.254.245.1" 10 times or so. No UDP protocol messages originating from the arduino are recorded by wireshark. UDP protocol messages originating from my computer are recorded by wireshark.
I'm using an arduino uno with the ethernet W5100 shield.
I'm afraid my networking experience is essentially zero and have no idea what th ARP announcement means or if it's an issue. But I can't find any other issue.
Arduino Code
#include <Ethernet.h>
#include <EthernetUdp.h>
byte mac[] = { 0x34, 0x29, 0x8f, 0x7a, 0x7f, 0x3b}; //Assign a mac address
IPAddress ip(169,254,245,1); //arduino IP
char ReplyBuffer[] = "response";
EthernetServer server(80);
unsigned int localPort = 5000;
char packetBuffer[UDP_TX_PACKET_MAX_SIZE];
String datReq;
int packetSize;
EthernetUDP Udp;
void setup() {
Serial.begin(9600);
Ethernet.begin(mac, ip);
Udp.begin(localPort);
Serial.print("test");
delay(1500);
}
void loop() {
packetSize = Udp.parsePacket();
if(packetSize>0){
Udp.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);
String datReq(packetBuffer);
Serial.println(datReq);
if (datReq =="Blue") { //See if blue was requested
Serial.println("data requested...");
Serial.println(Udp.remoteIP());
Serial.println(Udp.remotePort());
Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
Udp.write(ReplyBuffer);
Udp.endPacket(); //Packet has been sent
Serial.println("packet should be sent");
}
}
memset(packetBuffer, 0, UDP_TX_PACKET_MAX_SIZE);
}
Python Code
from socket import *
import time
address = ( '169.254.245.1', 5000) #match arduino IP + port
client_socket = socket(AF_INET, SOCK_DGRAM)
print(client_socket)
client_socket.settimeout(5) #wait up to 5 seconds
while(1):
data = "Blue" #response should be sent
client_socket.sendto(data.encode(), address)
print(client_socket)
try:
rec_data, addr = client_socket.recvfrom(2048)
print(rec_data)
except:
print("No message received")
print(client_socket)
pass
time.sleep(.1)