mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-28 02:36:37 +08:00
NuttX inits null console
This commit is contained in:
committed by
Daniel Agar
parent
01ef9cf3e6
commit
ec61512cdf
@@ -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
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* 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)
|
void board_late_initialize(void)
|
||||||
{
|
{
|
||||||
px4_platform_console_init();
|
|
||||||
sercon_main(0, NULL);
|
sercon_main(0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* 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)
|
void board_late_initialize(void)
|
||||||
{
|
{
|
||||||
px4_platform_console_init();
|
|
||||||
sercon_main(0, NULL);
|
sercon_main(0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* 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)
|
void board_late_initialize(void)
|
||||||
{
|
{
|
||||||
px4_platform_console_init();
|
|
||||||
sercon_main(0, NULL);
|
sercon_main(0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -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
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* 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)
|
void board_late_initialize(void)
|
||||||
{
|
{
|
||||||
px4_platform_console_init();
|
|
||||||
sercon_main(0, NULL);
|
sercon_main(0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ __EXPORT int board_app_initialize(uintptr_t arg)
|
|||||||
|
|
||||||
void board_late_initialize(void)
|
void board_late_initialize(void)
|
||||||
{
|
{
|
||||||
px4_platform_console_init();
|
|
||||||
sercon_main(0, NULL);
|
sercon_main(0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* 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)
|
void board_late_initialize(void)
|
||||||
{
|
{
|
||||||
px4_platform_console_init();
|
|
||||||
sercon_main(0, NULL);
|
sercon_main(0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* 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)
|
void board_late_initialize(void)
|
||||||
{
|
{
|
||||||
px4_platform_console_init();
|
|
||||||
sercon_main(0, NULL);
|
sercon_main(0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* 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)
|
void board_late_initialize(void)
|
||||||
{
|
{
|
||||||
px4_platform_console_init();
|
|
||||||
sercon_main(0, NULL);
|
sercon_main(0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* 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)
|
void board_late_initialize(void)
|
||||||
{
|
{
|
||||||
px4_platform_console_init();
|
|
||||||
sercon_main(0, NULL);
|
sercon_main(0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* 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)
|
void board_late_initialize(void)
|
||||||
{
|
{
|
||||||
px4_platform_console_init();
|
|
||||||
sercon_main(0, NULL);
|
sercon_main(0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
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,
|
system_load.total_count,
|
||||||
print_state->running_count,
|
print_state->running_count,
|
||||||
print_state->blocked_count,
|
print_state->blocked_count);
|
||||||
CONFIG_NFILE_DESCRIPTORS);
|
|
||||||
cb(user);
|
cb(user);
|
||||||
snprintf(buffer, buffer_length, "CPU usage: %.2f%% tasks, %.2f%% sched, %.2f%% idle",
|
snprintf(buffer, buffer_length, "CPU usage: %.2f%% tasks, %.2f%% sched, %.2f%% idle",
|
||||||
(double)(task_load * 100.f),
|
(double)(task_load * 100.f),
|
||||||
|
|||||||
@@ -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
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -44,56 +44,11 @@
|
|||||||
|
|
||||||
#include <fcntl.h>
|
#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 px4_platform_init(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
int ret = px4_platform_console_init();
|
int ret = px4_console_buffer_init();
|
||||||
|
|
||||||
if (ret < 0) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = px4_console_buffer_init();
|
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user