Skip to content

Commit

Permalink
[ncp] new spinel property to trigger/test watchdog (openthread#2374)
Browse files Browse the repository at this point in the history
  • Loading branch information
abtink authored and jwhui committed Nov 29, 2017
1 parent 5fc9736 commit ed2112a
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 6 deletions.
8 changes: 8 additions & 0 deletions doc/spinel-protocol-src/spinel-prop-debug.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@ If the NCP supports dynamic log level control, setting this property
changes the log level accordingly. Getting the value returns the current
log level. If the dynamic log level control is not supported, setting this
property returns a `PROP_LAST_STATUS` with `STATUS_INVALID_COMMAND_FOR_PROP`.

### PROP 16386: PROP_DEBUG_TEST_WATCHDOG {#prop-debug-test-watchdog}
* Type: Read-Only
* Packed-Encoding: Empty

Reading this property will causes NCP to start `while(true) ;` loop and
thus triggering a watchdog. This is intended for testing the watchdog
functionality on the underlying platform/NCP.
11 changes: 11 additions & 0 deletions src/ncp/ncp_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const NcpBase::PropertyHandlerEntry NcpBase::mGetPropertyHandlerTable[] =
{
NCP_GET_PROP_HANDLER_ENTRY(CAPS),
NCP_GET_PROP_HANDLER_ENTRY(DEBUG_TEST_ASSERT),
NCP_GET_PROP_HANDLER_ENTRY(DEBUG_TEST_WATCHDOG),
NCP_GET_PROP_HANDLER_ENTRY(DEBUG_NCP_LOG_LEVEL),
NCP_GET_PROP_HANDLER_ENTRY(HWADDR),
NCP_GET_PROP_HANDLER_ENTRY(HOST_POWER_STATE),
Expand Down Expand Up @@ -1852,6 +1853,16 @@ otError NcpBase::GetPropertyHandler_DEBUG_TEST_ASSERT(void)
)
}

otError NcpBase::GetPropertyHandler_DEBUG_TEST_WATCHDOG(void)
{
while (true)
;

OT_UNREACHABLE_CODE(
return OT_ERROR_NONE;
)
}

otError NcpBase::GetPropertyHandler_DEBUG_NCP_LOG_LEVEL(void)
{
uint8_t logLevel = 0;
Expand Down
1 change: 1 addition & 0 deletions src/ncp/ncp_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ class NcpBase
NCP_GET_PROP_HANDLER(VENDOR_ID);
NCP_GET_PROP_HANDLER(CAPS);
NCP_GET_PROP_HANDLER(DEBUG_TEST_ASSERT);
NCP_GET_PROP_HANDLER(DEBUG_TEST_WATCHDOG);
NCP_GET_PROP_HANDLER(DEBUG_NCP_LOG_LEVEL);
NCP_SET_PROP_HANDLER(DEBUG_NCP_LOG_LEVEL);
NCP_GET_PROP_HANDLER(NCP_VERSION);
Expand Down
4 changes: 4 additions & 0 deletions src/ncp/spinel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1781,6 +1781,10 @@ spinel_prop_key_to_cstr(spinel_prop_key_t prop_key)
ret = "PROP_DEBUG_NCP_LOG_LEVEL";
break;

case SPINEL_PROP_DEBUG_TEST_WATCHDOG:
ret = "PROP_DEBUG_TEST_WATCHDOG";
break;

default:
break;
}
Expand Down
24 changes: 18 additions & 6 deletions src/ncp/spinel.h
Original file line number Diff line number Diff line change
Expand Up @@ -1555,18 +1555,30 @@ typedef enum

SPINEL_PROP_DEBUG__BEGIN = 16384,

/// Reading this property will cause an assert on the NCP.
/// This is intended for testing the assert functionality of
/// underlying platform/NCP. Assert should ideally cause the
/// NCP to reset, but if this is not supported a `false` boolean
/// is returned in response.
/** Format: 'b' (read-only) */
/// Testing platform assert
/** Format: 'b' (read-only)
*
* Reading this property will cause an assert on the NCP. This is intended for testing the assert functionality of
* underlying platform/NCP. Assert should ideally cause the NCP to reset, but if this is not supported a `false`
* boolean is returned in response.
*
*/
SPINEL_PROP_DEBUG_TEST_ASSERT = SPINEL_PROP_DEBUG__BEGIN + 0,

/// The NCP log level.
/** Format: `C` */
SPINEL_PROP_DEBUG_NCP_LOG_LEVEL = SPINEL_PROP_DEBUG__BEGIN + 1,

/// Testing platform watchdog
/** Format: Empty (read-only)
*
* Reading this property will causes NCP to start a `while(true) ;` loop and thus triggering a watchdog.
*
* This is intended for testing the watchdog functionality on the underlying platform/NCP.
*
*/
SPINEL_PROP_DEBUG_TEST_WATCHDOG = SPINEL_PROP_DEBUG__BEGIN + 2,

SPINEL_PROP_DEBUG__END = 17408,

SPINEL_PROP_EXPERIMENTAL__BEGIN = 2000000,
Expand Down

0 comments on commit ed2112a

Please sign in to comment.