Skip to content

Commit

Permalink
Fix #136: Add 'system reset' command
Browse files Browse the repository at this point in the history
  • Loading branch information
terrillmoore committed Apr 13, 2019
1 parent e42f9a6 commit 7f056e9
Showing 1 changed file with 57 additions and 22 deletions.
79 changes: 57 additions & 22 deletions src/lib/CatenaBase_registerCommands.cpp
Original file line number Diff line number Diff line change
@@ -1,34 +1,17 @@
/* CatenaBase_registerCommands.cpp Mon Dec 03 2018 14:35:39 chwon */

/*
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"
Expand All @@ -39,7 +22,7 @@ using namespace McciCatena;

/****************************************************************************\
|
| Manifest constants
| Manifest constants and forward references
|
\****************************************************************************/

Expand All @@ -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
Expand All @@ -79,7 +64,7 @@ static KeyMap sKeyMap[] =

/****************************************************************************\
|
| The method function
| The method function that registers these commands
|
\****************************************************************************/

Expand All @@ -92,7 +77,7 @@ CatenaBase::registerCommands()

/****************************************************************************\
|
| The commands
| The commands (called back from parser)
|
\****************************************************************************/

Expand Down Expand Up @@ -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 ****/

0 comments on commit 7f056e9

Please sign in to comment.