From fa479e4e206dd30714448873e9c931699441c282 Mon Sep 17 00:00:00 2001 From: Davide Grohmann Date: Wed, 11 Aug 2021 13:23:09 +0200 Subject: Fix wrong output data json format when compiling with GCC This change works around an issue when compiling with GCC where by printing only a '\n' the produced global output is wrong. What happens is that new lines are actually printed before the content in the precedent fprintf calls. Hence the generated json is unparsable. Note also that replacing the LOG macros with direct calls to fprintf does _not_ solve the issue. Change-Id: I2d97703cbe7703aae94def1943e2ac693945ab31 --- applications/inference_process/src/inference_process.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/applications/inference_process/src/inference_process.cpp b/applications/inference_process/src/inference_process.cpp index 7058f9c..c26bb13 100644 --- a/applications/inference_process/src/inference_process.cpp +++ b/applications/inference_process/src/inference_process.cpp @@ -55,10 +55,15 @@ void print_output_data(TfLiteTensor *output, size_t bytesToPrint) { LOG("\"data_address\": \"%08" PRIx32 "\",\n", (uint32_t)output->data.data); LOG("\"data\":\""); for (int i = 0; i < numBytesToPrint - 1; ++i) { - if (i % 16 == 0 && i != 0) { - LOG("\n"); + /* + * Workaround an issue when compiling with GCC where by + * printing only a '\n' the produced global output is wrong. + */ + if (i % 15 == 0 && i != 0) { + LOG("0x%02x,\n", output->data.uint8[i]); + } else { + LOG("0x%02x,", output->data.uint8[i]); } - LOG("0x%02x,", output->data.uint8[i]); } LOG("0x%02x\"\n", output->data.uint8[numBytesToPrint - 1]); LOG("}"); -- cgit v1.2.1