grease_lighting
Well-known member
Folks, please bear with me. I don't have the <vocabulary> to discuss this, nor do I want to wade thru verbage detailing datagrams & link layers.
I'm having a difficult time understanding UDP communications. I have a project that uses a Teensy 3.0 (yes) and a REV 1 arduino ethernet interface that uses the W5100. My mental model is similar to Serial Port communications where the Tx and Rx lines are connected together and used as required. Which may be where some of my problem is. As far as control of the w5100 goes, I believe the SS line is like a chip select that enables the w5100 to listen & talk over the SPI interface and disables the w5100 SPI interface when it is inactive (high).
When I send data out over UDP, it appears pretty straight forward.
But, what is going on on the receive side? Is the receiver, like my Serial Port model, always connected to the network and always receiving & buffering the packets so it catches them all and only picks out the packets destined for the UDP port ? How do I get UDP to wait for data like tucking Serial.Read() into a while-loop?
I'm having a difficult time understanding UDP communications. I have a project that uses a Teensy 3.0 (yes) and a REV 1 arduino ethernet interface that uses the W5100. My mental model is similar to Serial Port communications where the Tx and Rx lines are connected together and used as required. Which may be where some of my problem is. As far as control of the w5100 goes, I believe the SS line is like a chip select that enables the w5100 to listen & talk over the SPI interface and disables the w5100 SPI interface when it is inactive (high).
When I send data out over UDP, it appears pretty straight forward.
Code:
Serial.println("udp.begin");
Serial.println(tmp);
if ( strlen(tmp) > 0 ) { // do not send empty messages
p1 = Udp.beginPacket(dcs100IP, dcsPort); // send only 1 - time
Udp.write(tmp); // This gets sent
p2 = Udp.endPacket(); // send & get status
Serial.print("Send Packet Status: "); // packet send status 1 == OK 0 == error (any)
if (p2 == 0) {Serial.println("Fail.");}
if (p2 == 1) {Serial.println("Success.");}
} else {Serial.println("- BYPASSED - ");}
But, what is going on on the receive side? Is the receiver, like my Serial Port model, always connected to the network and always receiving & buffering the packets so it catches them all and only picks out the packets destined for the UDP port ? How do I get UDP to wait for data like tucking Serial.Read() into a while-loop?