From 51f649620cc2be02b02f31ec872920e5ba2afb79 Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 28 Mar 2012 17:19:17 +0000 Subject: NX console should only be available if NX multi-user mode is enabled git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4535 42af7a65-404d-4744-a932-0658087f49c3 --- apps/examples/README.txt | 29 ++++----- apps/examples/nxconsole/Makefile | 6 +- apps/examples/nxconsole/nxcon_internal.h | 72 ++++++++++----------- apps/examples/nxconsole/nxcon_main.c | 104 +------------------------------ apps/examples/nxconsole/nxcon_server.c | 6 +- 5 files changed, 55 insertions(+), 162 deletions(-) (limited to 'apps/examples') diff --git a/apps/examples/README.txt b/apps/examples/README.txt index 01d4fb0ec..6cd1051bc 100644 --- a/apps/examples/README.txt +++ b/apps/examples/README.txt @@ -618,8 +618,19 @@ examples/nxconsole ^^^^^^^^^^^^^^^^^^ This directory contains a simple test of the NX console device defined in - include/nuttx/nx/nxconsole.h. The following configuration options - can be selected: + include/nuttx/nx/nxconsole.h. Prerequisite configuration settings for this + test include: + + CONFIG_NX=y -- NX graphics must be enabled + CONFIG_NXCONSOLE=y -- The NX console driver must be built + CONFIG_NX_MULTIUSER=y -- NX multi-user support must be enabled. + CONFIG_DISABLE_MQUEUE=n -- Message queue support must be available. + CONFIG_DISABLE_SIGNALS=n -- Signals are needed + CONFIG_DISABLE_PTHREAD=n -- pthreads are needed + CONFIG_NX_BLOCKING=y -- pthread APIs must be blocking + + The following configuration options can be selected to customize the + test: CONFIG_NSH_BUILTIN_APPS -- Build the NX example as a "built-in" that can be executed from the NSH command line @@ -659,10 +670,8 @@ examples/nxconsole NX console device corresponding to CONFIG_EXAMPLES_NXCON_MINOR. Default: "/dev/nxcon0" - This test can be performed with either the single-user version of - NX or with the multiple user version of NX selected with CONFIG_NX_MULTIUSER. - If CONFIG_NX_MULTIUSER is defined, then the following configuration - options also apply: + The following configuration settings determine how to set up the NX + server (CONFIG_NX_MULTIUSER): CONFIG_EXAMPLES_NXCON_STACKSIZE -- The stacksize to use when creating the NX server. Default 2048 @@ -673,14 +682,6 @@ examples/nxconsole CONFIG_EXAMPLES_NXCON_NOTIFYSIGNO -- The signal number to use with nx_eventnotify(). Default: 4 - If CONFIG_NX_MULTIUSER is defined, then the example also expects the - following settings and will generate an error if they are not as expected: - - CONFIG_DISABLE_MQUEUE=n - CONFIG_DISABLE_SIGNALS=n - CONFIG_DISABLE_PTHREAD=n - CONFIG_NX_BLOCKING=y - examples/nxffs ^^^^^^^^^^^^^^ diff --git a/apps/examples/nxconsole/Makefile b/apps/examples/nxconsole/Makefile index 0816fc96e..2a04f982e 100644 --- a/apps/examples/nxconsole/Makefile +++ b/apps/examples/nxconsole/Makefile @@ -40,11 +40,7 @@ include $(APPDIR)/Make.defs # NuttX NX Console Example. ASRCS = -CSRCS = nxcon_main.c nxcon_toolbar.c nxcon_wndo.c - -ifeq ($(CONFIG_NX_MULTIUSER),y) -CSRCS += nxcon_server.c -endif +CSRCS = nxcon_main.c nxcon_toolbar.c nxcon_wndo.c nxcon_server.c AOBJS = $(ASRCS:.S=$(OBJEXT)) COBJS = $(CSRCS:.c=$(OBJEXT)) diff --git a/apps/examples/nxconsole/nxcon_internal.h b/apps/examples/nxconsole/nxcon_internal.h index fd3777334..96ea8f781 100644 --- a/apps/examples/nxconsole/nxcon_internal.h +++ b/apps/examples/nxconsole/nxcon_internal.h @@ -60,11 +60,15 @@ /* Configuration ************************************************************/ #ifndef CONFIG_NX -# error "NX is not enabled (CONFIG_NX)" +# error "NX is not enabled (CONFIG_NX=y)" #endif #ifndef CONFIG_NXCONSOLE -# error "NxConsole is not enabled (CONFIG_NXCONSOLE)" +# error "NxConsole is not enabled (CONFIG_NXCONSOLE=y)" +#endif + +#ifndef CONFIG_NX_MULTIUSER +# error "Multi-user NX support is required (CONFIG_NX_MULTIUSER=y)" #endif /* If not specified, assume that the hardware supports one video plane */ @@ -161,34 +165,32 @@ /* Multi-user NX support */ -#ifdef CONFIG_NX_MULTIUSER -# ifdef CONFIG_DISABLE_MQUEUE -# error "The multi-threaded example requires MQ support (CONFIG_DISABLE_MQUEUE=n)" -# endif -# ifdef CONFIG_DISABLE_SIGNALS -# error "This example requires signal support (CONFIG_DISABLE_SIGNALS=n)" -# endif -# ifdef CONFIG_DISABLE_PTHREAD -# error "This example requires pthread support (CONFIG_DISABLE_PTHREAD=n)" -# endif -# ifndef CONFIG_NX_BLOCKING -# error "This example depends on CONFIG_NX_BLOCKING" -# endif -# ifndef CONFIG_EXAMPLES_NXCON_STACKSIZE -# define CONFIG_EXAMPLES_NXCON_STACKSIZE 2048 -# endif -# ifndef CONFIG_EXAMPLES_NXCON_LISTENERPRIO -# define CONFIG_EXAMPLES_NXCON_LISTENERPRIO 100 -# endif -# ifndef CONFIG_EXAMPLES_NXCON_CLIENTPRIO -# define CONFIG_EXAMPLES_NXCON_CLIENTPRIO 100 -# endif -# ifndef CONFIG_EXAMPLES_NXCON_SERVERPRIO -# define CONFIG_EXAMPLES_NXCON_SERVERPRIO 120 -# endif -# ifndef CONFIG_EXAMPLES_NXCON_NOTIFYSIGNO -# define CONFIG_EXAMPLES_NXCON_NOTIFYSIGNO 4 -# endif +#ifdef CONFIG_DISABLE_MQUEUE +# error "The multi-threaded example requires MQ support (CONFIG_DISABLE_MQUEUE=n)" +#endif +#ifdef CONFIG_DISABLE_SIGNALS +# error "This example requires signal support (CONFIG_DISABLE_SIGNALS=n)" +#endif +#ifdef CONFIG_DISABLE_PTHREAD +# error "This example requires pthread support (CONFIG_DISABLE_PTHREAD=n)" +#endif +#ifndef CONFIG_NX_BLOCKING +# error "This example depends on CONFIG_NX_BLOCKING" +#endif +#ifndef CONFIG_EXAMPLES_NXCON_STACKSIZE +# define CONFIG_EXAMPLES_NXCON_STACKSIZE 2048 +#endif +#ifndef CONFIG_EXAMPLES_NXCON_LISTENERPRIO +# define CONFIG_EXAMPLES_NXCON_LISTENERPRIO 100 +#endif +#ifndef CONFIG_EXAMPLES_NXCON_CLIENTPRIO +# define CONFIG_EXAMPLES_NXCON_CLIENTPRIO 100 +#endif +#ifndef CONFIG_EXAMPLES_NXCON_SERVERPRIO +# define CONFIG_EXAMPLES_NXCON_SERVERPRIO 120 +#endif +#ifndef CONFIG_EXAMPLES_NXCON_NOTIFYSIGNO +# define CONFIG_EXAMPLES_NXCON_NOTIFYSIGNO 4 #endif /* Graphics Device */ @@ -238,9 +240,7 @@ struct nxcon_state_s { volatile bool haveres; /* True: Have screen resolution */ -#ifdef CONFIG_NX_MULTIUSER - bool connected; /* True: Connected to server */ -#endif + volatile bool connected; /* True: Connected to server */ sem_t eventsem; /* Control waiting for display events */ NXHANDLE hnx; /* The connection handler */ NXTKWINDOW hwnd; /* The window */ @@ -269,13 +269,15 @@ extern const struct nx_callback_s g_nxtoolcb; /**************************************************************************** * Public Function Prototypes ****************************************************************************/ +/* Board-specific driver intiialization */ #ifdef CONFIG_EXAMPLES_NXCON_EXTERNINIT extern FAR NX_DRIVERTYPE *up_nxdrvinit(unsigned int devno); #endif -#if defined(CONFIG_NX) && defined(CONFIG_NX_MULTIUSER) + +/* Server thread support */ + extern int nxcon_server(int argc, char *argv[]); extern FAR void *nxcon_listener(FAR void *arg); -#endif #endif /* __EXAMPLES_NXCONSOLE_NXCON_INTERNAL_H */ diff --git a/apps/examples/nxconsole/nxcon_main.c b/apps/examples/nxconsole/nxcon_main.c index fad6b9c0c..8713be493 100644 --- a/apps/examples/nxconsole/nxcon_main.c +++ b/apps/examples/nxconsole/nxcon_main.c @@ -128,92 +128,11 @@ struct nxcon_state_s g_nxcon_vars; * Private Functions ****************************************************************************/ -/**************************************************************************** - * Name: nxcon_suinitialize - ****************************************************************************/ - -#ifndef CONFIG_NX_MULTIUSER -static inline int nxcon_suinitialize(void) -{ - FAR NX_DRIVERTYPE *dev; - -#if defined(CONFIG_EXAMPLES_NXCON_EXTERNINIT) - /* Use external graphics driver initialization */ - - message("nxcon_initialize: Initializing external graphics device\n"); - dev = up_nxdrvinit(CONFIG_EXAMPLES_NXCON_DEVNO); - if (!dev) - { - message("nxcon_initialize: up_nxdrvinit failed, devno=%d\n", CONFIG_EXAMPLES_NXCON_DEVNO); - return ERROR; - } - -#elif defined(CONFIG_NX_LCDDRIVER) - int ret; - - /* Initialize the LCD device */ - - message("nxcon_initialize: Initializing LCD\n"); - ret = up_lcdinitialize(); - if (ret < 0) - { - message("nxcon_initialize: up_lcdinitialize failed: %d\n", -ret); - return ERROR; - } - - /* Get the device instance */ - - dev = up_lcdgetdev(CONFIG_EXAMPLES_NXCON_DEVNO); - if (!dev) - { - message("nxcon_initialize: up_lcdgetdev failed, devno=%d\n", - CONFIG_EXAMPLES_NXCON_DEVNO); - return ERROR; - } - - /* Turn the LCD on at 75% power */ - - (void)dev->setpower(dev, ((3*CONFIG_LCD_MAXPOWER + 3)/4)); -#else - int ret; - - /* Initialize the frame buffer device */ - - message("nxcon_initialize: Initializing framebuffer\n"); - ret = up_fbinitialize(); - if (ret < 0) - { - message("nxcon_initialize: up_fbinitialize failed: %d\n", -ret); - return ERROR; - } - - dev = up_fbgetvplane(CONFIG_EXAMPLES_NXCON_VPLANE); - if (!dev) - { - message("nxcon_initialize: up_fbgetvplane failed, vplane=%d\n", CONFIG_EXAMPLES_NXCON_VPLANE); - return ERROR; - } -#endif - - /* Then open NX */ - - message("nxcon_initialize: Open NX\n"); - g_nxcon_vars.hnx = nx_open(dev); - if (!g_nxcon_vars.hnx) - { - message("nxcon_initialize: nx_open failed: %d\n", errno); - return ERROR; - } - return OK; -} -#endif - /**************************************************************************** * Name: nxcon_initialize ****************************************************************************/ -#ifdef CONFIG_NX_MULTIUSER -static inline int nxcon_muinitialize(void) +static int nxcon_initialize(void) { struct sched_param param; pthread_t thread; @@ -287,20 +206,6 @@ static inline int nxcon_muinitialize(void) } return OK; } -#endif - -/**************************************************************************** - * Name: nxcon_initialize - ****************************************************************************/ - -static int nxcon_initialize(void) -{ -#ifdef CONFIG_NX_MULTIUSER - return nxcon_muinitialize(); -#else - return nxcon_suinitialize(); -#endif -} /**************************************************************************** * Public Functions @@ -519,17 +424,10 @@ errout_with_hwnd: (void)nxtk_closewindow(g_nxcon_vars.hwnd); errout_with_nx: -#ifdef CONFIG_NX_MULTIUSER /* Disconnect from the server */ message(MAIN_NAME_STRING ": Disconnect from the server\n"); nx_disconnect(g_nxcon_vars.hnx); -#else - /* Close the server */ - - message(MAIN_NAME_STRING ": Close NX\n"); - nx_close(g_nxcon_vars.hnx); -#endif errout: return exitcode; } diff --git a/apps/examples/nxconsole/nxcon_server.c b/apps/examples/nxconsole/nxcon_server.c index 661479a4a..ccd000ec0 100644 --- a/apps/examples/nxconsole/nxcon_server.c +++ b/apps/examples/nxconsole/nxcon_server.c @@ -57,8 +57,6 @@ #include "nxcon_internal.h" -#ifdef CONFIG_NX_MULTIUSER - /**************************************************************************** * Definitions ****************************************************************************/ @@ -176,7 +174,7 @@ FAR void *nxcon_listener(FAR void *arg) */ message("nxcon_listener: Lost server connection: %d\n", errno); - exit(NXEXIT_LOSTSERVERCONN); + exit(EXIT_FAILURE); } /* If we received a message, we must be connected */ @@ -189,5 +187,3 @@ FAR void *nxcon_listener(FAR void *arg) } } } - -#endif /* CONFIG_NX_MULTIUSER */ -- cgit v1.2.3