Continuing the discussion from UDP issues and workarounds:
Hi,
Testing the Spark IP/UDP performance I have the same issue.
As far as I can test it, it has something to do with multiple UDP writes in the same UDP session.
The sketch below, with multiple writes (at least 3 but most of the time with 2) and no loop delay, kills the Core immediatelly (blue, green, red, ….) after flashing the code.
Increasing the delay between the UDP write session helps (or randomise the issue?).
However, reducing the UDP write to one with no delays seems to solve the problem.
Note also the a Udp.println(‘1’) generates 3 packets (‘1’+ 0x0a + 0x0d) which is a guaranty to crash the Core!
Please comment on the possible solution.
Robert
/*
Spark UDP write demo sketch
by @rrobinet1 29/08/2014
The remote socket (host IP address and UDP port) and local port have to be adapted
according to the user context.
Typical host configuration is obtained using net cat (nc).
To receive UDP data use the command:
nc -u -l
*/
// Local host socket
unsigned int localPort = 50000;
//Remote host socket
unsigned int remotePort = 55000;
IPAddress remoteIP (192, 168, 0, 100);
//Create UDP instance
UDP Udp;
void setup()
{
// Bind the UDP instance
while(!Udp.begin(localPort)); // Wait for socket binding
}
void loop()
{
// UDP Write to the remote socket
Udp.beginPacket(remoteIP, remotePort);
// Udp.write('1'); // 1st UDP PDU
// Udp.write('2'); // 2nd UDP PDU
// Udp.write('3'); // 3rd UDP PDU
// Udp.write ("The quick brown fox jumps over the lazy dog\r\n"); // A .. long UDP packet
Udp.println('1'); // Println generates 3 UDP packets
Udp.endPacket();
// delay(10);
}