Skip to content

Commit

Permalink
Use inttypes print formatting macros
Browse files Browse the repository at this point in the history
Use inttypes print formatting macros

Update DPRINT support for rt-kernel
  • Loading branch information
Andreas Karlsson committed Apr 14, 2023
1 parent 2f4afb3 commit 70a1042
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
10 changes: 8 additions & 2 deletions soes/esc_coe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions soes/esc_eoe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 7 additions & 5 deletions soes/esc_foe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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;
}

Expand Down Expand Up @@ -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 ();
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 ();
Expand Down
5 changes: 4 additions & 1 deletion soes/include/sys/gcc/cc.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ extern "C"
#include <assert.h>
#include <stdint.h>
#include <stddef.h>
#include <inttypes.h>
#include <sys/param.h>
#ifdef __linux__
#include <endian.h>
Expand All @@ -35,6 +36,7 @@ extern "C"
#define CC_ALIGNED(n) __attribute__((aligned (n)))

#ifdef __rtk__
#include <kern/assert.h>
#define CC_ASSERT(exp) ASSERT (exp)
#else
#define CC_ASSERT(exp) assert (exp)
Expand Down Expand Up @@ -70,9 +72,10 @@ extern "C"
#define EC_BIG_ENDIAN
#endif

#define ESC_DEBUG
#ifdef ESC_DEBUG
#ifdef __rtk__
#include <rprint.h>
#include <kern/rprint.h>
#define DPRINT(...) rprintp ("soes: "__VA_ARGS__)
#else
#include <stdio.h>
Expand Down

0 comments on commit 70a1042

Please sign in to comment.