summaryrefslogtreecommitdiffstats
path: root/apps/examples/nxconsole
diff options
context:
space:
mode:
authorpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-03-28 17:19:17 +0000
committerpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-03-28 17:19:17 +0000
commit79b7dc6f097ae217d02206884ef509fd78e94fb0 (patch)
treee12183151cf2f149ff8319895a151c458db3ba01 /apps/examples/nxconsole
parent7cf33ab655c02790c34ff8227698ca5e7a69accc (diff)
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
Diffstat (limited to 'apps/examples/nxconsole')
-rw-r--r--apps/examples/nxconsole/Makefile6
-rw-r--r--apps/examples/nxconsole/nxcon_internal.h72
-rw-r--r--apps/examples/nxconsole/nxcon_main.c104
-rw-r--r--apps/examples/nxconsole/nxcon_server.c6
4 files changed, 40 insertions, 148 deletions
diff --git a/apps/examples/nxconsole/Makefile b/apps/examples/nxconsole/Makefile
index 0816fc96e3..2a04f982eb 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 fd37773341..96ea8f781f 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 fad6b9c0ca..8713be4935 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 661479a4a1..ccd000ec07 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 */