Arduino sending UDP messages,,,, dont work after 100bytes, wireshark help

hi guys, im new on the forum,,, and i dont like to register only to ask a question, but i was looking around for a long time and i wasnt able to find the answer

this is what i need to do, i need to use an arduino+ethernet shield to measure 1 pin, and if that pin its activated ( lets say a switch ) , to send a UDP message to a specific Ip.
right now, i was able to make it work with this sketch
http://brelovich.com/2011/09/water-level-sensor-arduino-ethernet/

but the packet that i need to send its a Udp packaged captured with WireShark from a specific software, this package its like 120bites and when i recive the package on the wireshark its malformed. Is there any kind of limitation in the packet size that i can send ?

i leave an example of the same process ( and i was able to make it work without any problem ! ) with a package that was only 20 bites
the package its from TouchOSC. Basicaly i caputured the package with wireshark, i save only the data that its selected on the picture that i show from wireshark, and i made a small program with vvvv to convert that to hex. Again, with a package of this size, it works, but with the other package that im sniffing from another software it does not. any idea what im doing wrong ?

if i program the arduino to send just text, it works, but im putting the hex code on the botton of the example.jpg
using udp.write

what could be the problem why i have a corrupted package?

I usually take a look at the code, but I don't see your code. This is from the code in your link.

// buffers for receiving and sending data
//char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,
char ReplyBuffer[21];

If you use ReplyBuffer with more than 20 characters plus the terminating zero, you're overflowing the array.

If you use packetBuffer above, this is the define in EthernetUdp.h

#define UDP_TX_PACKET_MAX_SIZE 24

It overflows at 25.

SurferTim tnks for the replay
i think i found the problem,

first of all this is the code that im using

#include <SPI.h>         // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <EthernetUdp.h>         // UDP library from: bjoern@cs.stanford.edu 12/30/2008


byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 250);       // local ip

unsigned int localPort = 6002;      // local port to listen on, not used on this sketc
IPAddress remote_ip(192, 168, 1, 255);   // remote ip
unsigned int remote_port = 6002;

char  ReplyBuffer[] = { 0x2F, 0x31, 0x2F, 0x66, 0x61, 0x64, 0x65, 0x72, 0x33, 0x00, 0x00, 0x00, 0x2C, 0x66, 0x00, 0x00, 0x3F, 0x20, 0x3E, 0x89 };


EthernetUDP Udp;

void setup() {
  Ethernet.begin(mac,ip);
  Udp.begin(localPort);
}

void loop() {

   
    Udp.beginPacket(remote_ip, remote_port);
   Udp.write(ReplyBuffer);      
       Udp.endPacket(); 
    

  delay(1000);
}

That code its from the same image that i posted with VVVV, basicaly im sending a package from touch osc from an iphone, im capturing the data with wireshark, until here everything its fine,,,
then im converting that data to hex, and putting that into the arduino,
but here is the thing... check how the data came from the arduino back to the computer

im getting only 9 bytes of data, but im sending 20 bytes, so i get the firts 9 and why no the 10th ?
well if i look at the string, the 10th character its 00(in hex) , and acording to the ascci table thats null
http://www.columbia.edu/kermit/ascii.html

so i guess that the arduino enviroment its finishing my sentence there,,,, is there any other format to be able to send those ascci characters from arduino ?

This is a challenge if you plan on sending zero bytes. It will stop at the first zero byte. It transmits a zero terminated string.

    Udp.beginPacket(remote_ip, remote_port);
   Udp.write(ReplyBuffer);      
       Udp.endPacket();

If you want to send zero bytes, you need something like this:

    Udp.beginPacket(remote_ip, remote_port);
   Udp.write(ReplyBuffer,20);      
       Udp.endPacket();

This sends 20 bytes, zeros and all.

mmm im getting this error when i try to compile

the line that was changed its highlited

" Udp.write(ReplyBuffer,20); "

the header of the debug console says "invalid conversion from chart to const uint8_t*

edit

solved :wink:

i need to use unsigned char , tnks a lot :slight_smile:

Arggg!! I forgot about that. You must use unsigned char array or byte array rather than char array for that Udp.write() function.

Or you can type cast it

Udp.write((byte*)ReplyBuffer,20);

Great, im happy that it worked!

last question, im using the shield with the w5100
is there any way to do the same but with the ethernet shield v1.1 ?

On the ENC28J60, I'm not sure. I'm strictly w5100/w5200.