Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Interference_Simple StrCommandHandler_Demo
Revision 4:59a5e39e3e91, committed 2020-08-10
- Comitter:
- aktk
- Date:
- Mon Aug 10 10:35:29 2020 +0000
- Parent:
- 3:049a5f083f32
- Commit message:
- Modify the callbacks which are to be received and registered to those which receive the command str received as an argument.;
Changed in this revision
| StrCommandHandler.cpp | Show annotated file Show diff for this revision Revisions of this file |
| StrCommandHandler.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/StrCommandHandler.cpp Wed Nov 27 23:11:11 2019 +0000
+++ b/StrCommandHandler.cpp Mon Aug 10 10:35:29 2020 +0000
@@ -11,12 +11,12 @@
m_num_ofcommands(arg_num_ofcommands)
{
m_command_name = new char[m_num_ofcommands][16];
- m_function = new (void * (* [m_num_ofcommands])(void));
+ m_function = new (void * (* [m_num_ofcommands])(const char * const));
}
void StrCommandHandler::map(
const char * const arg_command,
- void * (*arg_pfunc)(void)
+ void * (*arg_pfunc)(const char * const)
)
{
static int itr_push = 0;
@@ -26,10 +26,10 @@
if (itr_push == m_num_ofcommands) {
m_num_ofcommands += 5;
char (*tmp_cm)[16] = new char[m_num_ofcommands][16];
- void * (**tmp_fu)(void)= new (void * (* [m_num_ofcommands])(void));
+ void * (**tmp_fu)(const char * const)= new (void * (* [m_num_ofcommands])(const char * const));
memcpy(tmp_cm, m_command_name, sizeof(char) * (m_num_ofcommands - 5) * 16);
- memcpy(tmp_fu, m_function, sizeof(void * (*)()) * (m_num_ofcommands - 5));
+ memcpy(tmp_fu, m_function, sizeof(void * (*)(const char * const)) * (m_num_ofcommands - 5));
delete[] m_command_name;
delete[] m_function;
@@ -81,7 +81,7 @@
// Exception: Not registered Command
if ( key == m_num_ofcommands ) return &(m_rescode = 0xFFFFFFFC);
- return (*m_function[key])();;
+ return (*m_function[key])(arg_command);;
}
void StrCommandHandler::list()
--- a/StrCommandHandler.h Wed Nov 27 23:11:11 2019 +0000
+++ b/StrCommandHandler.h Mon Aug 10 10:35:29 2020 +0000
@@ -17,12 +17,12 @@
/** Maps strings and functions
*
- * This maps strings(commands) and functions receiving no arguments,
+ * This maps strings(commands) and functions receiving own command,
* returning something of pointer.
*/
void map(
const char * const arg_command,
- void * (*arg_pfunc)(void)
+ void * (*arg_pfunc)(const char * const)
);
/** Analyzes a command input and executs a function corresponding to it.
@@ -54,16 +54,17 @@
private:
/** Array of commands' name
*
- * The length should be within 15 without last '\0'
+ * The length should be within 15 without last '\0'
+ * The number of the array is (int)m_numofcommands
*/
char (*m_command_name)[16];
/** Array of pointers to functions
- *
- * The length should be within 15 without last '\0'
+ *
+ * The number of the array is (int)m_numofcommands
*/
- void * (**m_function)(void);
-
+ void * (**m_function)(const char * const);
+
/** Numbers of commands registered in this.
*
* If commands are registered over this value,