40 #include <px4_platform_common/px4_config.h> 41 #include <px4_platform_common/log.h> 42 #include <px4_platform_common/module.h> 56 PRINT_MODULE_DESCRIPTION(
"Dump file utility. Prints file size and contents in binary mode (don't replace LF with CR LF) to stdout.");
58 PRINT_MODULE_USAGE_NAME_SIMPLE(
"dumpfile",
"command");
59 PRINT_MODULE_USAGE_ARG(
"<file>",
"File to dump",
false);
73 f = fopen(argv[1],
"r");
76 PX4_ERR(
"Failed to open file (%i)", errno);
81 fseek(f, 0L, SEEK_END);
83 fseek(f, 0L, SEEK_SET);
85 printf(
"File size: %d bytes\n", size);
88 int out = fileno(stdout);
91 struct termios tc_old;
95 memcpy(&tc_old, &tc,
sizeof(tc));
100 if (tcsetattr(out, TCSANOW, &tc) < 0) {
101 PX4_ERR(
"failed setting stdout attributes");
110 while ((nread = fread(buf, 1,
sizeof(buf), f)) > 0) {
111 if (
write(out, buf, nread) <= 0) {
112 PX4_ERR(
"write failed");
121 if (tcsetattr(out, TCSANOW, &tc_old) < 0) {
122 PX4_ERR(
"failed to restore stdout attributes");
Vector< float, 6 > f(float t, const Matrix< float, 6, 1 > &, const Matrix< float, 3, 1 > &)
__EXPORT int dumpfile_main(int argc, char *argv[])
Simple error/warning functions, heavily inspired by the BSD functions of the same names...
static void print_usage(void)
static void write(bootloader_app_shared_t *pshared)