uip_send

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

uip_send

1,333 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hcanova on Sat Nov 26 15:58:01 MST 2011
Hi

I'm using the UIP recently ,and always used the command uip_send alone like:


 uip_send("N",1);
if (uip_rexmit())
{
uip_send("N",1);
}

(this works well)


but I want to do something like the code below,

 uip_send("S",1);if (uip_rexmit()){uip_send("S",1);}
uip_send(buf_dev,sizeof(buf_dev));if (uip_rexmit()){uip_send(buf_dev,sizeof(buf_dev));}
 uip_send("F",1);if (uip_rexmit()){uip_send("F",1);}


using this command in sequence but only the last line works, you can help?

thanks
0 Kudos
Reply
4 Replies

1,244 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hcanova on Mon Nov 28 04:50:05 MST 2011
Hi Rob

I tried to wait the ACK, and works very well, I need to make many modifications in my code but thats ok.:)


thanks a lot:D
0 Kudos
Reply

1,244 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Sun Nov 27 08:46:52 MST 2011

Quote: hcanova
I understand now, I need to wait for the uip_acked () every time I send a packet, however I believe this is bad


No, not bad at all - this is good.
You want to wait for the confirmation that the packet has been received correctly by the other end (ACK) or not (NACK). The example given only handles to ACK situation, you need to decide yourself what to do when a packet is NACKed.
Zero might have some ideas on this, I have not used UIP myself (my 1769 board is due to arrive next week :D).

If you want you can always create your own function that sends the packet only after the previous packet has been acknowledged.

Rob
0 Kudos
Reply

1,244 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hcanova on Sun Nov 27 05:34:00 MST 2011

Quote: Rob65
After downloading Contiki 2.5 (available here) which contains a.o. the uip stack, I found the following in the uip-doc.txt:

So it seems your application is behaving correctly.

You need to wait until your uip_send() has been acknowledged before sending any new data:

struct example2_state {
   enum {WELCOME_SENT, WELCOME_ACKED} state;
};

void example2_init(void) {
   uip_listen(HTONS(2345));
}

void example2_app(void) {
   struct example2_state *s;

   s = (struct example2_state *)uip_conn->appstate;
   
   if(uip_connected()) {
      s->state = WELCOME_SENT;
      uip_send("Welcome!\n", 9);
      return;
   } 

   if(uip_acked() && s->state == WELCOME_SENT) {
      s->state = WELCOME_ACKED;
   }

   if(uip_newdata()) {
      uip_send("ok\n", 3);
   }

   if(uip_rexmit()) {
      switch(s->state) {
      case WELCOME_SENT:
         uip_send("Welcome!\n", 9);
         break;
      case WELCOME_ACKED:
         uip_send("ok\n", 3);
         break;
      }
   }
}


Too bad there is no HTML documentation in the contiki-2.5.zip file, I'm now checking to see if the InstantContiki2.5.zip does contain documentation but the .zip file is about 1.9 GB :eek:




Hi Rob

thanks for the reply, I understand now, I need to wait for the uip_acked () every time I send a packet, however I believe this is bad because the code had been too long, especially if I include everything in rexmit,and if I need to create on state for each different packed send the code wil increase ,but  I'll try to work this way.

Thanks Again
0 Kudos
Reply

1,244 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Sun Nov 27 02:39:32 MST 2011
After downloading Contiki 2.5 (available here) which contains a.o. the uip stack, I found the following in the uip-doc.txt:


Quote:
The application can send only one chunk of data at a time on a
connection and it is not possible to call uip_send() more than once
per application invocation; only the data from the last call will be
sent.

So it seems your application is behaving correctly.

You need to wait until your uip_send() has been acknowledged before sending any new data:

struct example2_state {
   enum {WELCOME_SENT, WELCOME_ACKED} state;
};

void example2_init(void) {
   uip_listen(HTONS(2345));
}

void example2_app(void) {
   struct example2_state *s;

   s = (struct example2_state *)uip_conn->appstate;
   
   if(uip_connected()) {
      s->state = WELCOME_SENT;
      uip_send("Welcome!\n", 9);
      return;
   } 

   if(uip_acked() && s->state == WELCOME_SENT) {
      s->state = WELCOME_ACKED;
   }

   if(uip_newdata()) {
      uip_send("ok\n", 3);
   }

   if(uip_rexmit()) {
      switch(s->state) {
      case WELCOME_SENT:
         uip_send("Welcome!\n", 9);
         break;
      case WELCOME_ACKED:
         uip_send("ok\n", 3);
         break;
      }
   }
}


Too bad there is no HTML documentation in the contiki-2.5.zip file, I'm now checking to see if the InstantContiki2.5.zip does contain documentation but the .zip file is about 1.9 GB :eek:
0 Kudos
Reply