aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Schink <jaylink-dev@marcschink.de>2016-09-16 20:12:21 +0200
committerMarc Schink <jaylink-dev@marcschink.de>2016-09-18 13:49:34 +0200
commitfaa2a433fdd3de211728f3da5921133214af9dd3 (patch)
tree5df8869271ed4524a63ff2d8dbb168f8a926b2fd
parentb705c2cce0589a592c4d999f0ad2f972c5407030 (diff)
Read SWO trace data in any case
The device expects that the trace data is read even if the status code indicates an error. Signed-off-by: Marc Schink <jaylink-dev@marcschink.de>
-rw-r--r--libjaylink/swo.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/libjaylink/swo.c b/libjaylink/swo.c
index 07e5f03..32fe80f 100644
--- a/libjaylink/swo.c
+++ b/libjaylink/swo.c
@@ -228,6 +228,7 @@ JAYLINK_API int jaylink_swo_read(struct jaylink_device_handle *devh,
int ret;
struct jaylink_context *ctx;
uint8_t buf[32];
+ uint32_t status;
uint32_t tmp;
if (!devh || !buffer || !length)
@@ -267,13 +268,7 @@ JAYLINK_API int jaylink_swo_read(struct jaylink_device_handle *devh,
return ret;
}
- tmp = buffer_get_u32(buf, 0);
-
- if (tmp > 0) {
- log_err(ctx, "Failed to read data: %u.", tmp);
- return JAYLINK_ERR_DEV;
- }
-
+ status = buffer_get_u32(buf, 0);
tmp = buffer_get_u32(buf, 4);
if (tmp > *length) {
@@ -302,6 +297,11 @@ JAYLINK_API int jaylink_swo_read(struct jaylink_device_handle *devh,
}
}
+ if (status > 0) {
+ log_err(ctx, "Failed to read data: %u.", status);
+ return JAYLINK_ERR_DEV;
+ }
+
return JAYLINK_OK;
}