summaryrefslogtreecommitdiffstats
path: root/apps/examples
diff options
context:
space:
mode:
authorpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-03-28 00:10:43 +0000
committerpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-03-28 00:10:43 +0000
commit516c28a3f7f41865b9934fe3fe2d22659aace7d3 (patch)
treec93decb412e433193f06fc5602a9560119017d19 /apps/examples
parent73faea1991a0426baf15b136df46e0052598ef1e (diff)
NFS update
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4532 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'apps/examples')
-rw-r--r--apps/examples/nxconsole/nxcon_internal.h6
-rw-r--r--apps/examples/nxconsole/nxcon_main.c33
2 files changed, 37 insertions, 2 deletions
diff --git a/apps/examples/nxconsole/nxcon_internal.h b/apps/examples/nxconsole/nxcon_internal.h
index 5aaabfe97e..06c989551b 100644
--- a/apps/examples/nxconsole/nxcon_internal.h
+++ b/apps/examples/nxconsole/nxcon_internal.h
@@ -173,6 +173,12 @@
# endif
#endif
+/* Graphics Device */
+
+#ifndef CONFIG_EXAMPLES_NXCON_DEVNO
+# define CONFIG_EXAMPLES_NXCON_DEVNO 0
+#endif
+
/* NX Console Device */
#ifndef CONFIG_EXAMPLES_NXCON_MINOR
diff --git a/apps/examples/nxconsole/nxcon_main.c b/apps/examples/nxconsole/nxcon_main.c
index 96f6567046..2edea83bab 100644
--- a/apps/examples/nxconsole/nxcon_main.c
+++ b/apps/examples/nxconsole/nxcon_main.c
@@ -321,10 +321,14 @@ static int nxcon_initialize(void)
int MAIN_NAME(int argc, char **argv)
{
int exitcode = EXIT_FAILURE;
+#if 0 /* Don't re-direct... too hard to debug */
+ int fd;
+#else
+ FILE *outstream;
+#endif
nxgl_mxpixel_t color;
int ndx;
int ret;
- int fd;
/* Reset all global data */
@@ -432,6 +436,7 @@ int MAIN_NAME(int argc, char **argv)
/* Open the driver */
+#if 0 /* Don't re-direct... too hard to debug */
fd = open(CONFIG_EXAMPLES_NXCON_DEVNAME, O_WRONLY);
if (fd < 0)
{
@@ -440,7 +445,10 @@ int MAIN_NAME(int argc, char **argv)
goto errout_with_driver;
}
- /* Now re-direct stdout and stderr so that they use the NX console driver */
+ /* Now re-direct stdout and stderr so that they use the NX console driver.
+ * If debug is enabled, then perform the test using only stderr so that we
+ * can still get debug output on stdout.
+ */
(void)dup2(fd, 1);
(void)dup2(fd, 2);
@@ -448,6 +456,17 @@ int MAIN_NAME(int argc, char **argv)
/* And we can close our original driver fd */
close(fd);
+#else
+ /* Open the Console driver as a write-only stream */
+
+ outstream = fopen(CONFIG_EXAMPLES_NXCON_DEVNAME, "w");
+ if (!outstream)
+ {
+ message(MAIN_NAME_STRING ": fopen %s read-only failed: %d\n",
+ CONFIG_EXAMPLES_NXCON_DEVNAME, errno);
+ goto errout_with_driver;
+ }
+#endif
/* Test Loop **************************************************************/
/* Now loop, adding text to the NX console */
@@ -461,7 +480,13 @@ int MAIN_NAME(int argc, char **argv)
/* Give another line of text to the NX console.*/
+#if 0 /* Don't re-direct... too hard to debug */
printf(g_nxcon_msg[ndx]);
+ fflush(stdout);
+#else
+ fprintf(outstream, g_nxcon_msg[ndx]);
+ fflush(outstream);
+#endif
if (++ndx >= NCON_MSG_NLINES)
{
#ifdef CONFIG_NSH_BUILTIN_APPS
@@ -481,6 +506,10 @@ int MAIN_NAME(int argc, char **argv)
/* Clean-up and Error Exits ***********************************************/
+#if 1 /* Don't re-direct... too hard to debug */
+ fclose(outstream);
+#endif
+
errout_with_driver:
message(MAIN_NAME_STRING ": Unregister the NX console device\n");
(void)nxcon_unregister(g_nxcon_vars.hdrvr);