AKJ
1
Hallo,
thanks for trying to help.
Project: Sending some UDP packets to a certain port and Address.
Problem: The Packets are not sent to the address, i assign them to.
Code:
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,137,5);
IPAddress udpip(255,255,255,255);
unsigned int localPort = 12345; // local port to listen on
unsigned int remoteip = 25001;
// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;
void setup() {
// start the Ethernet and UDP:
Ethernet.begin(mac,ip);
Udp.begin(localPort);
}
void loop() {
Udp.beginPacket(udpip, remoteip);
Udp.write("hello");
Udp.write("Wert");
Udp.endPacket();
}
Hardware: Arduino Uno Rev. 3 , Ethernet Shield W550, Windows 8.1
This looks strange:
Udp.beginPacket(udpip, remoteip);
You should be passing an IP and a port here.
AKJ
3
Wildid,
yes they are declared at the beginning of the code.
AKJ
4
More details:
With the code above, the packets are not even sent at a continues amount and stop after some time.
But with this code (Adding '255.255.255.255' in the Upd.beginPacket) :
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,137,5);
IPAddress udpip(255,255,255,255);
unsigned int localPort = 12345; // local port to listen on
unsigned int remoteip = 25001;
// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;
void setup() {
// start the Ethernet and UDP:
Ethernet.begin(mac,ip);
Udp.begin(localPort);
}
void loop() {
Udp.beginPacket('255.255.255.255', remoteip);
Udp.write("hello");
Udp.write("Wert");
Udp.endPacket();
}
i get really good UDP messages sent, but it still does not send it to the right address.
AKJ
5
Andddd,
i solved my issue. I was looking at the wrong connection feed.
Thanks