forked from Archive/PX4-Autopilot
systemcmds:Use inttypes
This commit is contained in:
parent
62fd132047
commit
1b80018f30
|
@ -1,6 +1,6 @@
|
|||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved.
|
||||
* Copyright (c) 2012, 2013, 2021 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -41,6 +41,7 @@
|
|||
#include <px4_platform_common/log.h>
|
||||
#include <px4_platform_common/module.h>
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -127,7 +128,7 @@ bl_update_main(int argc, char *argv[])
|
|||
/* sanity-check file size */
|
||||
if (s.st_size > BL_FILE_SIZE_LIMIT)
|
||||
{
|
||||
PX4_ERR("%s: file too large (limit: %u, actual: %d)", argv[1], BL_FILE_SIZE_LIMIT, s.st_size);
|
||||
PX4_ERR("%s: file too large (limit: %u, actual: %jd)", argv[1], BL_FILE_SIZE_LIMIT, (intmax_t) s.st_size);
|
||||
close(fd);
|
||||
return 1;
|
||||
}
|
||||
|
@ -145,7 +146,7 @@ bl_update_main(int argc, char *argv[])
|
|||
|
||||
if (buf == NULL)
|
||||
{
|
||||
PX4_ERR("failed to allocate %u bytes for firmware buffer", file_size);
|
||||
PX4_ERR("failed to allocate %jd bytes for firmware buffer", (intmax_t) file_size);
|
||||
close(fd);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
@ -254,16 +255,16 @@ static int write_stack_detail(bool inValid, _stack_s *si, char *sp_name,
|
|||
int n = 0;
|
||||
uint32_t sbot = si->top - si->size;
|
||||
n = snprintf(&buffer[n], max - n, " %s stack: \n", sp_name);
|
||||
n += snprintf(&buffer[n], max - n, " top: 0x%08x\n", si->top);
|
||||
n += snprintf(&buffer[n], max - n, " sp: 0x%08x %s\n", si->sp, (inValid ? "Invalid" : "Valid"));
|
||||
n += snprintf(&buffer[n], max - n, " top: 0x%08" PRIu32 "\n", si->top);
|
||||
n += snprintf(&buffer[n], max - n, " sp: 0x%08" PRIu32 " %s\n", si->sp, (inValid ? "Invalid" : "Valid"));
|
||||
|
||||
if (n != write(fd, buffer, n)) {
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
n = 0;
|
||||
n += snprintf(&buffer[n], max - n, " bottom: 0x%08x\n", sbot);
|
||||
n += snprintf(&buffer[n], max - n, " size: 0x%08x\n", si->size);
|
||||
n += snprintf(&buffer[n], max - n, " bottom: 0x%08" PRIu32 "\n", sbot);
|
||||
n += snprintf(&buffer[n], max - n, " size: 0x%08" PRIu32 "\n", si->size);
|
||||
|
||||
if (n != write(fd, buffer, n)) {
|
||||
return -EIO;
|
||||
|
@ -275,10 +276,11 @@ static int write_stack_detail(bool inValid, _stack_s *si, char *sp_name,
|
|||
tcb.adj_stack_size = si->size;
|
||||
|
||||
if (verify_ram_address(sbot, si->size)) {
|
||||
n = snprintf(buffer, max, " used: %08x\n", up_check_tcbstack(&tcb));
|
||||
n = snprintf(buffer, max, " used: %08zu\n", up_check_tcbstack(&tcb));
|
||||
|
||||
} else {
|
||||
n = snprintf(buffer, max, "Invalid Stack! (Corrupted TCB) Stack base: %08x Stack size: %08x\n", sbot,
|
||||
n = snprintf(buffer, max, "Invalid Stack! (Corrupted TCB) Stack base: %08" PRIu32 " Stack size: %08" PRIu32
|
||||
"\n", sbot,
|
||||
si->size);
|
||||
}
|
||||
|
||||
|
@ -348,7 +350,7 @@ static int write_stack(bool inValid, int winsize, uint32_t wtopaddr,
|
|||
marker[0] = '\0';
|
||||
}
|
||||
|
||||
n = snprintf(buffer, max, "0x%08x 0x%08x%s\n", wtopaddr, stack[i], marker);
|
||||
n = snprintf(buffer, max, "0x%08" PRIu32 " 0x%08" PRIu32 "%s\n", wtopaddr, stack[i], marker);
|
||||
|
||||
if (n != write(outfd, buffer, n)) {
|
||||
ret = -EIO;
|
||||
|
@ -368,7 +370,9 @@ static int write_stack(bool inValid, int winsize, uint32_t wtopaddr,
|
|||
****************************************************************************/
|
||||
static int write_registers(uint32_t regs[], char *buffer, int max, int fd)
|
||||
{
|
||||
int n = snprintf(buffer, max, " r0:0x%08x r1:0x%08x r2:0x%08x r3:0x%08x r4:0x%08x r5:0x%08x r6:0x%08x r7:0x%08x\n",
|
||||
int n = snprintf(buffer, max,
|
||||
" r0:0x%08" PRIu32 " r1:0x%08" PRIu32 " r2:0x%08" PRIu32 " r3:0x%08" PRIu32 " r4:0x%08" PRIu32 " r5:0x%08" PRIu32
|
||||
" r6:0x%08" PRIu32 " r7:0x%08" PRIu32 "\n",
|
||||
regs[REG_R0], regs[REG_R1],
|
||||
regs[REG_R2], regs[REG_R3],
|
||||
regs[REG_R4], regs[REG_R5],
|
||||
|
@ -378,7 +382,9 @@ static int write_registers(uint32_t regs[], char *buffer, int max, int fd)
|
|||
return -EIO;
|
||||
}
|
||||
|
||||
n = snprintf(buffer, max, " r8:0x%08x r9:0x%08x r10:0x%08x r11:0x%08x r12:0x%08x sp:0x%08x lr:0x%08x pc:0x%08x\n",
|
||||
n = snprintf(buffer, max,
|
||||
" r8:0x%08" PRIu32 " r9:0x%08" PRIu32 " r10:0x%08" PRIu32 " r11:0x%08" PRIu32 " r12:0x%08" PRIu32 " sp:0x%08" PRIu32
|
||||
" lr:0x%08" PRIu32 " pc:0x%08" PRIu32 "\n",
|
||||
regs[REG_R8], regs[REG_R9],
|
||||
regs[REG_R10], regs[REG_R11],
|
||||
regs[REG_R12], regs[REG_R13],
|
||||
|
@ -389,11 +395,11 @@ static int write_registers(uint32_t regs[], char *buffer, int max, int fd)
|
|||
}
|
||||
|
||||
#ifdef CONFIG_ARMV7M_USEBASEPRI
|
||||
n = snprintf(buffer, max, " xpsr:0x%08x basepri:0x%08x control:0x%08x\n",
|
||||
n = snprintf(buffer, max, " xpsr:0x%08" PRIu32 " basepri:0x%08" PRIu32 " control:0x%08" PRIu32 "\n",
|
||||
regs[REG_XPSR], regs[REG_BASEPRI],
|
||||
getcontrol());
|
||||
#else
|
||||
n = snprintf(buffer, max, " xpsr:0x%08x primask:0x%08x control:0x%08x\n",
|
||||
n = snprintf(buffer, max, " xpsr:0x%08" PRIu32 " primask:0x%08" PRIu32 " control:0x%08" PRIu32 "\n",
|
||||
regs[REG_XPSR], regs[REG_PRIMASK],
|
||||
getcontrol());
|
||||
#endif
|
||||
|
@ -403,7 +409,7 @@ static int write_registers(uint32_t regs[], char *buffer, int max, int fd)
|
|||
}
|
||||
|
||||
#ifdef REG_EXC_RETURN
|
||||
n = snprintf(buffer, max, " exe return:0x%08x\n", regs[REG_EXC_RETURN]);
|
||||
n = snprintf(buffer, max, " exe return:0x%08" PRIu32 "\n", regs[REG_EXC_RETURN]);
|
||||
|
||||
if (n != write(fd, buffer, n)) {
|
||||
return -EIO;
|
||||
|
@ -419,9 +425,12 @@ static int write_registers(uint32_t regs[], char *buffer, int max, int fd)
|
|||
static int write_fault_registers(fault_regs_s *fault_regs, char *buffer, int max, int fd)
|
||||
{
|
||||
#if defined(CONFIG_ARCH_CORTEXM7)
|
||||
const char fmt[] = " cfsr:0x%08x hfsr:0x%08x dfsr:0x%08x mmfsr:0x%08x bfsr:0x%08x afsr:0x%08x abfsr:0x%08x \n";
|
||||
const char fmt[] =
|
||||
" cfsr:0x%08" PRIu32 " hfsr:0x%08" PRIu32 " dfsr:0x%08" PRIu32 " mmfsr:0x%08" PRIu32 " bfsr:0x%08" PRIu32
|
||||
" afsr:0x%08" PRIu32 " abfsr:0x%08" PRIu32 " \n";
|
||||
#else
|
||||
const char fmt[] = " cfsr:0x%08x hfsr:0x%08x dfsr:0x%08x mmfsr:0x%08x bfsr:0x%08x afsr:0x%08x\n";
|
||||
const char fmt[] = " cfsr:0x%08" PRIu32 " hfsr:0x%08" PRIu32 " dfsr:0x%08" PRIu32 " mmfsr:0x%08" PRIu32
|
||||
" bfsr:0x%08" PRIu32 " afsr:0x%08" PRIu32 "\n";
|
||||
#endif
|
||||
int n = snprintf(buffer, max, fmt,
|
||||
fault_regs->cfsr, fault_regs->hfsr, fault_regs->dfsr,
|
||||
|
@ -861,7 +870,7 @@ static int hardfault_commit(char *caller)
|
|||
|
||||
if (state != OK) {
|
||||
identify(caller);
|
||||
syslog(LOG_INFO, "Nothing to save\n", path);
|
||||
syslog(LOG_INFO, "Nothing to save\n");
|
||||
ret = -ENOENT;
|
||||
|
||||
} else {
|
||||
|
@ -1065,8 +1074,8 @@ __EXPORT int hardfault_check_status(char *caller)
|
|||
} else {
|
||||
ret = state;
|
||||
identify(caller);
|
||||
syslog(LOG_INFO, "Fault Log info File No %d Length %d flags:0x%02x state:%d\n",
|
||||
(unsigned int)desc.fileno, (unsigned int) desc.len, (unsigned int)desc.flags, state);
|
||||
syslog(LOG_INFO, "Fault Log info File No %" PRIu8 " Length %" PRIu8 " flags:0x%02" PRIu16 " state:%d\n",
|
||||
desc.fileno, desc.len, desc.flags, state);
|
||||
|
||||
if (state == OK) {
|
||||
char buf[TIME_FMT_LEN + 1];
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2013-2014 PX4 Development Team. All rights reserved.
|
||||
* Copyright (c) 2013-2014, 2021 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -46,6 +46,7 @@
|
|||
#include <px4_platform_common/px4_mtd.h>
|
||||
#include <px4_platform_common/getopt.h>
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -112,7 +113,7 @@ static int mtd_status(void)
|
|||
ret = instances[i].part_dev[p]->ioctl(instances[i].part_dev[p], MTDIOC_GEOMETRY, (unsigned long)((uintptr_t)&geo));
|
||||
printf(" partition: %u:\n", p);
|
||||
printf(" name: %s\n", instances[i].partition_names[p]);
|
||||
printf(" blocks: %u (%u bytes)\n", geo.neraseblocks, erasesize * geo.neraseblocks);
|
||||
printf(" blocks: %" PRIu32 " (%lu bytes)\n", geo.neraseblocks, erasesize * geo.neraseblocks);
|
||||
totalnblocks += geo.neraseblocks;
|
||||
totalpartsize += erasesize * geo.neraseblocks;
|
||||
}
|
||||
|
@ -175,7 +176,7 @@ int mtd_erase(mtd_instance_s &instance)
|
|||
count += sizeof(v);
|
||||
}
|
||||
|
||||
printf("Erased %lu bytes\n", (unsigned long)count);
|
||||
printf("Erased %" PRIu32 " bytes\n", count);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
|
@ -203,7 +204,7 @@ int mtd_readtest(const mtd_instance_s &instance)
|
|||
return 1;
|
||||
}
|
||||
|
||||
printf("reading %s expecting %u bytes\n", instance.partition_names[i], expected_size);
|
||||
printf("reading %s expecting %zd bytes\n", instance.partition_names[i], expected_size);
|
||||
int fd = open(instance.partition_names[i], O_RDONLY);
|
||||
|
||||
if (fd == -1) {
|
||||
|
@ -216,7 +217,7 @@ int mtd_readtest(const mtd_instance_s &instance)
|
|||
}
|
||||
|
||||
if (count != expected_size) {
|
||||
PX4_ERR("Failed to read partition - got %u/%u bytes", count, expected_size);
|
||||
PX4_ERR("Failed to read partition - got %zd/%zd bytes", count, expected_size);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -248,7 +249,7 @@ int mtd_rwtest(const mtd_instance_s &instance)
|
|||
return 1;
|
||||
}
|
||||
|
||||
printf("rwtest %s testing %u bytes\n", instance.partition_names[i], expected_size);
|
||||
printf("rwtest %s testing %zd bytes\n", instance.partition_names[i], expected_size);
|
||||
int fd = open(instance.partition_names[i], O_RDWR);
|
||||
|
||||
if (fd == -1) {
|
||||
|
@ -288,7 +289,7 @@ int mtd_rwtest(const mtd_instance_s &instance)
|
|||
}
|
||||
|
||||
if (count != expected_size) {
|
||||
PX4_ERR("Failed to read partition - got %u/%u bytes", count, expected_size);
|
||||
PX4_ERR("Failed to read partition - got %zd/%zd bytes", count, expected_size);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -518,7 +518,7 @@ do_show_for_airframe()
|
|||
int32_t sys_autostart = 0;
|
||||
param_get(param_find("SYS_AUTOSTART"), &sys_autostart);
|
||||
if (sys_autostart != 0) {
|
||||
PARAM_PRINT("# Make sure to add all params from the current airframe (ID=%i) as well\n", sys_autostart);
|
||||
PARAM_PRINT("# Make sure to add all params from the current airframe (ID=%" PRId32 ") as well\n", sys_autostart);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2013, 2014, 2017 PX4 Development Team. All rights reserved.
|
||||
* Copyright (c) 2013, 2014, 2017, 2021 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -47,6 +47,7 @@
|
|||
#include <px4_platform_common/cli.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
@ -279,7 +280,7 @@ pwm_main(int argc, char *argv[])
|
|||
|
||||
for (unsigned i = 0; i < PWM_OUTPUT_MAX_CHANNELS; i++) {
|
||||
if (set_mask & 1 << i) {
|
||||
printf("%d ", i + 1);
|
||||
printf("%u ", i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -924,17 +925,17 @@ err_out_no_test:
|
|||
ret = px4_ioctl(fd, PWM_SERVO_GET(i), (unsigned long)&spos);
|
||||
|
||||
if (ret == OK) {
|
||||
printf("channel %u: %u us", i + 1, spos);
|
||||
printf("channel %u: %" PRIu16 " us", i + 1, spos);
|
||||
|
||||
if (info_alt_rate_mask & (1 << i)) {
|
||||
printf(" (alternative rate: %d Hz", info_alt_rate);
|
||||
printf(" (alternative rate: %" PRIu32 " Hz", info_alt_rate);
|
||||
|
||||
} else {
|
||||
printf(" (default rate: %d Hz", info_default_rate);
|
||||
printf(" (default rate: %" PRIu32 " Hz", info_default_rate);
|
||||
}
|
||||
|
||||
|
||||
printf(" failsafe: %d, disarmed: %d us, min: %d us, max: %d us, trim: %5.2f)",
|
||||
printf(" failsafe: %d, disarmed: %" PRIu16 " us, min: %" PRIu16 " us, max: %" PRIu16 " us, trim: %5.2f)",
|
||||
failsafe_pwm.values[i], disarmed_pwm.values[i], min_pwm.values[i], max_pwm.values[i],
|
||||
(double)((int16_t)(trim_pwm.values[i]) / 10000.0f));
|
||||
printf("\n");
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2014 Andrew Tridgell. All rights reserved.
|
||||
* Copyright (c) 2014, 2021 Andrew Tridgell. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -40,6 +40,7 @@
|
|||
*/
|
||||
|
||||
#include <px4_platform_common/px4_config.h>
|
||||
#include <inttypes.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -76,7 +77,7 @@ static uint32_t allocate_blocks(struct block **blocks)
|
|||
nblocks++;
|
||||
}
|
||||
|
||||
printf("Allocated %u blocks\n", nblocks);
|
||||
printf("Allocated %" PRIu32 " blocks\n", nblocks);
|
||||
|
||||
return nblocks;
|
||||
}
|
||||
|
|
|
@ -36,9 +36,8 @@
|
|||
* Tests for the bson en/decoder
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <px4_platform_common/defines.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
|
Loading…
Reference in New Issue