[ncp] config option for max log string size in otNcpPlatLogv() (#2603)

This commit adds `OPENTHREAD_CONFIG_NCP_SPINEL_LOG_MAX_SIZE` as
a config option to set the max log string size supported by NCP
`otNcpPlatLogv()`. This commit also increases the default to 150
characters.
This commit is contained in:
Abtin Keshavarzian
2018-03-07 17:46:32 +00:00
committed by Jonathan Hui
parent 3e4ed6cc98
commit 157d74d3ef
3 changed files with 21 additions and 11 deletions
+10 -10
View File
@@ -84,6 +84,16 @@ void otNcpInit(otInstance *aInstance);
*/
otError otNcpStreamWrite(int aStreamId, const uint8_t *aDataPtr, int aDataLen);
/**
* Writes OpenThread Log using `otNcpStreamWrite`.
*
* @param[in] aLogLevel The log level.
* @param[in] aLogRegion The log region.
* @param[in] aFormat A pointer to the format string.
* @param[in] aArgs va_list matching aFormat.
*/
void otNcpPlatLogv(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, va_list aArgs);
//-----------------------------------------------------------------------------------------
// Peek/Poke memory access control delegates
@@ -202,16 +212,6 @@ void otNcpHandleDidReceiveNewLegacyUlaPrefix(const uint8_t *aUlaPrefix);
*/
void otNcpRegisterLegacyHandlers(const otNcpLegacyHandlers *aHandlers);
/**
* Callback to write the OpenThread Log to the NCP Spinel Tunnel.
*
* @param[in] aLogLevel The log level.
* @param[in] aLogRegion The log region.
* @param[in] aFormat A pointer to the format string.
* @param[in] aArgs va_list matching aFormat.
*/
void otNcpPlatLogv(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, va_list aArgs);
/**
* @}
*
+10
View File
@@ -855,6 +855,16 @@
#define OPENTHREAD_CONFIG_NCP_SPINEL_ENCRYPTER_EXTRA_DATA_SIZE 0
#endif
/**
* @def OPENTHREAD_CONFIG_NCP_SPINEL_LOG_MAX_SIZE
*
* The maximum OpenThread log string size (number of chars) supported by NCP using Spinel `StreamWrite`.
*
*/
#ifndef OPENTHREAD_CONFIG_NCP_SPINEL_LOG_MAX_SIZE
#define OPENTHREAD_CONFIG_NCP_SPINEL_LOG_MAX_SIZE 150
#endif
/**
* @def OPENTHREAD_CONFIG_PLATFORM_ASSERT_MANAGEMENT
*
+1 -1
View File
@@ -2163,7 +2163,7 @@ otError otNcpStreamWrite(int aStreamId, const uint8_t *aDataPtr, int aDataLen)
extern "C" void otNcpPlatLogv(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, va_list aArgs)
{
char logString[128];
char logString[OPENTHREAD_CONFIG_NCP_SPINEL_LOG_MAX_SIZE];
int charsWritten;
if ((charsWritten = vsnprintf(logString, sizeof(logString), aFormat, aArgs)) > 0)