9
0
Fork 0

Move RAMLOG driver to drivers/syslog; Add ability to output debug information to any character device or file

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4996 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2012-08-02 00:42:46 +00:00
parent f2f9740189
commit edeb4ed92a
40 changed files with 636 additions and 135 deletions

View File

@ -492,7 +492,7 @@ void nsh_usbtrace(void);
# ifndef CONFIG_NSH_DISABLE_LS
int cmd_ls(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
# endif
# if defined(CONFIG_SYSLOG) && !defined(CONFIG_NSH_DISABLE_DMESG)
# if defined(CONFIG_SYSLOG) && defined(CONFIG_RAMLOG_SYSLOG) && !defined(CONFIG_NSH_DISABLE_DMESG)
int cmd_dmesg(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
# endif
# if CONFIG_NFILE_STREAMS > 0 && !defined(CONFIG_NSH_DISABLESCRIPT)

View File

@ -59,6 +59,9 @@
# include <netinet/in.h>
# include <nuttx/fs/nfs.h>
# endif
# ifdef CONFIG_RAMLOG_SYSLOG
# include <nuttx/ramlog.h>
# endif
#endif
#endif
@ -523,10 +526,11 @@ int cmd_cat(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
* Name: cmd_dmesg
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_SYSLOG) && !defined(CONFIG_NSH_DISABLE_DMESG)
#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_SYSLOG) && \
defined(CONFIG_RAMLOG_SYSLOG) && !defined(CONFIG_NSH_DISABLE_DMESG)
int cmd_dmesg(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{
return cat_common(vtbl, argv[0], "/dev/syslog");
return cat_common(vtbl, argv[0], CONFIG_SYSLOG_DEVPATH);
}
#endif

View File

@ -167,7 +167,7 @@ static const struct cmdmap_s g_cmdmap[] =
# ifndef CONFIG_NSH_DISABLE_DD
{ "dd", cmd_dd, 3, 6, "if=<infile> of=<outfile> [bs=<sectsize>] [count=<sectors>] [skip=<sectors>]" },
# endif
# if defined(CONFIG_SYSLOG) && !defined(CONFIG_NSH_DISABLE_DMESG)
# if defined(CONFIG_SYSLOG) && defined(CONFIG_RAMLOG_SYSLOG) && !defined(CONFIG_NSH_DISABLE_DMESG)
{ "dmesg", cmd_dmesg, 1, 1, NULL },
# endif
#endif

View File

@ -3099,4 +3099,15 @@
* sched/on_exit.c, sched/task_exithook.c, and include/nuttx/sched.c: Add
support for multiple registered on_exit() functions if CONFIG_SCHED_ONEXIT_MAX
is defined.
* drivers/syslog/ramlog.c: Move the RAM SYSLOG device into drivers/syslog
so that it will be in the same directory as some new SYSLOGing devices
in the works.
* include/nuttx/syslog.h and drivers/syslog/ramlog.c: The SYSLOG putc function
now has a common name that is independent of the device that provides the
SYSLOG.
* include/nuttx/syslog.h and drivers/syslog/syslog.c: This is a new, generic
SYSLOG device that can redirect debug output to any character device or file.
So you can log debug output to a file or you can put the console on /dev/ttyS0
and the debug output on /dev/ttyS1.

View File

@ -4063,7 +4063,6 @@ build
<code>CONFIG_SIG_SIGWORK</code>: The signal number that will be used to wake-up
the worker thread. Default: 4
</li>
<li>
<code>CONFIG_SCHED_WAITPID</code>: Enables the <a href="NuttxUserGuide.html#waitpid"><code>waitpid()</code><a> API
</li>
@ -4090,10 +4089,23 @@ build
<li>
<code>CONFIG_SYSLOG</code>: Enables general system logging support.
</li>
<code>CONFIG_SYSLOG_DEVPATH</code>: The full path to the system logging device.
Default <code>&quot;/dev/ramlog&quot;</code> (RAMLOG) or <code>&quot;dev/ttyS1;</code> (CHARDEV).
<p>
At present, the only system loggin device is a circular buffer in RAM.
At present, there are two system loggins devices available.
If <code>CONFIG_SYSLOG</code> is selected, then these options are also available.
</p>
<p>
First, any a generic character device that may be used as the SYSLOG.
</p>
<li>
<code>CONFIG_SYSLOG_CHAR</code>:
Enable the generic character device for the SYSLOG.
NOTE: No more than one SYSLOG device should be configured.
<p>
Alternatively, a circular buffer in RAM can be used as the SYSLOGing device.
The contents of this RAM buffer can be dumped using the NSH dmesg command.
</p>
<li>
<code>CONFIG_RAMLOG</code>: Enables the RAM logging feature
</li>

View File

@ -8,7 +8,7 @@
<tr align="center" bgcolor="#e4e4e4">
<td>
<h1><big><font color="#3c34ec"><i>NuttX README Files</i></font></big></h1>
<p>Last Updated: July 4, 2012</p>
<p>Last Updated: August 1, 2012</p>
</td>
</tr>
</table>
@ -219,6 +219,8 @@
| | | `- <a href="http://nuttx.svn.sourceforge.net/viewvc/nuttx/trunk/nuttx/drivers/lcd/README.txt?view=log"><b><i>README.txt</i></b></a>
| | |- sercomm/
| | | `- <a href="http://nuttx.svn.sourceforge.net/viewvc/nuttx/trunk/nuttx/drivers/sercomm/README.txt?view=log">README.txt</a>
| | |- syslog/
| | | `- <a href="http://nuttx.svn.sourceforge.net/viewvc/nuttx/trunk/nuttx/drivers/syslog/README.txt?view=log">README.txt</a>
| | `- <a href="http://nuttx.svn.sourceforge.net/viewvc/nuttx/trunk/nuttx/drivers/README.txt?view=log"><b><i>README.txt</i></b></a>
| |- fs/
| | |- mmap/

View File

@ -788,6 +788,8 @@ nuttx
| | `- README.txt
| |- sercomm/
| | `- README.txt
| |- syslog/
| | `- README.txt
| `- README.txt
|- fs/
| |- mmap/

View File

@ -20,7 +20,7 @@ nuttx/
(5) Graphics subystem (graphics/)
(1) Pascal add-on (pcode/)
(1) Documentation (Documentation/)
(7) Build system / Toolchains
(6) Build system / Toolchains
(5) Linux/Cywgin simulation (arch/sim)
(5) ARM (arch/arm/)
(1) ARM/C5471 (arch/arm/src/c5471/)
@ -600,6 +600,11 @@ o Libraries (lib/)
Description: Need some minimal termios support... at a minimum, enough to
switch between raw and "normal" modes to support behavior like
that needed for readline().
UPDATE: There is growing functionality in lib/termios/ and in the
ioctl methods of several MCU serial drivers (stm32, lpc43, lpc17,
pic32). However, as phrased, this bug cannot yet be closed since
this "growing functionality" does not address all termios.h
functionality and not all serial drivers support termios.
Status: Open
Priority: Low
@ -827,21 +832,13 @@ o Documentation (Documentation/)
o Build system
^^^^^^^^^^^^
Title: DEPENDENCIES IN THE BOARD DIRECTORY
Description: Dependencies do not work correctly under configs/<board>/src
(same as arch/<arch>/src/board).
UPDATE: Added the following to each arch/*/src/Makefile:
PHONY: board/libboard$(LIBEXT)
However, I have not confirmed that this a full-proof fix in
all cases -- still under test (thanks to Mike Smith).
Status: Open
Priority: Medium (maybe higher for z80 target)
Title: NUTTX CONFIGURATION TOOL
Description: Need a NuttX configuration tool. The number of configuration
settings has become quite large and difficult to manage manually.
Update: This task is essentially completed. But probably not for
all platforms and all features. When do we know that the the
features is complete and that we can switch to exclusive use of
the tool?
Status: Open
Priority: Medium-low

View File

@ -173,11 +173,14 @@ void up_initialize(void)
/* Initialize the system logging device */
#ifdef CONFIG_SYSLOG_CHAR
syslog_initialize();
#endif
#ifdef CONFIG_RAMLOG_SYSLOG
ramlog_sysloginit();
#endif
/* Initialize the netwok */
/* Initialize the network */
up_netinitialize();

View File

@ -84,6 +84,7 @@
/* Determine which device to use as the system logging device */
#ifndef CONFIG_SYSLOG
# undef CONFIG_SYSLOG_CHAR
# undef CONFIG_RAMLOG_SYSLOG
#endif

View File

@ -171,6 +171,7 @@
/* Determine which device to use as the system logging device */
#ifndef CONFIG_SYSLOG
# undef CONFIG_SYSLOG_CHAR
# undef CONFIG_RAMLOG_SYSLOG
#endif

View File

@ -90,6 +90,7 @@
/* Determine which device to use as the system logging device */
#ifndef CONFIG_SYSLOG
# undef CONFIG_SYSLOG_CHAR
# undef CONFIG_RAMLOG_SYSLOG
#endif

View File

@ -95,6 +95,7 @@
/* Determine which device to use as the system logging device */
#ifndef CONFIG_SYSLOG
# undef CONFIG_SYSLOG_CHAR
# undef CONFIG_RAMLOG_SYSLOG
#endif

View File

@ -81,6 +81,7 @@
/* Determine which device to use as the system logging device */
#ifndef CONFIG_SYSLOG
# undef CONFIG_SYSLOG_CHAR
# undef CONFIG_RAMLOG_SYSLOG
#endif
@ -193,11 +194,14 @@ void up_initialize(void)
/* Initialize the system logging device */
#ifdef CONFIG_SYSLOG_CHAR
syslog_initialize();
#endif
#ifdef CONFIG_RAMLOG_SYSLOG
ramlog_sysloginit();
#endif
/* Initialize the netwok */
/* Initialize the network */
up_netinitialize();

View File

@ -161,11 +161,14 @@ void up_initialize(void)
/* Initialize the system logging device */
#ifdef CONFIG_SYSLOG_CHAR
syslog_initialize();
#endif
#ifdef CONFIG_RAMLOG_SYSLOG
ramlog_sysloginit();
#endif
/* Initialize the netwok */
/* Initialize the network */
up_netinitialize();

View File

@ -84,6 +84,7 @@
/* Determine which device to use as the system logging device */
#ifndef CONFIG_SYSLOG
# undef CONFIG_SYSLOG_CHAR
# undef CONFIG_RAMLOG_SYSLOG
#endif

View File

@ -163,11 +163,14 @@ void up_initialize(void)
/* Initialize the system logging device */
#ifdef CONFIG_SYSLOG_CHAR
syslog_initialize();
#endif
#ifdef CONFIG_RAMLOG_SYSLOG
ramlog_sysloginit();
#endif
/* Initialize the netwok */
/* Initialize the network */
up_netinitialize();

View File

@ -84,6 +84,7 @@
/* Determine which device to use as the system logging device */
#ifndef CONFIG_SYSLOG
# undef CONFIG_SYSLOG_CHAR
# undef CONFIG_RAMLOG_SYSLOG
#endif

View File

@ -153,6 +153,9 @@ void up_initialize(void)
/* Initialize the system logging device */
#ifdef CONFIG_SYSLOG_CHAR
syslog_initialize();
#endif
#ifdef CONFIG_RAMLOG_SYSLOG
ramlog_sysloginit();
#endif

View File

@ -88,6 +88,7 @@
/* Determine which device to use as the system logging device */
#ifndef CONFIG_SYSLOG
# undef CONFIG_SYSLOG_CHAR
# undef CONFIG_RAMLOG_SYSLOG
#endif

View File

@ -107,6 +107,9 @@ void up_initialize(void)
ramlog_consoleinit();
#endif
#ifdef CONFIG_SYSLOG_CHAR
syslog_initialize();
#endif
#ifdef CONFIG_RAMLOG_SYSLOG
ramlog_sysloginit(); /* System logging device */
#endif
@ -116,6 +119,6 @@ void up_initialize(void)
#endif
#ifdef CONFIG_NET
uipdriver_init(); /* Our "real" netwok driver */
uipdriver_init(); /* Our "real" network driver */
#endif
}

View File

@ -79,6 +79,7 @@
/* Determine which device to use as the system logging device */
#ifndef CONFIG_SYSLOG
# undef CONFIG_SYSLOG_CHAR
# undef CONFIG_RAMLOG_SYSLOG
#endif

View File

@ -163,11 +163,14 @@ void up_initialize(void)
/* Initialize the system logging device */
#ifdef CONFIG_SYSLOG_CHAR
syslog_initialize();
#endif
#ifdef CONFIG_RAMLOG_SYSLOG
ramlog_sysloginit();
#endif
/* Initialize the netwok */
/* Initialize the network */
up_netinitialize();

View File

@ -83,6 +83,7 @@
/* Determine which device to use as the system logging device */
#ifndef CONFIG_SYSLOG
# undef CONFIG_SYSLOG_CHAR
# undef CONFIG_RAMLOG_SYSLOG
#endif

View File

@ -178,11 +178,14 @@ void up_initialize(void)
/* Initialize the system logging device */
#ifdef CONFIG_SYSLOG_CHAR
syslog_initialize();
#endif
#ifdef CONFIG_RAMLOG_SYSLOG
ramlog_sysloginit();
#endif
/* Initialize the netwok */
/* Initialize the network */
up_netinitialize();
up_ledon(LED_IRQSENABLED);

View File

@ -74,6 +74,7 @@
/* Determine which device to use as the system logging device */
#ifndef CONFIG_SYSLOG
# undef CONFIG_SYSLOG_CHAR
# undef CONFIG_RAMLOG_SYSLOG
#endif

View File

@ -362,14 +362,29 @@ defconfig -- This is a configuration file similar to the Linux
thread. Default: CONFIG_IDLETHREAD_STACKSIZE.
CONFIG_SIG_SIGWORK - The signal number that will be used to wake-up
the worker thread. Default: 4
CONFIG_SCHED_WAITPID - Enables the waitpid() API
CONFIG_SCHED_ATEXIT - Enables the atexit() API
CONFIG_SCHED_ATEXIT_MAX - By default if CONFIG_SCHED_ATEXIT is
selected, only a single atexit() function is supported. That number
can be increased by defined this setting to the number that you require.
CONFIG_SCHED_ONEXIT - Enables the on_exit() API
CONFIG_SCHED_ONEXIT_MAX - By default if CONFIG_SCHED_ONEXIT is selected,
only a single on_exit() function is supported. That number can be
increased by defined this setting to the number that you require.
System Logging:
CONFIG_SYSLOG enables general system logging support.
CONFIG_SYSLOG_DEVPATH - The full path to the system logging device. Default
"/dev/ramlog" (RAMLOG) or "dev/ttyS1" (character device)
At present, the only system loggin device is a circular buffer in RAM.
If CONFIG_SYSLOG is selected, then these options are also available.
At present, there are two system loggins devices available. If CONFIG_SYSLOG
is selected, then these options are also available.
CONFIG_RAMLOG - Enables the RAM logging feature
CONFIG_SYSLOG_CHAR - Enable the generic character device for the SYSLOG.
NOTE: No more than one SYSLOG device should be configured.
CONFIG_RAMLOG - Enables the RAM logging feature. The RAM log is a circular
buffer in RAM. NOTE: No more than one SYSLOG device should be configured.
CONFIG_RAMLOG_CONSOLE - Use the RAM logging device as a system console.
If this feature is enabled (along with CONFIG_DEV_CONSOLE), then all
console output will be re-directed to a circular buffer in RAM. This

View File

@ -29,70 +29,6 @@ config RAMDISK
a block driver that can be mounted as a files system. See
include/nuttx/ramdisk.h.
config RAMLOG
bool "RAM log message support"
default n
---help---
This is a driver that was intended to support debugging output,
aka syslogging, when the normal serial output is not available.
For example, if you are using a telnet or USB serial console,
the debug output will get lost.
This driver is similar to a pipe in that it saves the debugging
output in a FIFO in RAM. It differs from a pipe in numerous
details as needed to support logging.
if RAMLOG
config RAMLOG_SYSLOG
bool "Use RAMLOG for SYSLOG"
default n
depends on SYSLOG
---help---
Use the RAM logging device for the syslogging interface. If this feature
is enabled (along with SYSLOG), then all debug output (only) will be re-directed
to the circular buffer in RAM. This RAM log can be view from NSH using the
'dmesg'command.
config RAMLOG_CONSOLE
bool "Use RAMLOG for /dev/console"
default n
depends on DEV_CONSOLE
---help---
Use the RAM logging device as a system console. If this feature is enabled (along
with DEV_CONSOLE), then all console output will be re-directed to a circular
buffer in RAM. 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 circular buffer and can be viewed using the NSH 'dmesg' command.
config RAMLOG_CONSOLE_BUFSIZE
int "RAMLOG buffer size"
default 1024
depends on RAMLOG_SYSLOG || RAMLOG_CONSOLE
---help---
Size of the console RAM log. Default: 1024
config RAMLOG_CRLF
bool "RAMLOG CR/LF"
default n
---help---
Pre-pend a carriage return before every linefeed that goes into the RAM log.
config RAMLOG_NONBLOCKING
bool "RAMLOG non-block reads"
default y
---help---
Reading from the RAMLOG will never block if the RAMLOG is empty. If the RAMLOG
is empty, then zero is returned (usually interpreted as end-of-file).
config RAMLOG_NPOLLWAITERS
int "RAMLOG number of poll waiters"
default 4
depends on !DISABLE_POLL
---help---
The maximum number of threads that may be waiting on the poll method.
endif
config CAN
bool "CAN support"
default n
@ -387,3 +323,7 @@ menuconfig WIRELESS
if WIRELESS
source drivers/wireless/Kconfig
endif
source drivers/syslog/Kconfig

View File

@ -60,6 +60,7 @@ include power/Make.defs
include sensors/Make.defs
include sercomm/Make.defs
include serial/Make.defs
include syslog/Make.defs
include usbdev/Make.defs
include usbhost/Make.defs
include wireless/Make.defs
@ -71,10 +72,6 @@ ifneq ($(CONFIG_DISABLE_MOUNTPOINT),y)
CSRCS += ramdisk.c rwbuffer.c
endif
ifeq ($(CONFIG_RAMLOG),y)
CSRCS += ramlog.c
endif
ifeq ($(CONFIG_CAN),y)
CSRCS += can.c
endif

View File

@ -1,6 +1,7 @@
############################################################################
# drivers/mtd/Make.defs
# This driver supports a block of RAM as a NuttX MTD device
# These driver supports various Memory Technology Devices (MTD) using the
# NuttX MTD interface.
#
# Copyright (C) 2009-2012 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>

View File

@ -0,0 +1,67 @@
############################################################################
# drivers/syslog/Make.defs
# These drivers support system logging devices
#
# Copyright (C) 2012 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# 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.
#
############################################################################
# Include SYSLOG drivers (only one should be enabled)
ifeq ($(CONFIG_SYSLOG),y)
ifeq ($(CONFIG_SYSLOG_CHAR),y)
CSRCS += syslog.c
endif
ifeq ($(CONFIG_RAMLOG),y)
CSRCS += ramlog.c
endif
# Include SYSLOG build support
DEPPATH += --dep-path syslog
VPATH += :syslog
else
# The RAMLOG can be used even if system logging is not enabled.
ifeq ($(CONFIG_RAMLOG),y)
# Include RAMLOG build support
CSRCS += ramlog.c
DEPPATH += --dep-path syslog
VPATH += :syslog
endif
endif

View File

@ -0,0 +1,46 @@
drivers/syslog README File
==========================
This README file discusses the SYLOG drivers that can be found in the
drivers/syslog directory. In NuttX, syslog output is equivalent to
debug output and, therefore, the syslogging interfaces are defined in the
header file include/debug.h.
By default, all system log output goes to console (/dev/console). But that
behavior can be changed by the drivers in this directory.
ramlog.c
--------
The RAM logging driver is a driver that was intended to support debugging
output (syslogging) when the normal serial output is not available. For
example, if you are using a telnet or USB serial console, the debug
output will get lost.
The RAM logging driver is similar to a pipe in that it saves the
debugging output in a FIFO in RAM. It differs from a pipe in numerous
details as needed to support logging.
This driver is built when CONFIG_RAMLOG is defined in the Nuttx
configuration.
Configuration options:
CONFIG_RAMLOG - Enables the RAM logging feature
CONFIG_RAMLOG_CONSOLE - Use the RAM logging device as a system console.
If this feature is enabled (along with CONFIG_DEV_CONSOLE), then all
console output will be re-directed to a circular buffer in RAM. 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
circular buffer and can be viewed using the NSH 'dmesg' command.
CONFIG_RAMLOG_SYSLOG - Use the RAM logging device for the syslogging
interface. If this feature is enabled (along with CONFIG_SYSLOG),
then all debug output (only) will be re-directed to the circular
buffer in RAM. This RAM log can be view from NSH using the 'dmesg'
command.
CONFIG_RAMLOG_NPOLLWAITERS - The number of threads than can be waiting
for this driver on poll(). Default: 4
If CONFIG_RAMLOG_CONSOLE or CONFIG_RAMLOG_SYSLOG is selected, then the
following may also be provided:
CONFIG_RAMLOG_CONSOLE_BUFSIZE - Size of the console RAM log. Default: 1024

View File

@ -1,5 +1,5 @@
/****************************************************************************
* drivers/ramlog.c
* drivers/syslog/ramlog.c
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -139,8 +139,8 @@ static const struct file_operations g_ramlogfops =
static char g_sysbuffer[CONFIG_RAMLOG_CONSOLE_BUFSIZE];
/* This is the device structure for the console or syslogging function. It
* must be statically initialized because the ramlog_putc function could be
* called before the driver initialization logic executes.
* must be statically initialized because the RAMLOG syslog_putc function
* could be called before the driver initialization logic executes.
*/
static struct ramlog_dev_s g_sysdev =
@ -705,7 +705,7 @@ int ramlog_consoleinit(void)
*
* Description:
* Create the RAM logging device and register it at the specified path.
* Mostly likely this path will be /dev/syslog
* Mostly likely this path will be CONFIG_RAMLOG_SYSLOG
*
* If CONFIG_RAMLOG_CONSOLE is also defined, then this functionality is
* performed when ramlog_consoleinit() is called.
@ -717,12 +717,12 @@ int ramlog_sysloginit(void)
{
/* Register the syslog character driver */
return register_driver("/dev/syslog", &g_ramlogfops, 0666, &g_sysdev);
return register_driver(CONFIG_SYSLOG_DEVPATH, &g_ramlogfops, 0666, &g_sysdev);
}
#endif
/****************************************************************************
* Name: ramlog
* Name: syslog_putc
*
* Description:
* This is the low-level system logging interface. The debugging/syslogging
@ -730,12 +730,12 @@ int ramlog_sysloginit(void)
* the lib_rawprintf() writes to fd=1 (stdout) and lib_lowprintf() uses
* a lower level interface that works from interrupt handlers. This
* function is a a low-level interface used to implement lib_lowprintf()
* when CONFIG_RAMLOG_SYSLOG=y and CONFIG_SYSLOG=ramlog
* when CONFIG_RAMLOG_SYSLOG=y and CONFIG_SYSLOG=y
*
****************************************************************************/
#if defined(CONFIG_RAMLOG_CONSOLE) || defined(CONFIG_RAMLOG_SYSLOG)
int ramlog_putc(int ch)
int syslog_putc(int ch)
{
FAR struct ramlog_dev_s *priv = &g_sysdev;
int ret;

View File

@ -0,0 +1,177 @@
/****************************************************************************
* drivers/syslog/syslog.c
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 <stdint.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <nuttx/syslog.h>
#if defined(CONFIG_SYSLOG) && defined(CONFIG_SYSLOG_CHAR)
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
struct syslog_dev_s
{
int fd; /* File descriptor of the opened SYSLOG character device */
};
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/* This is the device structure for the console or syslogging function. It
* must be statically initialized because the RAMLOG syslog_putc function
* could be called before the driver initialization logic executes.
*/
static struct syslog_dev_s g_sysdev = { -1 };
static const uint8_t g_syscrlf[2] = { '\r', '\n' };
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: syslog_initialize
*
* Description:
* Initialize to use the character device at CONFIG_SYSLOG_DEVPATH as the
* SYSLOG.
*
****************************************************************************/
int syslog_initialize(void)
{
/* Has the device been opened yet */
if (g_sysdev.fd < 0)
{
/* No, try to open the device now: write-only, try to create it if
* it doesn't exist (it might be a file), if it is a file that already
* exists, then append new log data to the file.
*/
g_sysdev.fd = open(CONFIG_SYSLOG_DEVPATH, O_WRONLY | O_CREAT | O_APPEND, 0644);
if (g_sysdev.fd < 0)
{
return -get_errno();
}
}
/* The SYSLOG device is open and ready for writing. */
return OK;
}
/****************************************************************************
* Name: syslog_putc
*
* Description:
* This is the low-level system logging interface. The debugging/syslogging
* interfaces are lib_rawprintf() and lib_lowprinf(). The difference is
* the lib_rawprintf() writes to fd=1 (stdout) and lib_lowprintf() uses
* a lower level interface that works from interrupt handlers. This
* function is a a low-level interface used to implement lib_lowprintf().
*
****************************************************************************/
int syslog_putc(int ch)
{
ssize_t nbytes;
int ret;
/* Try to initialize the device. We do this repeatedly because the log
* device might be something that was not ready the first time that
* syslog_intialize() was called (such as a USB serial device or a file
* in an NFS mounted file system.
*/
ret = syslog_initialize();
if (ret < 0)
{
return ret;
}
/* Ignore carriage returns */
if (ch == '\r')
{
return ch;
}
/* Pre-pend a newline with a carriage return */
if (ch == '\n')
{
nbytes = write(g_sysdev.fd, g_syscrlf, 2);
}
else
{
nbytes = write(g_sysdev.fd, &ch, 1);
}
if (nbytes < 0)
{
return nbytes;
}
return ch;
}
#endif /* CONFIG_SYSLOG && CONFIG_SYSLOG_CHAR */

View File

@ -86,7 +86,7 @@ config HIDKBD_NODEBOUNCE
---help---
If set to y normal debouncing is disabled. Default:
Debounce enabled (No repeat keys).
USB host mass storage class driver. Requires CONFIG_USBHOST=y,
config USBHOST_BULK_DISABLE=n, CONFIG_NFILE_DESCRIPTORS > 0,
and CONFIG_SCHED_WORKQUEUE=y
USB host mass storage class driver. Requires USBHOST=y,
config USBHOST_BULK_DISABLE=n, NFILE_DESCRIPTORS > 0,
and SCHED_WORKQUEUE=y
endif

View File

@ -54,6 +54,7 @@
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/syslog.h>
#ifdef CONFIG_RAMLOG
@ -90,6 +91,10 @@
# undef CONFIG_RAMLOG_SYSLOG
#endif
#if defined(CONFIG_RAMLOG_SYSLOG) && !defined(CONFIG_SYSLOG_DEVPATH)
# define CONFIG_SYSLOG_DEVPATH "/dev/ramlog"
#endif
#ifndef CONFIG_RAMLOG_NPOLLWAITERS
# define CONFIG_RAMLOG_NPOLLWAITERS 4
#endif
@ -167,7 +172,7 @@ EXTERN int ramlog_register(FAR const char *devpath, FAR char *buffer,
* Mostly likely this path will be /dev/console.
*
* If CONFIG_RAMLOG_SYSLOG is also defined, then the same RAM logging
* device is also registered at /dev/syslog
* device is also registered at CONFIG_SYSLOG_DEVPATH
*
****************************************************************************/
@ -180,7 +185,7 @@ EXTERN int ramlog_consoleinit(void);
*
* Description:
* Create the RAM logging device and register it at the specified path.
* Mostly likely this path will be /dev/syslog
* Mostly likely this path will be CONFIG_SYSLOG_DEVPATH
*
* If CONFIG_RAMLOG_CONSOLE is also defined, then this functionality is
* performed when ramlog_consoleinit() is called.
@ -191,23 +196,6 @@ EXTERN int ramlog_consoleinit(void);
EXTERN int ramlog_sysloginit(void);
#endif
/****************************************************************************
* Name: ramlog
*
* Description:
* This is the low-level system logging interface. The debugging/syslogging
* interfaces are lib_rawprintf() and lib_lowprinf(). The difference is
* the lib_rawprintf() writes to fd=1 (stdout) and lib_lowprintf() uses
* a lower level interface that works from interrupt handlers. This
* function is a a low-level interface used to implement lib_lowprintf()
* when CONFIG_RAMLOG_SYSLOG=y and CONFIG_SYSLOG=ramlog
*
****************************************************************************/
#if defined(CONFIG_RAMLOG_CONSOLE) || defined(CONFIG_RAMLOG_SYSLOG)
EXTERN int ramlog_putc(int ch);
#endif
#undef EXTERN
#ifdef __cplusplus
}

View File

@ -0,0 +1,131 @@
/****************************************************************************
* include/nuttx/syslog.h
* The NuttX SYSLOGing interface
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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_H
#define __INCLUDE_NUTTX_SYSLOG_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* CONFIG_SYSLOG - Enables generic system logging features.
* CONFIG_SYSLOG_DEVPATH - The full path to the system logging device
*
* In addition, some SYSLOG device must also be enabled that will provide
* the syslog_putc() function. As of this writing, there are two SYSLOG
* devices avaiable:
*
* 1. A RAM SYSLOGing device that will log data into a circular buffer
* that can be dumped using the NSH dmesg command. This device is
* described in the include/nuttx/ramlog.h header file.
*
* 2. And a generic character device that may be used as the SYSLOG. The
* generic device interfaces are described in this file.
*
* CONFIG_SYSLOG_CHAR - Enable the generic character device for the SYSLOG.
* The full path to the SYSLOG device is provided by CONFIG_SYSLOG_DEVPATH.
* A valid character device must exist at this path. It will by opened
* by syslog_initialize.
*
* NOTE: No more than one SYSLOG device should be configured.
*/
#ifndef CONFIG_SYSLOG
# undef CONFIG_SYSLOG_CHAR
#endif
#if defined(CONFIG_SYSLOG_CHAR) && !defined(CONFIG_SYSLOG_DEVPATH)
# define CONFIG_SYSLOG_DEVPATH "/dev/ttyS1"
#endif
/****************************************************************************
* Public Data
****************************************************************************/
#ifndef __ASSEMBLY__
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: syslog_initialize
*
* Description:
* Initialize to use the character device at CONFIG_SYSLOG_DEVPATH as the
* SYSLOG.
*
****************************************************************************/
#ifdef CONFIG_SYSLOG_CHAR
EXTERN int syslog_initialize(void);
#endif
/****************************************************************************
* Name: syslog_putc
*
* Description:
* This is the low-level system logging interface. The debugging/syslogging
* interfaces are lib_rawprintf() and lib_lowprinf(). The difference is
* the lib_rawprintf() writes to fd=1 (stdout) and lib_lowprintf() uses
* a lower level interface that works from interrupt handlers. This
* function is a a low-level interface used to implement lib_lowprintf().
*
****************************************************************************/
#ifdef CONFIG_SYSLOG
EXTERN int syslog_putc(int ch);
#endif
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __INCLUDE_NUTTX_SYSLOG_H */

View File

@ -94,7 +94,7 @@ int lib_lowvprintf(const char *fmt, va_list ap)
/* Wrap the stdout in a stream object and let lib_vsprintf do the work. */
#if defined(CONFIG_RAMLOG_CONSOLE) || defined(CONFIG_RAMLOG_SYSLOG)
#ifdef CONFIG_SYSLOG
lib_syslogstream((FAR struct lib_outstream_s *)&stream);
#else
lib_lowoutstream((FAR struct lib_outstream_s *)&stream);

View File

@ -42,7 +42,7 @@
#include <unistd.h>
#include <errno.h>
#include <nuttx/ramlog.h>
#include <nuttx/syslog.h>
#include "lib_internal.h"
@ -62,12 +62,10 @@
static void syslogstream_putc(FAR struct lib_outstream_s *this, int ch)
{
/* At present, the RAM log is the only supported logging device */
/* Write the character to the supported logging device */
#ifdef CONFIG_RAMLOG_SYSLOG
(void)ramlog_putc(ch);
(void)syslog_putc(ch);
this->nput++;
#endif
}
/****************************************************************************

View File

@ -124,6 +124,84 @@ config SDCLONE_DISABLE
desciptors by task_create() when a new task is started. If
set, all sockets will appear to be closed in the new task.
config SCHED_WORKQUEUE
bool "Enable worker thread"
default n
---help---
Create a dedicated "worker" thread to handle delayed processing from interrupt
handlers. This feature is required for some drivers but, if there are no
complaints, can be safely disabled. The worker thread also performs
garbage collection -- completing any delayed memory deallocations from
interrupt handlers. If the worker thread is disabled, then that clean up will
be performed by the IDLE thread instead (which runs at the lowest of priority
and may not be appropriate if memory reclamation is of high priority).
config SCHED_WORKPRIORITY
int "Worker thread priority"
default 192
depends on SCHED_WORKQUEUE
---help---
The execution priority of the worker thread. Default: 192
config SCHED_WORKPERIOD
int "Worker thread period"
default 50000
depends on SCHED_WORKQUEUE
---help---
How often the worker thread checks for work in units of microseconds.
Default: 50*1000 (50 MS).
config SCHED_WORKSTACKSIZE
int "Worker thread stack size"
default 2048
depends on SCHED_WORKQUEUE
---help---
The stack size allocated for the worker thread. Default: 2K.
config SIG_SIGWORK
int "Worker thread wakeup signal"
default 4
depends on SCHED_WORKQUEUE
---help---
The signal number that will be used to wake-up the worker thread.
Default: 4
config SCHED_WAITPID
bool "Enable waitpid() API"
default n
---help---
Enables the waitpid() API
config SCHED_ATEXIT
bool "Enable atexit() API"
default n
---help---
Enables the atexit() API
config SCHED_ATEXIT_MAX
int "Max number of atexit() functions"
default 1
depends on SCHED_ATEXIT
---help---
By default if SCHED_ATEXIT is selected, only a single atexit() function
is supported. That number can be increased by defined this setting to
the number that you require.
config SCHED_ONEXIT
bool "Enable on_exit() API"
default n
---help---
Enables the on_exit() API
config SCHED_ONEXIT_MAX
int "Max number of on_exit() functions"
default 1
depends on SCHED_ONEXIT
---help---
By default if SCHED_ONEXIT is selected, only a single on_exit() function
is supported. That number can be increased by defined this setting to the
number that you require.
config DISABLE_OS_API
bool "Disable NuttX interfaces"
default n