From 7f056e9eeef5f6439ae49cf4750924159669e93c Mon Sep 17 00:00:00 2001 From: Terry Moore Date: Sat, 13 Apr 2019 00:21:18 -0400 Subject: [PATCH] Fix #136: Add 'system reset' command --- src/lib/CatenaBase_registerCommands.cpp | 79 ++++++++++++++++++------- 1 file changed, 57 insertions(+), 22 deletions(-) diff --git a/src/lib/CatenaBase_registerCommands.cpp b/src/lib/CatenaBase_registerCommands.cpp index 3c69094..3165e4c 100644 --- a/src/lib/CatenaBase_registerCommands.cpp +++ b/src/lib/CatenaBase_registerCommands.cpp @@ -1,5 +1,3 @@ -/* CatenaBase_registerCommands.cpp Mon Dec 03 2018 14:35:39 chwon */ - /* Module: CatenaBase_registerCommands.cpp @@ -7,28 +5,13 @@ Module: CatenaBase_registerCommands.cpp Function: CatenaBase::registerCommands() -Version: - V0.12.0 Mon Dec 03 2018 14:35:39 chwon Edit level 1 - Copyright notice: - This file copyright (C) 2018 by - - MCCI Corporation - 3520 Krums Corners Road - Ithaca, NY 14850 - - An unpublished work. All rights reserved. - - This file is proprietary information, and may not be disclosed or - copied without the prior permission of MCCI Corporation + See accompanying LICENSE file. Author: + Terry Moore, MCCI Corporation 2016 ChaeHee Won, MCCI Corporation December 2018 -Revision history: - 0.12.0 Mon Dec 03 2018 14:35:39 chwon - Module created. - */ #include "CatenaBase.h" @@ -39,7 +22,7 @@ using namespace McciCatena; /****************************************************************************\ | -| Manifest constants +| Manifest constants and forward references | \****************************************************************************/ @@ -54,10 +37,12 @@ static cCommandStream::CommandFn doSysEUI; \****************************************************************************/ static cCommandStream::CommandFn doConfigure; +static cCommandStream::CommandFn doReset; static const cCommandStream::cEntry sDispatchEntries[] = { { "configure", doConfigure }, + { "reset", doReset }, }; static cCommandStream::cDispatch @@ -79,7 +64,7 @@ static KeyMap sKeyMap[] = /****************************************************************************\ | -| The method function +| The method function that registers these commands | \****************************************************************************/ @@ -92,7 +77,7 @@ CatenaBase::registerCommands() /****************************************************************************\ | -| The commands +| The commands (called back from parser) | \****************************************************************************/ @@ -233,5 +218,55 @@ doConfigure( } } } + +/* + +Name: doReset() + +Function: + Implement the system reset command + +Definition: + static cCommandStream::CommandFn doReset; + + static cCommandStream::CommandStatus + doReset( + cCommandStream *pThis, + void *pContext, + int argc, + char **argv + ); + +Description: + This function dispatches the various commands, parsing the input + parameters if any to set the corresponding value, or displaying + the values. + + The parsed syntax: + +. system reset + +Returns: + Command status (always an error if it returns; otherwise the + system gets rebooted). + +*/ + + +static cCommandStream::CommandStatus +doReset( + cCommandStream *pThis, + void *pContext, + int argc, + char **argv + ) + { + if (argc != 1) + { + return cCommandStream::CommandStatus::kInvalidParameter; + } + + NVIC_SystemReset(); + } /**** end of CatenaBase_registerCommands.cpp ****/