Use inttypes print formatting macros

Use inttypes print formatting macros

Update DPRINT support for rt-kernel
pull/150/head
Andreas Karlsson 2023-04-14 11:49:57 +02:00
parent 2f4afb3230
commit 70a1042188
4 changed files with 22 additions and 11 deletions

View File

@ -171,7 +171,10 @@ uint16_t sizeOfPDO (uint16_t index, int * nmappings, _SMmap * mappings,
return 0; 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) if (index == 0 && subindex == 0)
{ {
@ -1756,7 +1759,10 @@ void COE_initDefaultValues (void)
if (objd[i].data != NULL) if (objd[i].data != NULL)
{ {
COE_setValue (&objd[i], objd[i].value); 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); } while (objd[i++].subindex < maxsub);
} }

View File

@ -738,7 +738,7 @@ static void EOE_receive_fragment (void)
/* Capture error case */ /* Capture error case */
if(EOEvar.rxfragmentno != EOE_HDR_FRAG_NO_GET(frameinfo2)) 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); EOE_HDR_FRAG_NO_GET(frameinfo2), EOEvar.rxfragmentno);
/* Clean up existing saved data */ /* Clean up existing saved data */
if(EOEvar.rxfragmentno != 0) if(EOEvar.rxfragmentno != 0)
@ -777,14 +777,14 @@ static void EOE_receive_fragment (void)
/* Validate received fragment */ /* Validate received fragment */
if(EOEvar.rxframeno != EOE_HDR_FRAME_NO_GET(frameinfo2)) 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_HDR_FRAME_NO_GET(frameinfo2), EOEvar.rxframeno);
EOE_init_rx (); EOE_init_rx ();
return; return;
} }
else if(EOEvar.rxframeoffset != offset) else if(EOEvar.rxframeoffset != offset)
{ {
DPRINT("Unexpected frame offset %u, expected: %u\n", DPRINT("Unexpected frame offset %"PRIu32", expected: %"PRIu32"\n",
offset, EOEvar.rxframeoffset); offset, EOEvar.rxframeoffset);
EOE_init_rx (); EOE_init_rx ();
return; return;

View File

@ -164,7 +164,7 @@ static uint32_t FOE_fwrite (uint8_t *data, uint32_t length)
FOEvar.fposition++; FOEvar.fposition++;
if(failed) if(failed)
{ {
DPRINT("Failed FOE_fwrite ncopied=%d\n", ncopied); DPRINT("Failed FOE_fwrite ncopied=%"PRIu32"\n", ncopied);
} }
else else
{ {
@ -174,7 +174,7 @@ static uint32_t FOE_fwrite (uint8_t *data, uint32_t length)
foe_file->total_size += ncopied; foe_file->total_size += ncopied;
DPRINT("FOE_fwrite END with : %d\n",ncopied); DPRINT("FOE_fwrite END with : %"PRIu32"\n",ncopied);
return 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. */ /* 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 (); FOE_init ();
} }
@ -451,7 +451,9 @@ static void FOE_data ()
if (packet != FOEvar.foepacket) 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); FOE_abort (FOE_ERR_PACKETNO);
} }
else if (data_len == 0) else if (data_len == 0)
@ -479,7 +481,7 @@ static void FOE_data ()
DPRINT("FOE_data data_len == FOE_DATA_SIZE\n"); DPRINT("FOE_data data_len == FOE_DATA_SIZE\n");
if (ncopied != data_len) 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); FOE_abort (FOE_ERR_PROGERROR);
} }
res = FOE_send_ack (); res = FOE_send_ack ();

View File

@ -14,6 +14,7 @@ extern "C"
#include <assert.h> #include <assert.h>
#include <stdint.h> #include <stdint.h>
#include <stddef.h> #include <stddef.h>
#include <inttypes.h>
#include <sys/param.h> #include <sys/param.h>
#ifdef __linux__ #ifdef __linux__
#include <endian.h> #include <endian.h>
@ -35,6 +36,7 @@ extern "C"
#define CC_ALIGNED(n) __attribute__((aligned (n))) #define CC_ALIGNED(n) __attribute__((aligned (n)))
#ifdef __rtk__ #ifdef __rtk__
#include <kern/assert.h>
#define CC_ASSERT(exp) ASSERT (exp) #define CC_ASSERT(exp) ASSERT (exp)
#else #else
#define CC_ASSERT(exp) assert (exp) #define CC_ASSERT(exp) assert (exp)
@ -70,9 +72,10 @@ extern "C"
#define EC_BIG_ENDIAN #define EC_BIG_ENDIAN
#endif #endif
#define ESC_DEBUG
#ifdef ESC_DEBUG #ifdef ESC_DEBUG
#ifdef __rtk__ #ifdef __rtk__
#include <rprint.h> #include <kern/rprint.h>
#define DPRINT(...) rprintp ("soes: "__VA_ARGS__) #define DPRINT(...) rprintp ("soes: "__VA_ARGS__)
#else #else
#include <stdio.h> #include <stdio.h>