Hi,
I try to send some UDP packet from a first Teensy 3.5 with wiz820 eth module to a 2nd Teensy 3.5 with wiz820 eth module and a straight cable between the two.
First : when I send packet from the first Teensy to my computer, packet are sent with the right timing : each 20ms ---> no problem
second: when I send packet from my computer to my second Teensy, Teensy received packet ---> no problem
But when I send packet from the first Teensy to nothing or to the second Teensy, timing are very bad (send packet?? every 2s) and the second teensy never received any packet...
Do you Know, why the first Teensy seems to wait for something? slow down and never send the packet? and try each 2s instead of 20ms?
I try to send some UDP packet from a first Teensy 3.5 with wiz820 eth module to a 2nd Teensy 3.5 with wiz820 eth module and a straight cable between the two.
First : when I send packet from the first Teensy to my computer, packet are sent with the right timing : each 20ms ---> no problem
second: when I send packet from my computer to my second Teensy, Teensy received packet ---> no problem
But when I send packet from the first Teensy to nothing or to the second Teensy, timing are very bad (send packet?? every 2s) and the second teensy never received any packet...
Do you Know, why the first Teensy seems to wait for something? slow down and never send the packet? and try each 2s instead of 20ms?
Code:
#include <Ethernet.h>
#include <EthernetUdp.h>
//FOR ETHERNET:
#define ethRSTpin 9
#define ethCSpin 10
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // MAC and IP controller address
IPAddress ip(192, 168, 1, 178);
unsigned int localPort = 8888; // local port to listen on
EthernetUDP Udp; // An EthernetUDP instance to let us send and receive packets over UDP
elapsedMillis TsincelastUDPOut; // increase as time elapses. will be reseted after each UDP send
int RefreshT = 20; //interval beetwen two UDP send
void setup() {
// set serial com
Serial.begin(9600);
delay(3000);
Serial.println("HELLO");
//Start wiz ethernet module
pinMode(ethRSTpin, OUTPUT);
digitalWrite(ethRSTpin, LOW);
delay(1000);
digitalWrite(ethRSTpin, HIGH);
delay(1000);
Ethernet.init(ethCSpin); // Ethernet.init(pin) to configure the CS pin
Ethernet.begin(mac,ip); // start the Ethernet
delay(500);
// start UDP
Udp.begin(localPort);
Serial.println("End of Ethernet init");
delay(1000);
}
//END OF INIT
void loop() {
if (TsincelastUDPOut >= RefreshT) {
TsincelastUDPOut = TsincelastUDPOut - RefreshT;
Serial.println("send");
char dataOut[11]= "speed test";
Udp.beginPacket("192.168.1.174",8888);
Udp.write((byte *)&dataOut,sizeof dataOut); //Write packet which contains data structure
Udp.endPacket(); //Close Packet and send
}
}
Last edited: