Skip to content

Commit

Permalink
[shell] Fixes for Matter cli (#31768)
Browse files Browse the repository at this point in the history
* [shell] Fixed parsing of long otcli commands

The otcli command buffer (128) was to small for some ot commands like otcli dataset set active <hex dataset>.
The 128 value was taken from an OT config a long time ago and since was increased to 384.
A new static constexpr was created with the value of 384 to be used instead of the define.

Signed-off-by: Marius Preda <[email protected]>

* [shell] Add backspace character in ReadLine

Signed-off-by: Andrei Menzopol <[email protected]>

---------

Signed-off-by: Marius Preda <[email protected]>
Signed-off-by: Andrei Menzopol <[email protected]>
Co-authored-by: Marius Preda <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Jul 14, 2024
1 parent 56cc19a commit 3617786
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
3 changes: 1 addition & 2 deletions examples/shell/shell_common/cmd_otcli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ static char sTxBuffer[SHELL_OTCLI_TX_BUFFER_SIZE];
static constexpr uint16_t sTxLength = SHELL_OTCLI_TX_BUFFER_SIZE;
#endif // !CHIP_DEVICE_CONFIG_THREAD_ENABLE_CLI)
#endif
static constexpr uint16_t kMaxLineLength = 384;
#else
#include <sys/types.h>
#include <sys/wait.h>
Expand Down Expand Up @@ -81,8 +82,6 @@ CHIP_ERROR cmd_otcli_dispatch(int argc, char ** argv)
{
CHIP_ERROR error = CHIP_NO_ERROR;

// From OT CLI internal lib, kMaxLineLength = 128
#define kMaxLineLength 128
char buff[kMaxLineLength] = { 0 };
char * buff_ptr = buff;
int i = 0;
Expand Down
1 change: 1 addition & 0 deletions src/lib/shell/MainLoopDefault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ size_t ReadLine(char * buffer, size_t max)
done = true;
}
break;
case 0x08:
case 0x7F:
// Do not accept backspace character (i.e. don't increment line_sz) and remove 1 additional character if it exists.
if (line_sz >= 1u)
Expand Down

0 comments on commit 3617786

Please sign in to comment.