mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 10:58:49 +08:00
SYSLOG: Add an option to use the syslog'ing device as the system consolution. This option enables a low-level, write-only console device at /dev/console (similar to the low-level UART console device). From Pierre-noel Bouteville.
This commit is contained in:
parent
93ed9dc8d3
commit
3465cb6138
15 changed files with 364 additions and 59 deletions
|
@ -44,6 +44,7 @@
|
|||
#include <nuttx/arch.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/syslog/ramlog.h>
|
||||
#include <nuttx/syslog/syslog_console.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
|
@ -220,6 +221,8 @@ void up_initialize(void)
|
|||
|
||||
#if defined(CONFIG_DEV_LOWCONSOLE)
|
||||
lowconsole_init();
|
||||
#elif defined(CONFIG_SYSLOG_CONSOLE)
|
||||
syslog_console_init();
|
||||
#elif defined(CONFIG_RAMLOG_CONSOLE)
|
||||
ramlog_consoleinit();
|
||||
#endif
|
||||
|
|
|
@ -127,73 +127,82 @@
|
|||
#undef HAVE_UART_CONSOLE
|
||||
#undef HAVE_LEUART_CONSOLE
|
||||
|
||||
#if defined(CONFIG_USART0_SERIAL_CONSOLE) && defined(CONFIG_EFM32_USART0_ISUART)
|
||||
#if defined(CONFIG_SYSLOG_CONSOLE)
|
||||
# undef CONFIG_USART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART2_SERIAL_CONSOLE
|
||||
# undef CONFIG_UART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_UART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_LEUART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_LEUART1_SERIAL_CONSOLE
|
||||
# define HAVE_UART_CONSOLE 1
|
||||
#elif defined(CONFIG_USART1_SERIAL_CONSOLE) && defined(CONFIG_EFM32_USART1_ISUART)
|
||||
# undef CONFIG_USART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART2_SERIAL_CONSOLE
|
||||
# undef CONFIG_UART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_UART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_LEUART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_LEUART1_SERIAL_CONSOLE
|
||||
# define HAVE_UART_CONSOLE 1
|
||||
#elif defined(CONFIG_USART2_SERIAL_CONSOLE) && defined(CONFIG_EFM32_USART2_ISUART)
|
||||
# undef CONFIG_USART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_UART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_UART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_LEUART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_LEUART1_SERIAL_CONSOLE
|
||||
# define HAVE_UART_CONSOLE 1
|
||||
#elif defined(CONFIG_UART0_SERIAL_CONSOLE) && defined(CONFIG_EFM32_UART0)
|
||||
# undef CONFIG_USART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART2_SERIAL_CONSOLE
|
||||
# undef CONFIG_UART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_LEUART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_LEUART1_SERIAL_CONSOLE
|
||||
# define HAVE_UART_CONSOLE 1
|
||||
#elif defined(CONFIG_UART1_SERIAL_CONSOLE) && defined(CONFIG_EFM32_UART1)
|
||||
# undef CONFIG_USART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART2_SERIAL_CONSOLE
|
||||
# undef CONFIG_UART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_LEUART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_LEUART1_SERIAL_CONSOLE
|
||||
# define HAVE_UART_CONSOLE 1
|
||||
#elif defined(CONFIG_LEUART0_SERIAL_CONSOLE) && defined(CONFIG_EFM32_LEUART0)
|
||||
# undef CONFIG_USART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART2_SERIAL_CONSOLE
|
||||
# undef CONFIG_UART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_UART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_LEUART1_SERIAL_CONSOLE
|
||||
# define HAVE_LEUART_CONSOLE 1
|
||||
#elif defined(CONFIG_LEUART1_SERIAL_CONSOLE) && defined(CONFIG_EFM32_LEUART1)
|
||||
# undef CONFIG_USART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART2_SERIAL_CONSOLE
|
||||
# undef CONFIG_UART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_UART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_LEUART0_SERIAL_CONSOLE
|
||||
# define HAVE_LEUART_CONSOLE 1
|
||||
#else
|
||||
# ifdef CONFIG_DEV_CONSOLE
|
||||
# warning "No valid CONFIG_U[S]ART[n]_SERIAL_CONSOLE Setting"
|
||||
# if defined(CONFIG_USART0_SERIAL_CONSOLE) && defined(CONFIG_EFM32_USART0_ISUART)
|
||||
# undef CONFIG_USART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART2_SERIAL_CONSOLE
|
||||
# undef CONFIG_UART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_UART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_LEUART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_LEUART1_SERIAL_CONSOLE
|
||||
# define HAVE_UART_CONSOLE 1
|
||||
# elif defined(CONFIG_USART1_SERIAL_CONSOLE) && defined(CONFIG_EFM32_USART1_ISUART)
|
||||
# undef CONFIG_USART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART2_SERIAL_CONSOLE
|
||||
# undef CONFIG_UART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_UART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_LEUART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_LEUART1_SERIAL_CONSOLE
|
||||
# define HAVE_UART_CONSOLE 1
|
||||
# elif defined(CONFIG_USART2_SERIAL_CONSOLE) && defined(CONFIG_EFM32_USART2_ISUART)
|
||||
# undef CONFIG_USART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_UART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_UART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_LEUART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_LEUART1_SERIAL_CONSOLE
|
||||
# define HAVE_UART_CONSOLE 1
|
||||
# elif defined(CONFIG_UART0_SERIAL_CONSOLE) && defined(CONFIG_EFM32_UART0)
|
||||
# undef CONFIG_USART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART2_SERIAL_CONSOLE
|
||||
# undef CONFIG_UART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_LEUART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_LEUART1_SERIAL_CONSOLE
|
||||
# define HAVE_UART_CONSOLE 1
|
||||
# elif defined(CONFIG_UART1_SERIAL_CONSOLE) && defined(CONFIG_EFM32_UART1)
|
||||
# undef CONFIG_USART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART2_SERIAL_CONSOLE
|
||||
# undef CONFIG_UART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_LEUART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_LEUART1_SERIAL_CONSOLE
|
||||
# define HAVE_UART_CONSOLE 1
|
||||
# elif defined(CONFIG_LEUART0_SERIAL_CONSOLE) && defined(CONFIG_EFM32_LEUART0)
|
||||
# undef CONFIG_USART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART2_SERIAL_CONSOLE
|
||||
# undef CONFIG_UART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_UART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_LEUART1_SERIAL_CONSOLE
|
||||
# define HAVE_LEUART_CONSOLE 1
|
||||
# elif defined(CONFIG_LEUART1_SERIAL_CONSOLE) && defined(CONFIG_EFM32_LEUART1)
|
||||
# undef CONFIG_USART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART2_SERIAL_CONSOLE
|
||||
# undef CONFIG_UART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_UART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_LEUART0_SERIAL_CONSOLE
|
||||
# define HAVE_LEUART_CONSOLE 1
|
||||
# else
|
||||
# ifdef CONFIG_DEV_CONSOLE
|
||||
# warning "No valid CONFIG_U[S]ART[n]_SERIAL_CONSOLE Setting"
|
||||
# endif
|
||||
# undef CONFIG_USART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART2_SERIAL_CONSOLE
|
||||
# undef CONFIG_UART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_UART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_LEUART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_LEUART1_SERIAL_CONSOLE
|
||||
# endif
|
||||
# undef CONFIG_USART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART2_SERIAL_CONSOLE
|
||||
# undef CONFIG_UART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_UART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_LEUART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_LEUART1_SERIAL_CONSOLE
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include <nuttx/arch.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/syslog/ramlog.h>
|
||||
#include <nuttx/syslog/syslog_console.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
|
@ -246,6 +247,8 @@ void up_initialize(void)
|
|||
|
||||
#if defined(CONFIG_DEV_LOWCONSOLE)
|
||||
lowconsole_init();
|
||||
#elif defined(CONFIG_SYSLOG_CONSOLE)
|
||||
syslog_console_init();
|
||||
#elif defined(CONFIG_RAMLOG_CONSOLE)
|
||||
ramlog_consoleinit();
|
||||
#endif
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include <nuttx/arch.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/syslog/ramlog.h>
|
||||
#include <nuttx/syslog/syslog_console.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
#include "up_internal.h"
|
||||
|
@ -169,6 +170,8 @@ void up_initialize(void)
|
|||
|
||||
#if defined(CONFIG_DEV_LOWCONSOLE)
|
||||
lowconsole_init();
|
||||
#elif defined(CONFIG_SYSLOG_CONSOLE)
|
||||
syslog_console_init();
|
||||
#elif defined(CONFIG_RAMLOG_CONSOLE)
|
||||
ramlog_consoleinit();
|
||||
#endif
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include <nuttx/arch.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/syslog/ramlog.h>
|
||||
#include <nuttx/syslog/syslog_console.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
|
@ -171,6 +172,8 @@ void up_initialize(void)
|
|||
|
||||
#if defined(CONFIG_DEV_LOWCONSOLE)
|
||||
lowconsole_init();
|
||||
#elif defined(CONFIG_SYSLOG_CONSOLE)
|
||||
syslog_console_init();
|
||||
#elif defined(CONFIG_RAMLOG_CONSOLE)
|
||||
ramlog_consoleinit();
|
||||
#endif
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include <nuttx/arch.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/syslog/ramlog.h>
|
||||
#include <nuttx/syslog/syslog_console.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
#include "up_internal.h"
|
||||
|
@ -159,6 +160,8 @@ void up_initialize(void)
|
|||
|
||||
#if defined(CONFIG_DEV_LOWCONSOLE)
|
||||
lowconsole_init();
|
||||
#elif defined(CONFIG_SYSLOG_CONSOLE)
|
||||
syslog_console_init();
|
||||
#elif defined(CONFIG_RAMLOG_CONSOLE)
|
||||
ramlog_consoleinit();
|
||||
#endif
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include <nuttx/fs/ioctl.h>
|
||||
#include <nuttx/mtd/mtd.h>
|
||||
#include <nuttx/syslog/ramlog.h>
|
||||
#include <nuttx/syslog/syslog_console.h>
|
||||
|
||||
#include "up_internal.h"
|
||||
|
||||
|
@ -143,6 +144,8 @@ void up_initialize(void)
|
|||
/* Register a console (or not) */
|
||||
|
||||
up_devconsole(); /* Our private /dev/console */
|
||||
#elif defined(CONFIG_SYSLOG_CONSOLE)
|
||||
syslog_console_init();
|
||||
#elif defined(CONFIG_RAMLOG_CONSOLE)
|
||||
ramlog_consoleinit();
|
||||
#endif
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include <nuttx/arch.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/syslog/ramlog.h>
|
||||
#include <nuttx/syslog/syslog_console.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
|
@ -171,6 +172,8 @@ void up_initialize(void)
|
|||
|
||||
#if defined(CONFIG_DEV_LOWCONSOLE)
|
||||
lowconsole_init();
|
||||
#elif defined(CONFIG_SYSLOG_CONSOLE)
|
||||
syslog_console_init();
|
||||
#elif defined(CONFIG_RAMLOG_CONSOLE)
|
||||
ramlog_consoleinit();
|
||||
#endif
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include <nuttx/arch.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/syslog/ramlog.h>
|
||||
#include <nuttx/syslog/syslog_console.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
|
@ -175,6 +176,8 @@ void up_initialize(void)
|
|||
|
||||
#if defined(CONFIG_DEV_LOWCONSOLE)
|
||||
lowconsole_init();
|
||||
#elif defined(CONFIG_SYSLOG_CONSOLE)
|
||||
syslog_console_init();
|
||||
#elif defined(CONFIG_RAMLOG_CONSOLE)
|
||||
ramlog_consoleinit();
|
||||
#endif
|
||||
|
|
|
@ -168,6 +168,8 @@ void up_initialize(void)
|
|||
|
||||
#if defined(CONFIG_DEV_LOWCONSOLE)
|
||||
lowconsole_init();
|
||||
#elif defined(CONFIG_SYSLOG_CONSOLE)
|
||||
syslog_console_init();
|
||||
#elif defined(CONFIG_RAMLOG_CONSOLE)
|
||||
ramlog_consoleinit();
|
||||
#endif
|
||||
|
|
|
@ -88,6 +88,9 @@
|
|||
# if defined(CONFIG_RAMLOG_CONSOLE)
|
||||
# undef USE_SERIALDRIVER
|
||||
# undef CONFIG_DEV_LOWCONSOLE
|
||||
# elif defined(CONFIG_SYSLOG_CONSOLE)
|
||||
# undef USE_SERIALDRIVER
|
||||
# undef CONFIG_DEV_LOWCONSOLE
|
||||
# elif defined(CONFIG_DEV_LOWCONSOLE)
|
||||
# undef USE_SERIALDRIVER
|
||||
# else
|
||||
|
@ -168,6 +171,14 @@ void lowconsole_init(void);
|
|||
# define lowconsole_init()
|
||||
#endif
|
||||
|
||||
/* Defined in drivers/syslog_console.c */
|
||||
|
||||
#ifdef defined(CONFIG_SYSLOG_CONSOLE)
|
||||
syslog_console_init();
|
||||
#else
|
||||
# define syslog_console_init()
|
||||
#endif
|
||||
|
||||
/* Defined in drivers/ramlog.c */
|
||||
|
||||
#ifdef CONFIG_RAMLOG_CONSOLE
|
||||
|
|
|
@ -71,3 +71,15 @@ config RAMLOG_NPOLLWAITERS
|
|||
The maximum number of threads that may be waiting on the poll method.
|
||||
|
||||
endif
|
||||
|
||||
config SYSLOG_CONSOLE
|
||||
bool "Use SYSLOG for /dev/console"
|
||||
default n
|
||||
depends on DEV_CONSOLE
|
||||
---help---
|
||||
Use the syslog logging device as a system console. If this feature is enabled
|
||||
(along with DEV_CONSOLE), then all console output will be re-directed to syslog
|
||||
output (syslog_putc). This is useful, for example, if the only console is a Telnet
|
||||
console. Then in that case, console output from non-Telnet threads will go to
|
||||
the syslog output.
|
||||
|
||||
|
|
|
@ -47,6 +47,12 @@ ifeq ($(CONFIG_RAMLOG),y)
|
|||
CSRCS += ramlog.c
|
||||
endif
|
||||
|
||||
# (Add other SYSLOG_CONSOLE drivers here)
|
||||
|
||||
ifeq ($(CONFIG_SYSLOG_CONSOLE),y)
|
||||
CSRCS += syslog_console.c
|
||||
endif
|
||||
|
||||
# Include SYSLOG build support
|
||||
|
||||
DEPPATH += --dep-path syslog
|
||||
|
|
139
drivers/syslog/syslog_console.c
Normal file
139
drivers/syslog/syslog_console.c
Normal file
|
@ -0,0 +1,139 @@
|
|||
/****************************************************************************
|
||||
* drivers/syslog/syslog_console.c
|
||||
*
|
||||
* Copyright (C) 2015 Pierre-noel Bouteville. All rights reserved.
|
||||
* Author: Pierre-noel Bouteville <pnb990@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/syslog/syslog.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* The architecture must provide syslog_putc for this driver */
|
||||
|
||||
#if defined(CONFIG_SYSLOG)
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static ssize_t syslog_console_read(FAR struct file *filep, FAR char *buffer,
|
||||
size_t buflen);
|
||||
static ssize_t syslog_console_write(FAR struct file *filep,
|
||||
FAR const char *buffer, size_t buflen);
|
||||
static int syslog_console_ioctl(FAR struct file *filep, int cmd,
|
||||
unsigned long arg);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
****************************************************************************/
|
||||
|
||||
static const struct file_operations g_consoleops =
|
||||
{
|
||||
0, /* open */
|
||||
0, /* close */
|
||||
syslog_console_read, /* read */
|
||||
syslog_console_write, /* write */
|
||||
0, /* seek */
|
||||
syslog_console_ioctl /* ioctl */
|
||||
#ifndef CONFIG_DISABLE_POLL
|
||||
, 0 /* poll */
|
||||
#endif
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: syslog_console_ioctl
|
||||
****************************************************************************/
|
||||
|
||||
static int syslog_console_ioctl(FAR struct file *filep, int cmd,
|
||||
unsigned long arg)
|
||||
{
|
||||
return -ENOTTY;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: syslog_console_read
|
||||
****************************************************************************/
|
||||
|
||||
static ssize_t syslog_console_read(FAR struct file *filep, FAR char *buffer,
|
||||
size_t buflen)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: syslog_console_write
|
||||
****************************************************************************/
|
||||
|
||||
static ssize_t syslog_console_write(FAR struct file *filep,
|
||||
FAR const char *buffer, size_t buflen)
|
||||
{
|
||||
ssize_t ret = buflen;
|
||||
|
||||
for (; buflen; buflen--)
|
||||
{
|
||||
syslog_putc(*buffer++);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: syslog_console_init
|
||||
****************************************************************************/
|
||||
|
||||
void syslog_console_init(void)
|
||||
{
|
||||
(void)register_driver("/dev/console", &g_consoleops, 0666, NULL);
|
||||
}
|
||||
#endif /* CONFIG_SYSLOG */
|
102
include/nuttx/syslog/syslog_console.h
Normal file
102
include/nuttx/syslog/syslog_console.h
Normal file
|
@ -0,0 +1,102 @@
|
|||
/****************************************************************************
|
||||
* include/nuttx/syslog/ramlog.h
|
||||
*
|
||||
* Copyright (C) 2015 Pierre-noel Bouteville. All rights reserved.
|
||||
* Author: Pierre-noel Bouteville <pnb990@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTTX_SYSLOG_SYSLOG_CONSOLE_H
|
||||
#define __INCLUDE_NUTTX_SYSLOG_SYSLOG_CONSOLE_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/syslog/syslog.h>
|
||||
|
||||
#ifdef CONFIG_SYSLOG_CONSOLE
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
/* Configuration ************************************************************/
|
||||
/* CONFIG_SYSLOG_CONSOLE - Use the syslog logging output as a system console.
|
||||
* If this feature is enabled (along with CONFIG_DEV_CONSOLE), then all
|
||||
* console output will be re-directed to a syslog_putc function. This
|
||||
* is useful, for example, if the only console is a Telnet console. Then
|
||||
* in that case, console output from non-Telnet threads will go to the
|
||||
* syslog_putc output.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_DEV_CONSOLE
|
||||
# undef CONFIG_SYSLOG_CONSOLE
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C" {
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: syslog_console_init
|
||||
*
|
||||
* Description:
|
||||
* Create the console logging device and register it at the '/dev/console'
|
||||
* path.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SYSLOG_CONSOLE
|
||||
EXTERN int syslog_console_init(void);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* CONFIG_SYSLOG_CONSOLE */
|
||||
#endif /* __INCLUDE_NUTTX_SYSLOG_SYSLOG_CONSOLE_H */
|
Loading…
Reference in a new issue