summaryrefslogtreecommitdiff
path: root/cesar/hal/phy/maximus
diff options
context:
space:
mode:
authorburet2009-02-11 11:53:13 +0000
committerburet2009-02-11 11:53:13 +0000
commit1fde2606a973213684613200ed2e5b25276537af (patch)
tree761b8eda5341583b02780bfb576f8145b7c7c496 /cesar/hal/phy/maximus
parent3e36f7fa11af25ff861c2799bd876c1c0db3b52d (diff)
[maximus] add a debug function to display hal phy medium state
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@3959 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/hal/phy/maximus')
-rw-r--r--cesar/hal/phy/maximus/inc/maximus_phy_ctrl.h10
-rw-r--r--cesar/hal/phy/maximus/inc/maximus_phy_ctx.h3
-rw-r--r--cesar/hal/phy/maximus/src/maximus_phy_access.c3
-rw-r--r--cesar/hal/phy/maximus/src/maximus_phy_ctrl.c59
-rw-r--r--cesar/hal/phy/maximus/src/maximus_phy_ctrl_cb.c9
-rw-r--r--cesar/hal/phy/maximus/test/src/test_phy_ctrl.c54
6 files changed, 131 insertions, 7 deletions
diff --git a/cesar/hal/phy/maximus/inc/maximus_phy_ctrl.h b/cesar/hal/phy/maximus/inc/maximus_phy_ctrl.h
index c51bb6e6f5..c7cc92c85b 100644
--- a/cesar/hal/phy/maximus/inc/maximus_phy_ctrl.h
+++ b/cesar/hal/phy/maximus/inc/maximus_phy_ctrl.h
@@ -18,6 +18,16 @@
#include "host/fwd.h"
/**
+ * Used to display medium state.
+ * \param ctx current phy context
+ * \return a string describing the Maximus PHY medium state if ok,
+ * NULL if it fails with errno =
+ * - EINVAL if ctx is NULL, or if ctx->access.medium_state is out-of-range
+ */
+const char *
+maximus_phy_get_medium_state(phy_t *ctx);
+
+/**
* Fill a blank phy header
* \param ctx current phy context
* \param msg pointer to sci message to fill header
diff --git a/cesar/hal/phy/maximus/inc/maximus_phy_ctx.h b/cesar/hal/phy/maximus/inc/maximus_phy_ctx.h
index 4e60191472..5ef700cf44 100644
--- a/cesar/hal/phy/maximus/inc/maximus_phy_ctx.h
+++ b/cesar/hal/phy/maximus/inc/maximus_phy_ctx.h
@@ -36,7 +36,8 @@ enum maximus_phy_medium_state_t
MAXIMUS_PHY_MEDIUM_CW = 0x03,
MAXIMUS_PHY_MEDIUM_WAIT_CONF = 0x04,
MAXIMUS_PHY_MEDIUM_BUSY_RX = 0x05,
- MAXIMUS_PHY_MEDIUM_BUSY_TX = 0x06
+ MAXIMUS_PHY_MEDIUM_BUSY_TX = 0x06,
+ MAXIMUS_PHY_MEDIUM_STATE_NB
};
typedef enum maximus_phy_medium_state_t maximus_phy_medium_state_t;
diff --git a/cesar/hal/phy/maximus/src/maximus_phy_access.c b/cesar/hal/phy/maximus/src/maximus_phy_access.c
index 3ce91e51da..b080d7b33a 100644
--- a/cesar/hal/phy/maximus/src/maximus_phy_access.c
+++ b/cesar/hal/phy/maximus/src/maximus_phy_access.c
@@ -58,7 +58,8 @@ void maximus_phy_access_backoff_cb (void *data)
{
errno = EPROTO;
station_log(&my_station, STATION_LOG_ERROR, STATION_LOGTYPE_PHY,
- "%s: errno = %d because cannot start the PRP if medium state is not IDLE", __FUNCTION__, errno);
+ "%s: errno = %d because cannot start the PRP if medium state is not IDLE (%s)",
+ __FUNCTION__, errno, maximus_phy_get_medium_state(ctx));
}
else
{
diff --git a/cesar/hal/phy/maximus/src/maximus_phy_ctrl.c b/cesar/hal/phy/maximus/src/maximus_phy_ctrl.c
index 0f482dd5b1..6a4173c45a 100644
--- a/cesar/hal/phy/maximus/src/maximus_phy_ctrl.c
+++ b/cesar/hal/phy/maximus/src/maximus_phy_ctrl.c
@@ -132,6 +132,62 @@ maximus_phy_recv_function maximus_phy_function_array[PHY_TYPE_NB] = { &maximus_p
/**
+ * Used to display medium state.
+ * \param ctx current phy context
+ * \return a string describing the Maximus PHY medium state if ok,
+ * NULL if it fails with errno =
+ * - EINVAL if ctx is NULL, or if ctx->access.medium_state is out-of-range
+ */
+const char *
+maximus_phy_get_medium_state(phy_t *ctx)
+{
+ static char medium_state[32];
+ memset(medium_state, '\0', 32);
+
+ dbg_assert_ptr(ctx);
+ dbg_assert(ctx->access.medium_state < MAXIMUS_PHY_MEDIUM_STATE_NB);
+
+ if ((NULL == ctx)
+ || (ctx->access.medium_state >= MAXIMUS_PHY_MEDIUM_STATE_NB))
+ {
+ errno = EINVAL;
+ station_log(&my_station, STATION_LOG_ERROR, STATION_LOGTYPE_PHY,
+ "%s: errno = %d", __FUNCTION__, errno);
+ return NULL;
+ }
+
+ switch(ctx->access.medium_state)
+ {
+ case 0:
+ strcpy(medium_state, "MAXIMUS_PHY_MEDIUM_IDLE");
+ break;
+ case 1:
+ strcpy(medium_state, "MAXIMUS_PHY_MEDIUM_PRS0");
+ break;
+ case 2:
+ strcpy(medium_state, "MAXIMUS_PHY_MEDIUM_PRS1");
+ break;
+ case 3:
+ strcpy(medium_state, "MAXIMUS_PHY_MEDIUM_CW");
+ break;
+ case 4:
+ strcpy(medium_state, "MAXIMUS_PHY_MEDIUM_WAIT_CONF");
+ break;
+ case 5:
+ strcpy(medium_state, "MAXIMUS_PHY_MEDIUM_BUSY_RX");
+ break;
+ case 6:
+ strcpy(medium_state, "MAXIMUS_PHY_MEDIUM_BUSY_TX");
+ break;
+ default:
+ break;
+ }
+
+ return medium_state;
+}
+
+
+/**
* Fill a blank phy header
* \param ctx current phy context
* \param msg pointer to sci message to fill header
@@ -536,7 +592,7 @@ maximus_phy_recv_preamble (phy_t *ctx, sci_msg_t *msg)
}
else if (!ctx->control.pre_detection)
{
- station_log(&my_station, STATION_LOG_WARNING, STATION_LOGTYPE_PHY,
+ station_log(&my_station, STATION_LOG_DEBUG, STATION_LOGTYPE_PHY,
"%s: recv a PREAMBLE but does not process it because PRE detection is deactivated", __FUNCTION__);
if (!ctx->warning_assert)
@@ -833,6 +889,7 @@ maximus_phy_recv_prs (phy_t *ctx, sci_msg_t *msg)
{
station_log(&my_station, STATION_LOG_WARNING, STATION_LOGTYPE_PHY,
"%s: recv a PRS symbol but does not process it because medium state is not PRS0 or PRS1", __FUNCTION__);
+ ret = 0;
}
else
{
diff --git a/cesar/hal/phy/maximus/src/maximus_phy_ctrl_cb.c b/cesar/hal/phy/maximus/src/maximus_phy_ctrl_cb.c
index 5818d1eaff..d57487d2bf 100644
--- a/cesar/hal/phy/maximus/src/maximus_phy_ctrl_cb.c
+++ b/cesar/hal/phy/maximus/src/maximus_phy_ctrl_cb.c
@@ -113,13 +113,14 @@ maximus_phy_recv_preamble_cb (void *data)
else
{
station_log(&my_station, STATION_LOG_WARNING, STATION_LOGTYPE_PHY,
- "%s: detect a PREAMBLE but does not process it because PRE detection is deactivated or because medium state is already BUSY",
- __FUNCTION__);
+ "%s: detect a PREAMBLE but does not process it because PRE detection is deactivated or because medium state is already BUSY (%s)",
+ __FUNCTION__, maximus_phy_get_medium_state(ctx));
if (ctx->warning_assert)
{
dbg_assert_print(false,
- "detect a PREAMBLE but does not process it because PRE detection is deactivated or because medium state is already BUSY");
+ "detect a PREAMBLE but does not process it because PRE detection is deactivated or because medium state is already BUSY (%s)",
+ maximus_phy_get_medium_state(ctx));
}
}
@@ -253,7 +254,7 @@ maximus_phy_tx_frame_cb (void *data)
ctx->control.tx_blocked_on_false_alarm = true;
station_log(&my_station, STATION_LOG_INFO, STATION_LOGTYPE_PHY,
- "%s: TX blocked because medium state is WANT_CONF", __FUNCTION__);
+ "%s: TX blocked because medium state is WAIT_CONF", __FUNCTION__);
}
}
}
diff --git a/cesar/hal/phy/maximus/test/src/test_phy_ctrl.c b/cesar/hal/phy/maximus/test/src/test_phy_ctrl.c
index a65d615ec2..a10d4a812e 100644
--- a/cesar/hal/phy/maximus/test/src/test_phy_ctrl.c
+++ b/cesar/hal/phy/maximus/test/src/test_phy_ctrl.c
@@ -35,6 +35,59 @@ extern uint32_t maximus_pending_isrs; // used in 'station.c'
extern station_ctx_t my_station;
phy_t *ctx;
+void maximus_phy_get_medium_state_test_case(test_t t)
+{
+ printf("get medium state\n");
+ test_case_begin(t, "get medium state");
+
+ test_begin(t, "NULL ctx")
+ {
+ dbg_fatal_try_begin
+ {
+ test_fail_unless ( (NULL == maximus_phy_get_medium_state(NULL))
+ && (EINVAL == errno) );
+ }
+ dbg_fatal_try_catch (const char *fatal_message)
+ {
+ printf("get medium state with NULL ctx\n%s\n", fatal_message);
+ }
+ dbg_fatal_try_end;
+
+ // reset errno
+ errno = 0;
+ } test_end;
+
+ test_begin(t, "invalid medium state")
+ {
+ ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_STATE_NB;
+
+ dbg_fatal_try_begin
+ {
+ test_fail_unless ( (NULL == maximus_phy_get_medium_state(ctx))
+ && (EINVAL == errno) );
+ }
+ dbg_fatal_try_catch (const char *fatal_message)
+ {
+ printf("get medium state with invalid medium state\n%s\n", fatal_message);
+ }
+ dbg_fatal_try_end;
+
+ // reset errno
+ errno = 0;
+ } test_end;
+
+ test_begin(t, "valid medium states")
+ {
+ ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_BUSY_TX;
+ test_fail_unless ( !strcmp(maximus_phy_get_medium_state(ctx), "MAXIMUS_PHY_MEDIUM_BUSY_TX")
+ && (EINVAL != errno) );
+
+ ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_IDLE;
+ test_fail_unless ( !strcmp(maximus_phy_get_medium_state(ctx), "MAXIMUS_PHY_MEDIUM_IDLE")
+ && (EINVAL != errno) );
+ } test_end;
+}
+
void maximus_phy_fill_hdr_test_case(test_t t)
{
printf("fill hdr\n");
@@ -3808,6 +3861,7 @@ void phy_ctrl_test_suite(test_t t)
trace_init();
phy_init_test_case(t);
phy_zero_cross_init_test_case(t);
+ maximus_phy_get_medium_state_test_case(t);
maximus_phy_fill_hdr_test_case(t);
maximus_phy_recv_test_case(t);
phy_date_test_case(t);