Receiving UDP data from Arduino

 

 

 

Receiving UDP data from Arduino

 

 

When any packet is received it is keep in burref.

 

So after function who read pakets we need to check is packet received is UDP.

 

Some information:

IP_PROTO_P = HEX 0x17 (DEC 23)

IP_PROTO_UDP_V =  HEX 0x11 (DEC 17)

 

We must check if in buffer possition 23 we have 17

 

Code:

 

    // read packet, handle ping and wait for a tcp packet:
    dat_p=es.ES_packetloop_icmp_tcp(buf,es.ES_enc28j60PacketReceive(BUFFER_SIZE, buf));
    
  
    if (buf[IP_PROTO_P]==IP_PROTO_UDP_V){   // ==     if (buf[23]==17)

     // We have UDP paket received

   }

 

 

 

Exsample UDP packet, buffer positions and values:

 

 

Buffer HEX DEC
position
0 cf 207
1 70 112
2 7c 124
3 e4 228
4 8a 138
5 b8 184
6 0 0
7 26 38
8 18 24
9 f9 249
10 71 113
11 a2 162
12 8 8
13 0 0
14 45 69
15 0 0
16 0 0
17 21 33
18 a6 166
19 eb 235
20 0 0
21 0 0
22 80 128
23 11 17
24 fe 254
25 12 18
26 c0 192
27 a8 168
28 0a 10
29 64 100
30 c0 192
31 a8 168
32 0a 10
33 19 25
34 30 48
35 39 57
36 30 48
37 39 57
38 0 0
39 0d 13
40 70 112
41 2d 45
42 31 49
43 32 50
44 33 51
45 34 52
46 35 53

 

 

 

 

 

 

 

 

Read 3219 times