- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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!
Link Copied
0 Replies

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page