diff options
-rw-r--r-- | apps/examples/README.txt | 29 | ||||
-rw-r--r-- | apps/examples/nxconsole/Makefile | 6 | ||||
-rw-r--r-- | apps/examples/nxconsole/nxcon_internal.h | 72 | ||||
-rw-r--r-- | apps/examples/nxconsole/nxcon_main.c | 104 | ||||
-rw-r--r-- | apps/examples/nxconsole/nxcon_server.c | 6 | ||||
-rw-r--r-- | nuttx/configs/sim/README.txt | 3 | ||||
-rw-r--r-- | nuttx/graphics/nxmu/Make.defs | 6 | ||||
-rw-r--r-- | nuttx/graphics/nxmu/nx_setpixel.c | 11 | ||||
-rw-r--r-- | nuttx/graphics/nxmu/nxmu_server.c | 11 | ||||
-rw-r--r-- | nuttx/include/nuttx/nx/nxconsole.h | 14 |
10 files changed, 85 insertions, 177 deletions
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 @@ -129,91 +129,10 @@ struct nxcon_state_s g_nxcon_vars; ****************************************************************************/ /**************************************************************************** - * 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 */ diff --git a/nuttx/configs/sim/README.txt b/nuttx/configs/sim/README.txt index 2a65300d9..58ce7d9ba 100644 --- a/nuttx/configs/sim/README.txt +++ b/nuttx/configs/sim/README.txt @@ -374,6 +374,9 @@ nx11 -CONFIG_NXCONSOLE=n +CONFIG_NXCONSOLE=y + -CONFIG_NX_MULTIUSER=n + +CONFIG_NX_MULTIUSER=y + Comment out the following in the appconfig file: -CONFIGURED_APPS += examples/nx diff --git a/nuttx/graphics/nxmu/Make.defs b/nuttx/graphics/nxmu/Make.defs index 6be702f11..6b4295290 100644 --- a/nuttx/graphics/nxmu/Make.defs +++ b/nuttx/graphics/nxmu/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # 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> # # Redistribution and use in source and binary forms, with or without @@ -36,10 +36,10 @@ NX_ASRCS = 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_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_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 NXMU_CSRCS = nxmu_constructwindow.c nxmu_kbdin.c nxmu_mouse.c \ nxmu_openwindow.c nxmu_redrawreq.c nxmu_releasebkgd.c \ diff --git a/nuttx/graphics/nxmu/nx_setpixel.c b/nuttx/graphics/nxmu/nx_setpixel.c index f4cc17053..35617646e 100644 --- a/nuttx/graphics/nxmu/nx_setpixel.c +++ b/nuttx/graphics/nxmu/nx_setpixel.c @@ -85,12 +85,12 @@ * col - The color to use in the set * * Return: - * None + * OK on success; ERROR on failure with errno set appropriately * ****************************************************************************/ -void nx_setpixel(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos, - nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) +int nx_setpixel(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos, + nxgl_mxpixel_t color[CONFIG_NX_NPLANES]) { FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; struct nxsvrmsg_setpixel_s outmsg; @@ -99,7 +99,7 @@ void nx_setpixel(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos, #ifdef CONFIG_DEBUG if (!wnd || !wnd->conn || !pos || !color) { - errno = EINVAL; + set_errno(EINVAL); return ERROR; } #endif @@ -108,8 +108,9 @@ void nx_setpixel(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos, outmsg.msgid = NX_SVRMSG_SETPIXEL; outmsg.wnd = wnd; + outmsg.pos.x = pos->x; + outmsg.pos.y = pos->y; - nxgl_vectcopy(&outmsg.pos, pos); nxgl_colorcopy(outmsg.color, color); /* Forward the fill command to the server */ diff --git a/nuttx/graphics/nxmu/nxmu_server.c b/nuttx/graphics/nxmu/nxmu_server.c index aa545c18f..9cd9e578a 100644 --- a/nuttx/graphics/nxmu/nxmu_server.c +++ b/nuttx/graphics/nxmu/nxmu_server.c @@ -1,7 +1,7 @@ /**************************************************************************** * 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> * * 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 ****************************************************************************/ -static inline int nxmu_lcdsetup(FAR const char *mqname, - FAR NX_DRIVERTYPE *dev, - FAR struct nxfe_state_s *fe) +static inline int nxmu_setup(FAR const char *mqname, FAR NX_DRIVERTYPE *dev, + FAR struct nxfe_state_s *fe) { struct mq_attr attr; 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 */ { - FAR struct nxsvrmsg_setpixel_s *setmsg = (FAR struct nxsvrmsg_fill_s *)buffer; - nxbe_setpixel(fillmsg->wnd, &setmsg->pos, setmsg->color); + FAR struct nxsvrmsg_setpixel_s *setmsg = (FAR struct nxsvrmsg_setpixel_s *)buffer; + nxbe_setpixel(setmsg->wnd, &setmsg->pos, setmsg->color); } break; diff --git a/nuttx/include/nuttx/nx/nxconsole.h b/nuttx/include/nuttx/nx/nxconsole.h index bf2c32160..0a66e4c03 100644 --- a/nuttx/include/nuttx/nx/nxconsole.h +++ b/nuttx/include/nuttx/nx/nxconsole.h @@ -51,7 +51,19 @@ * Pre-processor definitions ****************************************************************************/ /* 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. * CONFIG_NXCONSOLE_BPP * Currently, NxConsole supports only a single pixel depth. This |