This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 220a5a2ce nxscope: use the entire reserved channel length when sending
strings
220a5a2ce is described below
commit 220a5a2ce615fcb9b2897e5a321cb47a63673434
Author: raiden00pl <[email protected]>
AuthorDate: Tue Feb 7 20:40:24 2023 +0100
nxscope: use the entire reserved channel length when sending strings
The previous version makes stream data parser too complicated and
susceptible to errors.
---
include/logging/nxscope/nxscope_chan.h | 18 ------------------
logging/nxscope/nxscope_chan.c | 5 +++--
2 files changed, 3 insertions(+), 20 deletions(-)
diff --git a/include/logging/nxscope/nxscope_chan.h
b/include/logging/nxscope/nxscope_chan.h
index ee6f5fad5..15e16f139 100644
--- a/include/logging/nxscope/nxscope_chan.h
+++ b/include/logging/nxscope/nxscope_chan.h
@@ -224,15 +224,6 @@ int nxscope_put_vub32_m(FAR struct nxscope_s *s, uint8_t
ch,
int nxscope_put_vb32_m(FAR struct nxscope_s *s, uint8_t ch,
FAR b32_t *val, uint8_t d,
FAR uint8_t *meta, uint8_t mlen);
-
-/****************************************************************************
- * Name: nxscope_put_vchar_m
- *
- * NOTE: if a given string is shorten than initialized channel vdim,
- * we put only string bytes + '\0'
- *
- ****************************************************************************/
-
int nxscope_put_vchar_m(FAR struct nxscope_s *s, uint8_t ch,
FAR char *val, uint8_t d,
FAR uint8_t *meta, uint8_t mlen);
@@ -283,15 +274,6 @@ int nxscope_put_vub32(FAR struct nxscope_s *s, uint8_t ch,
FAR ub32_t *val, uint8_t d);
int nxscope_put_vb32(FAR struct nxscope_s *s, uint8_t ch,
FAR b32_t *val, uint8_t d);
-
-/****************************************************************************
- * Name: nxscope_put_vchar
- *
- * NOTE: if a given string is shorten than initialized channel vdim,
- * we put only string bytes + '\0'
- *
- ****************************************************************************/
-
int nxscope_put_vchar(FAR struct nxscope_s *s, uint8_t ch,
FAR char *val, uint8_t d);
diff --git a/logging/nxscope/nxscope_chan.c b/logging/nxscope/nxscope_chan.c
index ca730b37c..a59828be2 100644
--- a/logging/nxscope/nxscope_chan.c
+++ b/logging/nxscope/nxscope_chan.c
@@ -360,13 +360,14 @@ static int nxscope_put_vector(FAR uint8_t *buff, uint8_t
type, FAR void *val,
case NXSCOPE_TYPE_CHAR:
{
- /* Copy only string bytes + '\0' */
+ /* Copy string bytes and fill with '\0' */
DEBUGASSERT(val);
strncpy((FAR char *)buff, (FAR const char *)val, d);
j += strnlen((FAR char *)buff, d);
- buff[j++] = '\0';
+ memset(&buff[j], '\0', d - j);
+ j = d;
break;
}