From 404b931062d845caf3b167ccafc4648b0b5aba68 Mon Sep 17 00:00:00 2001 From: laranjeiro Date: Thu, 28 Aug 2008 08:32:03 +0000 Subject: cp2/beacon: Replace the circular buffer by a chained beacon list. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@2781 017c9cb6-072f-447c-8318-d5b54f68fe89 --- cesar/cp2/beacon/doc/beacons.xmi | 53 ++++++++++++++++++++------------------ cesar/cp2/beacon/inc/beacon.h | 9 ++----- cesar/cp2/beacon/src/beacon.c | 21 +++++++++------ cesar/cp2/beacon/test/src/beacon.c | 7 +++-- 4 files changed, 46 insertions(+), 44 deletions(-) (limited to 'cesar/cp2') diff --git a/cesar/cp2/beacon/doc/beacons.xmi b/cesar/cp2/beacon/doc/beacons.xmi index d51d0da83f..be471344f3 100644 --- a/cesar/cp2/beacon/doc/beacons.xmi +++ b/cesar/cp2/beacon/doc/beacons.xmi @@ -1,5 +1,5 @@ - + umbrello uml modeller http://uml.sf.net @@ -13,6 +13,7 @@ + @@ -72,7 +73,8 @@ - + + @@ -386,7 +388,7 @@ If next tei is 0. the CCo shall send a discover beacon." isSpecification="false" - + @@ -429,46 +431,46 @@ If next tei is 0. the CCo shall send a discover beacon." isSpecification="false" - + + + + + + + + + + + + + + - + - + - + - + - + - + - - - - - - - - - - - - - - + @@ -494,7 +496,7 @@ If next tei is 0. the CCo shall send a discover beacon." isSpecification="false" - + @@ -576,6 +578,7 @@ If next tei is 0. the CCo shall send a discover beacon." isSpecification="false" + diff --git a/cesar/cp2/beacon/inc/beacon.h b/cesar/cp2/beacon/inc/beacon.h index 0d295395c8..2c16994d8e 100644 --- a/cesar/cp2/beacon/inc/beacon.h +++ b/cesar/cp2/beacon/inc/beacon.h @@ -28,19 +28,14 @@ #include "cp2/beacon/inc/common.h" #include "cp2/beacon/inc/beacon_work.h" -/** Define the size of the circular buffer. */ -#define CP_BEACON_LIST_SIZE 10 - /** * Beacon module. Use to generate and read a beacon. */ struct cp_beacon_t { /** circular list manager for the beacon reception. */ - circular_buffer_t list; - - /** Beacon list for the list manager. */ - cp_beacon_desc_t *beacon_list[CP_BEACON_LIST_SIZE]; + cp_beacon_desc_t *list; + cp_beacon_desc_t *list_tail; /** Bentry manager. */ cp_beacon_bentry_mgr_t bentry; diff --git a/cesar/cp2/beacon/src/beacon.c b/cesar/cp2/beacon/src/beacon.c index 8659816ab4..aafcae7c17 100644 --- a/cesar/cp2/beacon/src/beacon.c +++ b/cesar/cp2/beacon/src/beacon.c @@ -31,7 +31,6 @@ #include "mac/common/timings.h" #include "mac/common/ntb.h" - #include "cp2/beacon/inc/beacon.h" #include "cp2/beacon/inc/beacon_work.h" #include "cp2/beacon/inc/bentry_msg.h" @@ -66,10 +65,6 @@ cp_beacon_init (cp_t *ctx) &ctx->beacon.alarm_handle, &ctx->beacon.alarm); - // Initialise the list. - circular_buffer_init (&ctx->beacon.list, - ctx->beacon.beacon_list, CP_BEACON_LIST_SIZE); - // Initialise the central beacon common data. cp_beacon_common_init (&ctx->beacon.central); cp_beacon_common_init (&ctx->beacon.discover); @@ -101,11 +96,13 @@ cp_beacon_uninit (cp_t *ctx) cyg_counter_delete (ctx->beacon.ecos_timer_handle); // Release all the beacon in the context. - while ((beacon = circular_buffer_get(&ctx->beacon.list))) + while ((beacon = ctx->beacon.list)) { + ctx->beacon.list = ctx->beacon.list->next; // Release the current one. blk_release_desc ( (blk_t *) beacon); } + ctx->beacon.list_tail = NULL; // Uninitialise the central beacon common data. cp_beacon_common_uninit (&ctx->beacon.central, ctx); @@ -278,7 +275,14 @@ cp_beacon_receive (cp_t *ctx, cp_beacon_desc_t * beacon) dbg_assert (ctx); dbg_assert (beacon); - circular_buffer_add (&ctx->beacon.list, beacon); + beacon->next = NULL; + if (ctx->beacon.list) + ctx->beacon.list_tail = beacon; + else + { + ctx->beacon.list = beacon; + ctx->beacon.list_tail = beacon; + } } /** @@ -557,7 +561,8 @@ cp_beacon_get_and_process_beacon (cp_t *ctx) dbg_assert (ctx); - beacon = circular_buffer_get (&ctx->beacon.list); + beacon = ctx->beacon.list; + ctx->beacon.list = ctx->beacon.list->next; dbg_check (beacon); // Read the variant fields of the beacon. diff --git a/cesar/cp2/beacon/test/src/beacon.c b/cesar/cp2/beacon/test/src/beacon.c index 74f4f700da..c9cdd1f99f 100644 --- a/cesar/cp2/beacon/test/src/beacon.c +++ b/cesar/cp2/beacon/test/src/beacon.c @@ -34,8 +34,6 @@ test_case_beacon_common_init_uninit (test_t test, cp_t *cp) { test_begin (test, "verify") { - test_fail_if (circular_buffer_peek(&cp->beacon.list) != NULL, - "Beacon list shall be null"); test_fail_if (cp->beacon.event_cb != NULL, "Event call back shall be null"); test_fail_if (cp->beacon.event_user_data != NULL, @@ -125,8 +123,9 @@ test_case_beacon_uninit (test_t test) cp.mac_store = mac_store_init (); // Add a beacon. - circular_buffer_add (&cp.beacon.list, blk_alloc_desc ()); - circular_buffer_add (&cp.beacon.list, blk_alloc_desc ()); + cp.beacon.list = (cp_beacon_desc_t *) blk_alloc_desc (); + cp.beacon.list->next =(cp_beacon_desc_t *) blk_alloc_desc (); + cp.beacon.list->next->next =(cp_beacon_desc_t *) NULL; // Add a central beacon. cp.beacon.central.mfs = mac_store_mfs_add_tx (cp.mac_store, true, false, -- cgit v1.2.3