From 70a10421885c0d7b1c6d2544af74675061dd1d4f Mon Sep 17 00:00:00 2001 From: Andreas Karlsson Date: Fri, 14 Apr 2023 11:49:57 +0200 Subject: [PATCH] Use inttypes print formatting macros Use inttypes print formatting macros Update DPRINT support for rt-kernel --- soes/esc_coe.c | 10 ++++++++-- soes/esc_eoe.c | 6 +++--- soes/esc_foe.c | 12 +++++++----- soes/include/sys/gcc/cc.h | 5 ++++- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/soes/esc_coe.c b/soes/esc_coe.c index 0eb3da4..361c67d 100644 --- a/soes/esc_coe.c +++ b/soes/esc_coe.c @@ -171,7 +171,10 @@ uint16_t sizeOfPDO (uint16_t index, int * nmappings, _SMmap * mappings, return 0; } - DPRINT ("%04x:%02x @ %d\n", index, subindex, offset); + DPRINT ("%04"PRIx32":%02"PRIx32" @ %"PRIu32"\n", + index, + subindex, + offset); if (index == 0 && subindex == 0) { @@ -1756,7 +1759,10 @@ void COE_initDefaultValues (void) if (objd[i].data != NULL) { COE_setValue (&objd[i], objd[i].value); - DPRINT ("%04x:%02x = %x\n", SDOobjects[n].index, objd[i].subindex, objd[i].value); + DPRINT ("%04"PRIx32":%02"PRIx32" = %"PRIx32"\n", + SDOobjects[n].index, + objd[i].subindex, + objd[i].value); } } while (objd[i++].subindex < maxsub); } diff --git a/soes/esc_eoe.c b/soes/esc_eoe.c index 37afaf3..ae0d526 100644 --- a/soes/esc_eoe.c +++ b/soes/esc_eoe.c @@ -738,7 +738,7 @@ static void EOE_receive_fragment (void) /* Capture error case */ if(EOEvar.rxfragmentno != EOE_HDR_FRAG_NO_GET(frameinfo2)) { - DPRINT("Unexpected fragment number %u, expected: %u\n", + DPRINT("Unexpected fragment number %"PRIu32", expected: %"PRIu32"\n", EOE_HDR_FRAG_NO_GET(frameinfo2), EOEvar.rxfragmentno); /* Clean up existing saved data */ if(EOEvar.rxfragmentno != 0) @@ -777,14 +777,14 @@ static void EOE_receive_fragment (void) /* Validate received fragment */ if(EOEvar.rxframeno != EOE_HDR_FRAME_NO_GET(frameinfo2)) { - DPRINT("Unexpected frame number %u, expected: %u\n", + DPRINT("Unexpected frame number %"PRIu32", expected: %"PRIu32"\n", EOE_HDR_FRAME_NO_GET(frameinfo2), EOEvar.rxframeno); EOE_init_rx (); return; } else if(EOEvar.rxframeoffset != offset) { - DPRINT("Unexpected frame offset %u, expected: %u\n", + DPRINT("Unexpected frame offset %"PRIu32", expected: %"PRIu32"\n", offset, EOEvar.rxframeoffset); EOE_init_rx (); return; diff --git a/soes/esc_foe.c b/soes/esc_foe.c index ff4eda9..7c1bac5 100644 --- a/soes/esc_foe.c +++ b/soes/esc_foe.c @@ -164,7 +164,7 @@ static uint32_t FOE_fwrite (uint8_t *data, uint32_t length) FOEvar.fposition++; if(failed) { - DPRINT("Failed FOE_fwrite ncopied=%d\n", ncopied); + DPRINT("Failed FOE_fwrite ncopied=%"PRIu32"\n", ncopied); } else { @@ -174,7 +174,7 @@ static uint32_t FOE_fwrite (uint8_t *data, uint32_t length) foe_file->total_size += ncopied; - DPRINT("FOE_fwrite END with : %d\n",ncopied); + DPRINT("FOE_fwrite END with : %"PRIu32"\n",ncopied); return ncopied; } @@ -234,7 +234,7 @@ static void FOE_abort (uint32_t code) } /* Nothing we can do if we can't get an outbound mailbox. */ } - DPRINT("FOE_abort: 0x%X\n", code); + DPRINT("FOE_abort: 0x%"PRIX32"\n", code); FOE_init (); } @@ -451,7 +451,9 @@ static void FOE_data () if (packet != FOEvar.foepacket) { - DPRINT("FOE_data packet error, packet: %d, foeheader.packet: %d\n",packet,FOEvar.foepacket); + DPRINT("FOE_data packet error, packet: %"PRIu32", foeheader.packet: %"PRIu32"\n", + packet, + FOEvar.foepacket); FOE_abort (FOE_ERR_PACKETNO); } else if (data_len == 0) @@ -479,7 +481,7 @@ static void FOE_data () DPRINT("FOE_data data_len == FOE_DATA_SIZE\n"); if (ncopied != data_len) { - DPRINT("FOE_data only %d of %d copied\n",ncopied, data_len); + DPRINT("FOE_data only %"PRIu32" of %"PRIu32" copied\n",ncopied, data_len); FOE_abort (FOE_ERR_PROGERROR); } res = FOE_send_ack (); diff --git a/soes/include/sys/gcc/cc.h b/soes/include/sys/gcc/cc.h index 9761a4d..848b9d5 100644 --- a/soes/include/sys/gcc/cc.h +++ b/soes/include/sys/gcc/cc.h @@ -14,6 +14,7 @@ extern "C" #include #include #include +#include #include #ifdef __linux__ #include @@ -35,6 +36,7 @@ extern "C" #define CC_ALIGNED(n) __attribute__((aligned (n))) #ifdef __rtk__ +#include #define CC_ASSERT(exp) ASSERT (exp) #else #define CC_ASSERT(exp) assert (exp) @@ -70,9 +72,10 @@ extern "C" #define EC_BIG_ENDIAN #endif +#define ESC_DEBUG #ifdef ESC_DEBUG #ifdef __rtk__ -#include +#include #define DPRINT(...) rprintp ("soes: "__VA_ARGS__) #else #include