Character Arrays

#include <SPI.h>        
#include <Ethernet.h>
#include <EthernetUdp.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {  
  0x90, 0xA2, 0xAD, 0x10, 0xF2, 0xB9 };
IPAddress ip(1, 1, 1, 49);

unsigned int localPort = 8888;      // local port to listen on

// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;

char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,

void setup() {
  // start the Ethernet and UDP:
  Ethernet.begin(mac,ip);
  Udp.begin(localPort);

}

void loop() {

  int packetSize = Udp.parsePacket();
  if(packetSize)
  {
    Serial.print("Received packet of size ");
    Serial.println(packetSize);
    Serial.print("From ");
    IPAddress remote = Udp.remoteIP();
    for (int i =0; i < 4; i++)
    {
      Serial.print(remote[i], DEC);
      if (i < 3)
      {
        Serial.print(".");
      }
    }
    Serial.print(", port ");
    Serial.println(Udp.remotePort());

    // read the packet into packetBufffer
    Udp.read(packetBuffer,UDP_TX_PACKET_MAX_SIZE);
    Serial.println("Contents:");
    Serial.println(packetBuffer);
 }
}

What is the deal with the character packetBuffer array? I get that is is essentially 24, but why in the Udp.read line at the bottom is it referenced with a comma between the packetBuffer and UDP_… instead of brackets.

I basically just need an explanation on the UDP.read line.

Thanks

but why in the Udp.read line at the bottom is it referenced with a comma between the packetBuffer and UDP_... instead of brackets.

Because you need to Udp.read how many characters to expect / it can use in the buffer you provided.

What is the deal with the character packetBuffer array? I get that is is essentially 24, but why in the Udp.read line at the bottom is it referenced with a comma between the packetBuffer and UDP_… instead of brackets.

I basically just need an explanation on the UDP.read line.

Thanks

That notation provides the function with a pointer to the buffer as its first argument and the maximum number of characters as its second.

Let's say UDP.read has the parameters (x, y).

I want x to be 1 and y to be 0.

The lines say

char 1[0]
UDP.read(1, 0)

Is this correct?

Today at 17:52:03
Let's say UDP.read has the parameters (x, y).

Then the function would expect x to be an array of chars and for 0 bytes to be read. Does that any sense ?

I want x to be 1 and y to be 0.

Why ?