From 1f6528e6c9a600b7f04128ed8f22e841107361f6 Mon Sep 17 00:00:00 2001 From: Stuart Longland Date: Mon, 20 Nov 2017 19:31:47 -0500 Subject: [PATCH] [cli] make CLI buffer sizes configurable (#2351) * [core] Make CLI buffer sizes configurable. At the moment, we allocate 512 bytes for a receive buffer and 1kB for transmit, which while it doesn't seem a lot, is in fact a big commitment for a CLI interface. In cases where the platform does its own buffering, this can be significantly reduced. These add definitions that mirror the current settings so they may be changed. * [cli] Define UART buffers according to config. Use the definitions produced in the previous commit to set the buffer sizes. * [core, cli] Rename OPENTHREAD_CONFIG_CLI_LINE_LENGTH to `OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH` as per review in pull request 2351. --- src/cli/cli_uart.hpp | 6 ++--- src/core/openthread-core-default-config.h | 30 +++++++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/cli/cli_uart.hpp b/src/cli/cli_uart.hpp index c7e06c919..7f0f79cd6 100644 --- a/src/cli/cli_uart.hpp +++ b/src/cli/cli_uart.hpp @@ -111,9 +111,9 @@ public: private: enum { - kRxBufferSize = 512, - kTxBufferSize = 1024, - kMaxLineLength = 128, + kRxBufferSize = OPENTHREAD_CONFIG_CLI_UART_RX_BUFFER_SIZE, + kTxBufferSize = OPENTHREAD_CONFIG_CLI_UART_TX_BUFFER_SIZE, + kMaxLineLength = OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH, }; otError ProcessCommand(void); diff --git a/src/core/openthread-core-default-config.h b/src/core/openthread-core-default-config.h index 37e83fcf0..8e5f4d75f 100644 --- a/src/core/openthread-core-default-config.h +++ b/src/core/openthread-core-default-config.h @@ -231,6 +231,36 @@ #define OPENTHREAD_CONFIG_ADDRESS_QUERY_MAX_RETRY_DELAY 28800 #endif +/** + * @def OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH + * + * The maximum size of the CLI line in bytes + * + */ +#ifndef OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH +#define OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH 128 +#endif + +/** + * @def OPENTHREAD_CONFIG_CLI_UART_RX_BUFFER_SIZE + * + * The size of CLI UART RX buffer in bytes + * + */ +#ifndef OPENTHREAD_CONFIG_CLI_UART_RX_BUFFER_SIZE +#define OPENTHREAD_CONFIG_CLI_UART_RX_BUFFER_SIZE 512 +#endif + +/** + * @def OPENTHREAD_CONFIG_CLI_TX_BUFFER_SIZE + * + * The size of CLI message buffer in bytes + * + */ +#ifndef OPENTHREAD_CONFIG_CLI_UART_TX_BUFFER_SIZE +#define OPENTHREAD_CONFIG_CLI_UART_TX_BUFFER_SIZE 1024 +#endif + /** * @def OPENTHREAD_CONFIG_MAX_CHILDREN *