From 5eebfbb4416e4d979f5641be2aac9f083ea2c63e Mon Sep 17 00:00:00 2001 From: raiden00pl Date: Sat, 13 May 2023 09:59:16 +0200 Subject: [PATCH] logging/nxscope: do not complete the stream frame if the previous send failed In this case, the buffer already contains a frame ready to be send --- include/logging/nxscope/nxscope.h | 1 + logging/nxscope/nxscope_internals.c | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/include/logging/nxscope/nxscope.h b/include/logging/nxscope/nxscope.h index e29022235..bf1344857 100644 --- a/include/logging/nxscope/nxscope.h +++ b/include/logging/nxscope/nxscope.h @@ -360,6 +360,7 @@ struct nxscope_s FAR uint8_t *streambuf; size_t streambuf_len; size_t stream_i; + bool stream_retry; #ifdef CONFIG_LOGGING_NXSCOPE_CRICHANNELS /* Critical buffer data */ diff --git a/logging/nxscope/nxscope_internals.c b/logging/nxscope/nxscope_internals.c index e62581291..0c25895df 100644 --- a/logging/nxscope/nxscope_internals.c +++ b/logging/nxscope/nxscope_internals.c @@ -61,12 +61,15 @@ int nxscope_stream_send(FAR struct nxscope_s *s, FAR uint8_t *buff, /* Finalize stream frame */ - ret = PROTO_FRAME_FINAL(s, s->proto_stream, - NXSCOPE_HDRID_STREAM, buff, buff_i); - if (ret < 0) + if (!s->stream_retry) { - _err("ERROR: PROTO_FRAME_FINAL failed %d\n", ret); - goto errout; + ret = PROTO_FRAME_FINAL(s, s->proto_stream, + NXSCOPE_HDRID_STREAM, buff, buff_i); + if (ret < 0) + { + _err("ERROR: PROTO_FRAME_FINAL failed %d\n", ret); + goto errout; + } } /* Send stream data */ @@ -75,6 +78,11 @@ int nxscope_stream_send(FAR struct nxscope_s *s, FAR uint8_t *buff, if (ret < 0) { _err("ERROR: INTF_SEND failed %d\n", ret); + s->stream_retry = true; + } + else + { + s->stream_retry = false; } errout: