NX console should only be available if NX multi-user mode is enabled

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4535 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo
2012-03-28 17:19:17 +00:00
parent 07e5222a41
commit 9e5d37dcdd
10 changed files with 85 additions and 177 deletions
+15 -14
View File
@@ -618,8 +618,19 @@ examples/nxconsole
^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^
This directory contains a simple test of the NX console device defined in This directory contains a simple test of the NX console device defined in
include/nuttx/nx/nxconsole.h. The following configuration options include/nuttx/nx/nxconsole.h. Prerequisite configuration settings for this
can be selected: 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" CONFIG_NSH_BUILTIN_APPS -- Build the NX example as a "built-in"
that can be executed from the NSH command line that can be executed from the NSH command line
@@ -659,10 +670,8 @@ examples/nxconsole
NX console device corresponding to CONFIG_EXAMPLES_NXCON_MINOR. NX console device corresponding to CONFIG_EXAMPLES_NXCON_MINOR.
Default: "/dev/nxcon0" Default: "/dev/nxcon0"
This test can be performed with either the single-user version of The following configuration settings determine how to set up the NX
NX or with the multiple user version of NX selected with CONFIG_NX_MULTIUSER. server (CONFIG_NX_MULTIUSER):
If CONFIG_NX_MULTIUSER is defined, then the following configuration
options also apply:
CONFIG_EXAMPLES_NXCON_STACKSIZE -- The stacksize to use when creating CONFIG_EXAMPLES_NXCON_STACKSIZE -- The stacksize to use when creating
the NX server. Default 2048 the NX server. Default 2048
@@ -673,14 +682,6 @@ examples/nxconsole
CONFIG_EXAMPLES_NXCON_NOTIFYSIGNO -- The signal number to use with CONFIG_EXAMPLES_NXCON_NOTIFYSIGNO -- The signal number to use with
nx_eventnotify(). Default: 4 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 examples/nxffs
^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
+1 -5
View File
@@ -40,11 +40,7 @@ include $(APPDIR)/Make.defs
# NuttX NX Console Example. # NuttX NX Console Example.
ASRCS = ASRCS =
CSRCS = nxcon_main.c nxcon_toolbar.c nxcon_wndo.c CSRCS = nxcon_main.c nxcon_toolbar.c nxcon_wndo.c nxcon_server.c
ifeq ($(CONFIG_NX_MULTIUSER),y)
CSRCS += nxcon_server.c
endif
AOBJS = $(ASRCS:.S=$(OBJEXT)) AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT)) COBJS = $(CSRCS:.c=$(OBJEXT))
+37 -35
View File
@@ -60,11 +60,15 @@
/* Configuration ************************************************************/ /* Configuration ************************************************************/
#ifndef CONFIG_NX #ifndef CONFIG_NX
# error "NX is not enabled (CONFIG_NX)" # error "NX is not enabled (CONFIG_NX=y)"
#endif #endif
#ifndef CONFIG_NXCONSOLE #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 #endif
/* If not specified, assume that the hardware supports one video plane */ /* If not specified, assume that the hardware supports one video plane */
@@ -161,34 +165,32 @@
/* Multi-user NX support */ /* Multi-user NX support */
#ifdef CONFIG_NX_MULTIUSER #ifdef CONFIG_DISABLE_MQUEUE
# ifdef CONFIG_DISABLE_MQUEUE # error "The multi-threaded example requires MQ support (CONFIG_DISABLE_MQUEUE=n)"
# error "The multi-threaded example requires MQ support (CONFIG_DISABLE_MQUEUE=n)" #endif
# endif #ifdef CONFIG_DISABLE_SIGNALS
# ifdef CONFIG_DISABLE_SIGNALS # error "This example requires signal support (CONFIG_DISABLE_SIGNALS=n)"
# error "This example requires signal support (CONFIG_DISABLE_SIGNALS=n)" #endif
# endif #ifdef CONFIG_DISABLE_PTHREAD
# ifdef CONFIG_DISABLE_PTHREAD # error "This example requires pthread support (CONFIG_DISABLE_PTHREAD=n)"
# error "This example requires pthread support (CONFIG_DISABLE_PTHREAD=n)" #endif
# endif #ifndef CONFIG_NX_BLOCKING
# ifndef CONFIG_NX_BLOCKING # error "This example depends on CONFIG_NX_BLOCKING"
# error "This example depends on CONFIG_NX_BLOCKING" #endif
# endif #ifndef CONFIG_EXAMPLES_NXCON_STACKSIZE
# ifndef CONFIG_EXAMPLES_NXCON_STACKSIZE # define CONFIG_EXAMPLES_NXCON_STACKSIZE 2048
# define CONFIG_EXAMPLES_NXCON_STACKSIZE 2048 #endif
# endif #ifndef CONFIG_EXAMPLES_NXCON_LISTENERPRIO
# ifndef CONFIG_EXAMPLES_NXCON_LISTENERPRIO # define CONFIG_EXAMPLES_NXCON_LISTENERPRIO 100
# define CONFIG_EXAMPLES_NXCON_LISTENERPRIO 100 #endif
# endif #ifndef CONFIG_EXAMPLES_NXCON_CLIENTPRIO
# ifndef CONFIG_EXAMPLES_NXCON_CLIENTPRIO # define CONFIG_EXAMPLES_NXCON_CLIENTPRIO 100
# define CONFIG_EXAMPLES_NXCON_CLIENTPRIO 100 #endif
# endif #ifndef CONFIG_EXAMPLES_NXCON_SERVERPRIO
# ifndef CONFIG_EXAMPLES_NXCON_SERVERPRIO # define CONFIG_EXAMPLES_NXCON_SERVERPRIO 120
# define CONFIG_EXAMPLES_NXCON_SERVERPRIO 120 #endif
# endif #ifndef CONFIG_EXAMPLES_NXCON_NOTIFYSIGNO
# ifndef CONFIG_EXAMPLES_NXCON_NOTIFYSIGNO # define CONFIG_EXAMPLES_NXCON_NOTIFYSIGNO 4
# define CONFIG_EXAMPLES_NXCON_NOTIFYSIGNO 4
# endif
#endif #endif
/* Graphics Device */ /* Graphics Device */
@@ -238,9 +240,7 @@
struct nxcon_state_s struct nxcon_state_s
{ {
volatile bool haveres; /* True: Have screen resolution */ volatile bool haveres; /* True: Have screen resolution */
#ifdef CONFIG_NX_MULTIUSER volatile bool connected; /* True: Connected to server */
bool connected; /* True: Connected to server */
#endif
sem_t eventsem; /* Control waiting for display events */ sem_t eventsem; /* Control waiting for display events */
NXHANDLE hnx; /* The connection handler */ NXHANDLE hnx; /* The connection handler */
NXTKWINDOW hwnd; /* The window */ NXTKWINDOW hwnd; /* The window */
@@ -269,13 +269,15 @@ extern const struct nx_callback_s g_nxtoolcb;
/**************************************************************************** /****************************************************************************
* Public Function Prototypes * Public Function Prototypes
****************************************************************************/ ****************************************************************************/
/* Board-specific driver intiialization */
#ifdef CONFIG_EXAMPLES_NXCON_EXTERNINIT #ifdef CONFIG_EXAMPLES_NXCON_EXTERNINIT
extern FAR NX_DRIVERTYPE *up_nxdrvinit(unsigned int devno); extern FAR NX_DRIVERTYPE *up_nxdrvinit(unsigned int devno);
#endif #endif
#if defined(CONFIG_NX) && defined(CONFIG_NX_MULTIUSER)
/* Server thread support */
extern int nxcon_server(int argc, char *argv[]); extern int nxcon_server(int argc, char *argv[]);
extern FAR void *nxcon_listener(FAR void *arg); extern FAR void *nxcon_listener(FAR void *arg);
#endif
#endif /* __EXAMPLES_NXCONSOLE_NXCON_INTERNAL_H */ #endif /* __EXAMPLES_NXCONSOLE_NXCON_INTERNAL_H */
+1 -103
View File
@@ -128,92 +128,11 @@ struct nxcon_state_s g_nxcon_vars;
* Private Functions * 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 * Name: nxcon_initialize
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_NX_MULTIUSER static int nxcon_initialize(void)
static inline int nxcon_muinitialize(void)
{ {
struct sched_param param; struct sched_param param;
pthread_t thread; pthread_t thread;
@@ -287,20 +206,6 @@ static inline int nxcon_muinitialize(void)
} }
return OK; 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 * Public Functions
@@ -519,17 +424,10 @@ errout_with_hwnd:
(void)nxtk_closewindow(g_nxcon_vars.hwnd); (void)nxtk_closewindow(g_nxcon_vars.hwnd);
errout_with_nx: errout_with_nx:
#ifdef CONFIG_NX_MULTIUSER
/* Disconnect from the server */ /* Disconnect from the server */
message(MAIN_NAME_STRING ": Disconnect from the server\n"); message(MAIN_NAME_STRING ": Disconnect from the server\n");
nx_disconnect(g_nxcon_vars.hnx); 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: errout:
return exitcode; return exitcode;
} }
+1 -5
View File
@@ -57,8 +57,6 @@
#include "nxcon_internal.h" #include "nxcon_internal.h"
#ifdef CONFIG_NX_MULTIUSER
/**************************************************************************** /****************************************************************************
* Definitions * Definitions
****************************************************************************/ ****************************************************************************/
@@ -176,7 +174,7 @@ FAR void *nxcon_listener(FAR void *arg)
*/ */
message("nxcon_listener: Lost server connection: %d\n", errno); message("nxcon_listener: Lost server connection: %d\n", errno);
exit(NXEXIT_LOSTSERVERCONN); exit(EXIT_FAILURE);
} }
/* If we received a message, we must be connected */ /* If we received a message, we must be connected */
@@ -189,5 +187,3 @@ FAR void *nxcon_listener(FAR void *arg)
} }
} }
} }
#endif /* CONFIG_NX_MULTIUSER */
+3
View File
@@ -374,6 +374,9 @@ nx11
-CONFIG_NXCONSOLE=n -CONFIG_NXCONSOLE=n
+CONFIG_NXCONSOLE=y +CONFIG_NXCONSOLE=y
-CONFIG_NX_MULTIUSER=n
+CONFIG_NX_MULTIUSER=y
Comment out the following in the appconfig file: Comment out the following in the appconfig file:
-CONFIGURED_APPS += examples/nx -CONFIGURED_APPS += examples/nx
+3 -3
View File
@@ -1,7 +1,7 @@
############################################################################ ############################################################################
# graphics/nxmu/Make.defs # graphics/nxmu/Make.defs
# #
# Copyright (C) 2008, 2011 Gregory Nutt. All rights reserved. # Copyright (C) 2008, 2011-2012 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org> # Author: Gregory Nutt <gnutt@nuttx.org>
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@@ -36,10 +36,10 @@
NX_ASRCS = NX_ASRCS =
NXAPI_CSRCS = nx_bitmap.c nx_closewindow.c nx_connect.c nx_disconnect.c \ NXAPI_CSRCS = nx_bitmap.c nx_closewindow.c nx_connect.c nx_disconnect.c \
nx_eventhandler.c nx_eventnotify.c nx_fill.c nx_filltrapezoid.c \ nx_eventhandler.c nx_eventnotify.c nx_fill.c nx_filltrapezoid.c \
nx_getposition.nx_getrectanble.c nx_kbdchin.c nx_kbdin.c nx_lower.c \ nx_getposition.c nx_getrectangle.c nx_kbdchin.c nx_kbdin.c nx_lower.c \
nx_mousein.c nx_move.c nx_openwindow.c nx_raise.c \ nx_mousein.c nx_move.c nx_openwindow.c nx_raise.c \
nx_releasebkgd.c nx_requestbkgd.c nx_setpixel.c nx_setsize.c \ nx_releasebkgd.c nx_requestbkgd.c nx_setpixel.c nx_setsize.c \
nx_setbgcolor.c nx_setposition.c nx_drawcircle.c nx_drawline.c nx_setbgcolor.c nx_setposition.c nx_drawcircle.c nx_drawline.c \
nx_fillcircle.c nx_fillcircle.c
NXMU_CSRCS = nxmu_constructwindow.c nxmu_kbdin.c nxmu_mouse.c \ NXMU_CSRCS = nxmu_constructwindow.c nxmu_kbdin.c nxmu_mouse.c \
nxmu_openwindow.c nxmu_redrawreq.c nxmu_releasebkgd.c \ nxmu_openwindow.c nxmu_redrawreq.c nxmu_releasebkgd.c \
+6 -5
View File
@@ -85,12 +85,12 @@
* col - The color to use in the set * col - The color to use in the set
* *
* Return: * Return:
* None * OK on success; ERROR on failure with errno set appropriately
* *
****************************************************************************/ ****************************************************************************/
void nx_setpixel(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos, int nx_setpixel(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
{ {
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
struct nxsvrmsg_setpixel_s outmsg; struct nxsvrmsg_setpixel_s outmsg;
@@ -99,7 +99,7 @@ void nx_setpixel(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
#ifdef CONFIG_DEBUG #ifdef CONFIG_DEBUG
if (!wnd || !wnd->conn || !pos || !color) if (!wnd || !wnd->conn || !pos || !color)
{ {
errno = EINVAL; set_errno(EINVAL);
return ERROR; return ERROR;
} }
#endif #endif
@@ -108,8 +108,9 @@ void nx_setpixel(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
outmsg.msgid = NX_SVRMSG_SETPIXEL; outmsg.msgid = NX_SVRMSG_SETPIXEL;
outmsg.wnd = wnd; outmsg.wnd = wnd;
outmsg.pos.x = pos->x;
outmsg.pos.y = pos->y;
nxgl_vectcopy(&outmsg.pos, pos);
nxgl_colorcopy(outmsg.color, color); nxgl_colorcopy(outmsg.color, color);
/* Forward the fill command to the server */ /* Forward the fill command to the server */
+5 -6
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* graphics/nxmu/nxmu_server.c * graphics/nxmu/nxmu_server.c
* *
* Copyright (C) 2008-2011 Gregory Nutt. All rights reserved. * Copyright (C) 2008-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -180,9 +180,8 @@ static inline void nxmu_shutdown(FAR struct nxfe_state_s *fe)
* Name: nxmu_setup * Name: nxmu_setup
****************************************************************************/ ****************************************************************************/
static inline int nxmu_lcdsetup(FAR const char *mqname, static inline int nxmu_setup(FAR const char *mqname, FAR NX_DRIVERTYPE *dev,
FAR NX_DRIVERTYPE *dev, FAR struct nxfe_state_s *fe)
FAR struct nxfe_state_s *fe)
{ {
struct mq_attr attr; struct mq_attr attr;
int ret; int ret;
@@ -435,8 +434,8 @@ int nx_runinstance(FAR const char *mqname, FAR NX_DRIVERTYPE *dev)
case NX_SVRMSG_SETPIXEL: /* Set a single pixel in the window with a color */ case NX_SVRMSG_SETPIXEL: /* Set a single pixel in the window with a color */
{ {
FAR struct nxsvrmsg_setpixel_s *setmsg = (FAR struct nxsvrmsg_fill_s *)buffer; FAR struct nxsvrmsg_setpixel_s *setmsg = (FAR struct nxsvrmsg_setpixel_s *)buffer;
nxbe_setpixel(fillmsg->wnd, &setmsg->pos, setmsg->color); nxbe_setpixel(setmsg->wnd, &setmsg->pos, setmsg->color);
} }
break; break;
+13 -1
View File
@@ -51,7 +51,19 @@
* Pre-processor definitions * Pre-processor definitions
****************************************************************************/ ****************************************************************************/
/* Configuration ************************************************************/ /* Configuration ************************************************************/
/* CONFIG_NXCONSOLE /* Nx Console prerequistes */
#ifndef CONFIG_NX
# warning "NX is not enabled (CONFIG_NX)
#endif
#ifndef CONFIG_NX_MULTIUSER
# warning "NX Console requires multi-user support (CONFIG_NX_MULTIUSER)"
#endif
/* Nx Console configuration options:
*
* CONFIG_NXCONSOLE
* Enables building of the NxConsole driver. * Enables building of the NxConsole driver.
* CONFIG_NXCONSOLE_BPP * CONFIG_NXCONSOLE_BPP
* Currently, NxConsole supports only a single pixel depth. This * Currently, NxConsole supports only a single pixel depth. This