bugfix: control messages were lost due to lack of buffers; wait for buffer before sending

This commit is contained in:
Fredrik Osterlind 2012-05-30 18:01:04 +02:00
parent 076c208b72
commit 10064dbdd9

View file

@ -450,7 +450,7 @@ recv_ctrl(struct runicast_conn *c, const rimeaddr_t *from, uint8_t seqno)
const static struct runicast_callbacks runicast_callbacks =
{ recv_ctrl, sent_ctrl, timedout_ctrl };
/*---------------------------------------------------------------------------*/
static void
static int
send_ctrl_command(const rimeaddr_t *to, uint8_t command)
{
struct ctrl_msg *msg;
@ -458,7 +458,7 @@ send_ctrl_command(const rimeaddr_t *to, uint8_t command)
packetbuf_set_datalen(sizeof(struct ctrl_msg));
msg = packetbuf_dataptr();
msg->command = command;
runicast_send(&ctrl, to, MAX_RETRIES);
return runicast_send(&ctrl, to, MAX_RETRIES);
}
/*---------------------------------------------------------------------------*/
static void
@ -589,7 +589,9 @@ PROCESS_THREAD(shell_netperf_process, ev, data)
shell_output_str(&netperf_command, "-------- Broadcast --------", "");
shell_output_str(&netperf_command, "Contacting ", recvstr);
send_ctrl_command(&receiver, CTRL_COMMAND_CLEAR);
while(!send_ctrl_command(&receiver, CTRL_COMMAND_CLEAR)) {
PROCESS_PAUSE();
}
PROCESS_YIELD_UNTIL(ev == CONTINUE_EVENT);
shell_output_str(&netperf_command, "Measuring broadcast performance to ", recvstr);
@ -604,7 +606,9 @@ PROCESS_THREAD(shell_netperf_process, ev, data)
}
shell_output_str(&netperf_command, "Requesting statistics from ", recvstr);
send_ctrl_command(&receiver, CTRL_COMMAND_STATS);
while(!send_ctrl_command(&receiver, CTRL_COMMAND_STATS)) {
PROCESS_PAUSE();
}
PROCESS_YIELD_UNTIL(ev == CONTINUE_EVENT);
/* Wait for reply */
@ -619,7 +623,9 @@ PROCESS_THREAD(shell_netperf_process, ev, data)
shell_output_str(&netperf_command, "-------- Unicast one-way --------", "");
shell_output_str(&netperf_command, "Contacting ", recvstr);
send_ctrl_command(&receiver, CTRL_COMMAND_CLEAR);
while(!send_ctrl_command(&receiver, CTRL_COMMAND_CLEAR)) {
PROCESS_PAUSE();
}
PROCESS_YIELD_UNTIL(ev == CONTINUE_EVENT);
shell_output_str(&netperf_command, "Measuring unicast performance to ", recvstr);
@ -635,7 +641,9 @@ PROCESS_THREAD(shell_netperf_process, ev, data)
}
shell_output_str(&netperf_command, "Requesting statistics from ", recvstr);
send_ctrl_command(&receiver, CTRL_COMMAND_STATS);
while(!send_ctrl_command(&receiver, CTRL_COMMAND_STATS)) {
PROCESS_PAUSE();
}
PROCESS_YIELD_UNTIL(ev == CONTINUE_EVENT);
/* Wait for reply */
@ -649,7 +657,9 @@ PROCESS_THREAD(shell_netperf_process, ev, data)
shell_output_str(&netperf_command, "-------- Unicast ping-pong--------", "");
shell_output_str(&netperf_command, "Contacting ", recvstr);
send_ctrl_command(&receiver, CTRL_COMMAND_CLEAR);
while(!send_ctrl_command(&receiver, CTRL_COMMAND_CLEAR)) {
PROCESS_PAUSE();
}
PROCESS_YIELD_UNTIL(ev == CONTINUE_EVENT);
shell_output_str(&netperf_command, "Measuring two-way unicast performance to ", recvstr);
@ -667,7 +677,9 @@ PROCESS_THREAD(shell_netperf_process, ev, data)
}
shell_output_str(&netperf_command, "Requesting statistics from ", recvstr);
send_ctrl_command(&receiver, CTRL_COMMAND_STATS);
while(!send_ctrl_command(&receiver, CTRL_COMMAND_STATS)) {
PROCESS_PAUSE();
}
PROCESS_YIELD_UNTIL(ev == CONTINUE_EVENT);
/* Wait for reply */
@ -681,7 +693,9 @@ PROCESS_THREAD(shell_netperf_process, ev, data)
shell_output_str(&netperf_command, "-------- Unicast stream ping-pong--------", "");
shell_output_str(&netperf_command, "Contacting ", recvstr);
send_ctrl_command(&receiver, CTRL_COMMAND_CLEAR);
while(!send_ctrl_command(&receiver, CTRL_COMMAND_CLEAR)) {
PROCESS_PAUSE();
}
PROCESS_YIELD_UNTIL(ev == CONTINUE_EVENT);
shell_output_str(&netperf_command, "Measuring two-way unicast stream performance to ", recvstr);
@ -698,7 +712,9 @@ PROCESS_THREAD(shell_netperf_process, ev, data)
}
shell_output_str(&netperf_command, "Requesting statistics from ", recvstr);
send_ctrl_command(&receiver, CTRL_COMMAND_STATS);
while(!send_ctrl_command(&receiver, CTRL_COMMAND_STATS)) {
PROCESS_PAUSE();
}
PROCESS_YIELD_UNTIL(ev == CONTINUE_EVENT);
/* Wait for reply */