diff options
author | Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com> | 2016-02-02 11:06:21 +0200 |
---|---|---|
committer | Anas Nashif <anas.nashif@intel.com> | 2016-02-05 20:25:32 -0500 |
commit | 838961af9a4ac234927907b8269d551947cd1d39 (patch) | |
tree | 0745bebde7bda4e8dadb16e529bb96d04f273ce4 /samples | |
parent | 94210770fdf1cbefb6a01be3672184a5708b733b (diff) |
net: apps: Modify echo-client to send data only after reception
Modify echo-client to send packet after packet received from
server and wait unlimited ticks. Current behaviour flood messages
to server irrespective of reception at server end. Modified
behavior only for nanokernel at the moment.
Change-Id: I6aa20c5b9fc9d6d1cf8f996e90735f5d2b986e5a
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Diffstat (limited to 'samples')
-rw-r--r-- | samples/net/echo_client/src/echo-client.c | 52 |
1 files changed, 23 insertions, 29 deletions
diff --git a/samples/net/echo_client/src/echo-client.c b/samples/net/echo_client/src/echo-client.c index c7ab301d7..75999d89b 100644 --- a/samples/net/echo_client/src/echo-client.c +++ b/samples/net/echo_client/src/echo-client.c @@ -164,8 +164,12 @@ static inline void reverse(unsigned char *buf, int len) } } +#if 0 #define WAIT_TIME 1 #define WAIT_TICKS (WAIT_TIME * sys_clock_ticks_per_sec) +#else +#define WAIT_TICKS TICKS_UNLIMITED +#endif static inline bool send_packet(const char *name, struct net_context *ctx, @@ -413,40 +417,31 @@ void taskB(void) #define STACKSIZE 2000 -static char fiberStack_sending[STACKSIZE]; static char fiberStack_receiving[STACKSIZE]; -/* The other fiber is sending and the other one is receiving. */ void fiber_sending(void) { - struct nano_timer timer; - uint32_t data[2] = {0, 0}; - bool send_unicast = true; - - nano_timer_init(&timer, data); + static bool send_unicast = true; - while (1) { - PRINT("%s: Sending packet\n", __func__); + PRINT("%s: Sending packet\n", __func__); - expecting = sys_rand32_get() % ipsum_len; + expecting = sys_rand32_get() % ipsum_len; - if (send_unicast) { - if (send_packet(__func__, unicast, ipsum_len, - expecting)) { - PRINT("Unicast sending %d bytes FAIL\n", - ipsum_len - expecting); - } - } else { - if (send_packet(__func__, multicast, ipsum_len, - expecting)) { - PRINT("Multicast sending %d bytes FAIL\n", - ipsum_len - expecting); - } + if (send_unicast) { + if (send_packet(__func__, unicast, ipsum_len, + expecting)) { + PRINT("Unicast sending %d bytes FAIL\n", + ipsum_len - expecting); + } + } else { + if (send_packet(__func__, multicast, ipsum_len, + expecting)) { + PRINT("Multicast sending %d bytes FAIL\n", + ipsum_len - expecting); } - - send_unicast = !send_unicast; - fiber_sleep(10); } + + send_unicast = !send_unicast; } void fiber_receiving(void) @@ -456,6 +451,8 @@ void fiber_receiving(void) nano_timer_init(&timer, data); + fiber_sending(); + while (1) { PRINT("%s: Waiting packet\n", __func__); @@ -465,7 +462,7 @@ void fiber_receiving(void) ipsum_len - expecting); } - fiber_sleep(10); + fiber_sending(); } } @@ -482,9 +479,6 @@ void main(void) return; } - task_fiber_start(&fiberStack_sending[0], STACKSIZE, - (nano_fiber_entry_t)fiber_sending, 0, 0, 7, 0); - task_fiber_start(&fiberStack_receiving[0], STACKSIZE, (nano_fiber_entry_t)fiber_receiving, 0, 0, 7, 0); } |