added continuous mode support fix #3
If a command returns SHELLMATTA_CONTINUE all received data is passed to this command until it returns != SHELLMATTA_CONTINUE or a cancel is received The data is passed stdin like and can be read byte by byte vie shellmatta_read The stdin buffer is overwritten witch each new char
This commit is contained in:
@@ -119,6 +119,30 @@ static shellmatta_retCode_t reset(shellmatta_handle_t handle, const char *argume
|
||||
}
|
||||
shellmatta_cmd_t resetCommand = {"reset", NULL, "resets the shellmatta instance", "reset [prompt]", reset, NULL};
|
||||
|
||||
static shellmatta_retCode_t continuous(shellmatta_handle_t handle, const char *arguments, uint32_t length)
|
||||
{
|
||||
(void)arguments;
|
||||
(void)length;
|
||||
|
||||
shellmatta_retCode_t ret = SHELLMATTA_CONTINUE;
|
||||
uint32_t stdinLength;
|
||||
char *stdinData;
|
||||
|
||||
shellmatta_read(handle, &stdinData, &stdinLength);
|
||||
if(NULL != stdinData)
|
||||
{
|
||||
if('x' == stdinData[0u])
|
||||
{
|
||||
ret = SHELLMATTA_OK;
|
||||
}
|
||||
|
||||
stdinData[0u] ++;
|
||||
shellmatta_write(handle, stdinData, stdinLength);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
shellmatta_cmd_t continuousCommand = {"continuous", "cont", "prints continously all input bytes", "continuous", continuous, NULL};
|
||||
|
||||
|
||||
shellmatta_retCode_t writeFct(const char* data, uint32_t length)
|
||||
{
|
||||
@@ -164,6 +188,7 @@ int main(int argc, char **argv)
|
||||
shellmatta_addCmd(handle, &removeCommand);
|
||||
shellmatta_addCmd(handle, &emptyCommand);
|
||||
shellmatta_addCmd(handle, &resetCommand);
|
||||
shellmatta_addCmd(handle, &continuousCommand);
|
||||
|
||||
while(exitRequest == false)
|
||||
{
|
||||
|
Reference in New Issue
Block a user