Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
12748 Discussions

UDP Tx partial fail when using Lwip within uC/OS

Altera_Forum
Honored Contributor II
1,151 Views

hi all! 

 

I was trying to send a UDP packet using conn_send(). However, I find that when I use netbuf_ref() to send data which the ptr points to, what I got in the reciever side was not the data ptr point to. But is was OK if I'm using netbuf_alloc() to send some immediate data. 

 

Another thing that I can't understand is whichever buffer or data structure the ptr points to, when using netbuf_ref(), the data sent on the physical wire is always the same! 

 

Here's my code: 

 

void udp_task() 

struct netconn *conn; 

struct netbuf* buf; 

struct ip_addr udpDestIpAddr,udpLocalIpAddr; 

u8_t test[10]; 

int i; 

u8_t *data; 

void *ptr; 

 

for(i=0;i<10;i++){ 

test=i; 

ptr = test; 

 

conn = netconn_new(netconn_udp); 

ip4_addr(&udpdestipaddr, 10, 1, 1, 15); 

ip4_addr(&udplocalipaddr, 10, 1,1, 19); 

 

printf("udp_init\n"); 

netconn_bind(conn,&udplocalipaddr,38); 

netconn_connect(conn,&udpdestipaddr,10); 

 

while(1) 

buf = netbuf_new(); 

data = netbuf_alloc(buf,10); 

for(i=0;i<10;i++) 

data=i; 

netconn_send(conn, buf); 

//""this command function just the way it is, and I recieve exactly what I sent "" 

 

 

netbuf_ref(buf,&test[0],10); 

netconn_send(conn, buf); 

//""here is where everything goes wrong, I recieved the wrong data"" 

 

netbuf_ref(buf,&test[0]+10,10); 

netconn_send(conn, buf); 

/*""I recieved exactly the same fault data just like above, it seems the pointer has *no effect of determining which data should be sent"" 

*/ 

 

OSTimeDlyHMSM(0, 0, 3, 0); 

printf("udp sent "); 

 

netbuf_delete(buf); 

 

Thanks in advance!
0 Kudos
0 Replies
Reply