Renamed the Rime 'ping' command to 'rime-ping' to differentiate it from the IP ping command

This commit is contained in:
adamdunkels 2009-03-05 23:54:14 +00:00
parent a3daf1d3cc
commit 482de817e0

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: shell-rime-ping.c,v 1.5 2009/02/24 21:28:43 adamdunkels Exp $ * $Id: shell-rime-ping.c,v 1.6 2009/03/05 23:54:14 adamdunkels Exp $
*/ */
/** /**
@ -47,7 +47,7 @@
int snprintf(char *str, size_t size, const char *format, ...); int snprintf(char *str, size_t size, const char *format, ...);
#endif /* HAVE_SNPRINTF */ #endif /* HAVE_SNPRINTF */
struct ping_msg { struct rime_ping_msg {
rtimer_clock_t pingtime; rtimer_clock_t pingtime;
rtimer_clock_t pongtime; rtimer_clock_t pongtime;
}; };
@ -56,18 +56,18 @@ static struct mesh_conn mesh;
static int waiting_for_pong = 0; static int waiting_for_pong = 0;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
PROCESS(shell_ping_process, "ping"); PROCESS(shell_rime_ping_process, "rime-ping");
SHELL_COMMAND(ping_command, SHELL_COMMAND(rime_ping_command,
"ping", "rime-ping",
"ping <node addr>: send a message to a specific node and get a reply", "rime-ping <node addr>: send a message to a specific node and get a reply",
&shell_ping_process); &shell_rime_ping_process);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_ping_process, ev, data) PROCESS_THREAD(shell_rime_ping_process, ev, data)
{ {
static int i; static int i;
static struct etimer timeout, periodic; static struct etimer timeout, periodic;
static rimeaddr_t receiver; static rimeaddr_t receiver;
struct ping_msg *ping; struct rime_ping_msg *ping;
const char *nextptr; const char *nextptr;
char buf[32]; char buf[32];
@ -75,7 +75,7 @@ PROCESS_THREAD(shell_ping_process, ev, data)
receiver.u8[0] = shell_strtolong(data, &nextptr); receiver.u8[0] = shell_strtolong(data, &nextptr);
if(nextptr == data || *nextptr != '.') { if(nextptr == data || *nextptr != '.') {
shell_output_str(&ping_command, shell_output_str(&rime_ping_command,
"ping <receiver>: recevier must be specified", ""); "ping <receiver>: recevier must be specified", "");
PROCESS_EXIT(); PROCESS_EXIT();
} }
@ -83,12 +83,12 @@ PROCESS_THREAD(shell_ping_process, ev, data)
receiver.u8[1] = shell_strtolong(nextptr, &nextptr); receiver.u8[1] = shell_strtolong(nextptr, &nextptr);
snprintf(buf, sizeof(buf), "%d.%d", receiver.u8[0], receiver.u8[1]); snprintf(buf, sizeof(buf), "%d.%d", receiver.u8[0], receiver.u8[1]);
shell_output_str(&ping_command, "Sending 4 pings to ", buf); shell_output_str(&rime_ping_command, "Sending 4 pings to ", buf);
for(i = 0; i < 4; ++i) { for(i = 0; i < 4; ++i) {
rimebuf_clear(); rimebuf_clear();
ping = rimebuf_dataptr(); ping = rimebuf_dataptr();
rimebuf_set_datalen(sizeof(struct ping_msg)); rimebuf_set_datalen(sizeof(struct rime_ping_msg));
#if TIMESYNCH_CONF_ENABLED #if TIMESYNCH_CONF_ENABLED
ping->pingtime = timesynch_time(); ping->pingtime = timesynch_time();
#else #else
@ -104,7 +104,7 @@ PROCESS_THREAD(shell_ping_process, ev, data)
if(waiting_for_pong == 0) { if(waiting_for_pong == 0) {
PROCESS_WAIT_UNTIL(etimer_expired(&periodic)); PROCESS_WAIT_UNTIL(etimer_expired(&periodic));
} else { } else {
shell_output_str(&ping_command, shell_output_str(&rime_ping_command,
"Timed out", ""); "Timed out", "");
} }
waiting_for_pong = 0; waiting_for_pong = 0;
@ -124,7 +124,7 @@ sent_mesh(struct mesh_conn *c)
static void static void
recv_mesh(struct mesh_conn *c, rimeaddr_t *from, u8_t hops) recv_mesh(struct mesh_conn *c, rimeaddr_t *from, u8_t hops)
{ {
struct ping_msg *ping; struct rime_ping_msg *ping;
char buf[64]; char buf[64];
rtimer_clock_t pingrecvtime; rtimer_clock_t pingrecvtime;
@ -149,10 +149,10 @@ recv_mesh(struct mesh_conn *c, rimeaddr_t *from, u8_t hops)
(1000L * (pingrecvtime - ping->pongtime)) / RTIMER_ARCH_SECOND, (1000L * (pingrecvtime - ping->pongtime)) / RTIMER_ARCH_SECOND,
hops); hops);
shell_output_str(&ping_command, shell_output_str(&rime_ping_command,
"Pong recived; rtt ", buf); "Pong recived; rtt ", buf);
waiting_for_pong = 0; waiting_for_pong = 0;
process_post(&shell_ping_process, PROCESS_EVENT_CONTINUE, NULL); process_post(&shell_rime_ping_process, PROCESS_EVENT_CONTINUE, NULL);
} }
} }
CC_CONST_FUNCTION static struct mesh_callbacks mesh_callbacks = { recv_mesh, CC_CONST_FUNCTION static struct mesh_callbacks mesh_callbacks = { recv_mesh,
@ -164,6 +164,6 @@ shell_rime_ping_init(void)
{ {
mesh_open(&mesh, SHELL_RIME_CHANNEL_PING, &mesh_callbacks); mesh_open(&mesh, SHELL_RIME_CHANNEL_PING, &mesh_callbacks);
shell_register_command(&ping_command); shell_register_command(&rime_ping_command);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/