NuttX inits null console

This commit is contained in:
David Sidrane 2021-04-20 12:34:12 -07:00 committed by Daniel Agar
parent 01ef9cf3e6
commit ec61512cdf
13 changed files with 14 additions and 70 deletions

View File

@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2020 PX4 Development Team. All rights reserved.
* Copyright (c) 2020, 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
@ -65,7 +65,6 @@ __EXPORT int board_app_initialize(uintptr_t arg)
void board_late_initialize(void)
{
px4_platform_console_init();
sercon_main(0, NULL);
}

View File

@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2020 PX4 Development Team. All rights reserved.
* Copyright (c) 2020, 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
@ -65,7 +65,6 @@ __EXPORT int board_app_initialize(uintptr_t arg)
void board_late_initialize(void)
{
px4_platform_console_init();
sercon_main(0, NULL);
}

View File

@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2020 PX4 Development Team. All rights reserved.
* Copyright (c) 2020, 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
@ -65,7 +65,6 @@ __EXPORT int board_app_initialize(uintptr_t arg)
void board_late_initialize(void)
{
px4_platform_console_init();
sercon_main(0, NULL);
}

View File

@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2018 PX4 Development Team. All rights reserved.
* Copyright (c) 2018, 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

View File

@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2019 PX4 Development Team. All rights reserved.
* Copyright (c) 2019, 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
@ -65,7 +65,6 @@ __EXPORT int board_app_initialize(uintptr_t arg)
void board_late_initialize(void)
{
px4_platform_console_init();
sercon_main(0, NULL);
}

View File

@ -65,7 +65,6 @@ __EXPORT int board_app_initialize(uintptr_t arg)
void board_late_initialize(void)
{
px4_platform_console_init();
sercon_main(0, NULL);
}

View File

@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2020 PX4 Development Team. All rights reserved.
* Copyright (c) 2020, 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
@ -65,7 +65,6 @@ __EXPORT int board_app_initialize(uintptr_t arg)
void board_late_initialize(void)
{
px4_platform_console_init();
sercon_main(0, NULL);
}

View File

@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2020 PX4 Development Team. All rights reserved.
* Copyright (c) 2020, 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
@ -65,7 +65,6 @@ __EXPORT int board_app_initialize(uintptr_t arg)
void board_late_initialize(void)
{
px4_platform_console_init();
sercon_main(0, NULL);
}

View File

@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2020 PX4 Development Team. All rights reserved.
* Copyright (c) 2020, 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
@ -65,7 +65,6 @@ __EXPORT int board_app_initialize(uintptr_t arg)
void board_late_initialize(void)
{
px4_platform_console_init();
sercon_main(0, NULL);
}

View File

@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2019 PX4 Development Team. All rights reserved.
* Copyright (c) 2019, 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
@ -65,7 +65,6 @@ __EXPORT int board_app_initialize(uintptr_t arg)
void board_late_initialize(void)
{
px4_platform_console_init();
sercon_main(0, NULL);
}

View File

@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2019 PX4 Development Team. All rights reserved.
* Copyright (c) 2019, 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
@ -65,7 +65,6 @@ __EXPORT int board_app_initialize(uintptr_t arg)
void board_late_initialize(void)
{
px4_platform_console_init();
sercon_main(0, NULL);
}

View File

@ -335,11 +335,10 @@ void print_load_buffer(char *buffer, int buffer_length, print_load_callback_f cb
const float sched_load = 1.f - idle_load - task_load;
snprintf(buffer, buffer_length, "Processes: %d total, %d running, %d sleeping, max FDs: %d",
snprintf(buffer, buffer_length, "Processes: %d total, %d running, %d sleeping",
system_load.total_count,
print_state->running_count,
print_state->blocked_count,
CONFIG_NFILE_DESCRIPTORS);
print_state->blocked_count);
cb(user);
snprintf(buffer, buffer_length, "CPU usage: %.2f%% tasks, %.2f%% sched, %.2f%% idle",
(double)(task_load * 100.f),

View File

@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2019 PX4 Development Team. All rights reserved.
* Copyright (c) 2019, 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
@ -44,56 +44,11 @@
#include <fcntl.h>
int px4_platform_console_init(void)
{
#if !defined(CONFIG_DEV_CONSOLE) && defined(CONFIG_DEV_NULL)
/* Support running nsh on a board with out a console
* Without this the assumption that the fd 0..2 are
* std{in..err} will be wrong. NSH will read/write to the
* fd it opens for the init script or nested scripts assigned
* to fd 0..2.
*
*/
int fd = open("/dev/null", O_RDWR);
if (fd == 0) {
/* Successfully opened /dev/null as stdin (fd == 0) */
(void)fs_dupfd2(0, 1);
(void)fs_dupfd2(0, 2);
(void)fs_fdopen(0, O_RDONLY, NULL, NULL);
(void)fs_fdopen(1, O_WROK | O_CREAT, NULL, NULL);
(void)fs_fdopen(2, O_WROK | O_CREAT, NULL, NULL);
} else {
/* We failed to open /dev/null OR for some reason, we opened
* it and got some file descriptor other than 0.
*/
if (fd > 0) {
(void)close(fd);
}
return -ENFILE;
}
#endif
return OK;
}
int px4_platform_init(void)
{
int ret = px4_platform_console_init();
if (ret < 0) {
return ret;
}
ret = px4_console_buffer_init();
int ret = px4_console_buffer_init();
if (ret < 0) {
return ret;