apps/nshlib: Change the way SLCD is supported. Works better
This commit is contained in:
parent
2b8685b63f
commit
368f14852e
@ -886,6 +886,26 @@ config NSH_CONSOLE
|
|||||||
NSH_USBCONSOLE and NSH_USBCONDEV - Sets up some other USB
|
NSH_USBCONSOLE and NSH_USBCONDEV - Sets up some other USB
|
||||||
serial device as the NSH console (not necessarily dev/console).
|
serial device as the NSH console (not necessarily dev/console).
|
||||||
|
|
||||||
|
config NSH_SLCDCONSOLE
|
||||||
|
bool "Use a SLCD as console"
|
||||||
|
default n if !SLCD_CONSOLE
|
||||||
|
default y if SLCD_CONSOLE
|
||||||
|
depends on SLCD && NSH_CONSOLE
|
||||||
|
---help---
|
||||||
|
If defined, then the a configured SLCD display could be used as
|
||||||
|
output console to NuttShell (nsh>).
|
||||||
|
|
||||||
|
if NSH_SLCDCONSOLE
|
||||||
|
|
||||||
|
config NSH_SLCDCONDEV
|
||||||
|
string "SLCD console display device"
|
||||||
|
default "/dev/slcd0"
|
||||||
|
---help---
|
||||||
|
If NSH_SLCDCONSOLE is set to 'y', then NSH_SLCDCONDEV must
|
||||||
|
also be set to select the SLCD device used as output display.
|
||||||
|
|
||||||
|
endif # NSH_SLCDCONSOLE
|
||||||
|
|
||||||
config NSH_USBCONSOLE
|
config NSH_USBCONSOLE
|
||||||
bool "Use a USB serial console"
|
bool "Use a USB serial console"
|
||||||
default n
|
default n
|
||||||
|
@ -293,15 +293,16 @@
|
|||||||
|
|
||||||
#undef HAVE_SLCD_CONSOLE
|
#undef HAVE_SLCD_CONSOLE
|
||||||
|
|
||||||
/* Check if SLCD is configured as alternative console */
|
/* Check if SLCD is configured as console */
|
||||||
|
|
||||||
#if defined(CONFIG_SLCD) && defined(CONFIG_NSH_ALTCONDEV)
|
#if defined(CONFIG_SLCD) && defined(CONFIG_NSH_SLCDCONSOLE)
|
||||||
|
|
||||||
# define HAVE_SLCD_CONSOLE 1
|
# define HAVE_SLCD_CONSOLE 1
|
||||||
|
|
||||||
# ifndef CONFIG_NSH_CONDEV
|
# ifndef CONFIG_NSH_SLCDCONDEV
|
||||||
# define CONFIG_NSH_CONDEV "/dev/slcd0"
|
# define CONFIG_NSH_SLCDCONDEV "/dev/slcd0"
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#endif /* HAVE_SLCD_CONSOLE */
|
#endif /* HAVE_SLCD_CONSOLE */
|
||||||
|
|
||||||
/* USB trace settings */
|
/* USB trace settings */
|
||||||
|
@ -70,19 +70,21 @@ static int nsh_clone_console(FAR struct console_stdio_s *pstate)
|
|||||||
|
|
||||||
/* Close stdin */
|
/* Close stdin */
|
||||||
|
|
||||||
(void)close(0);
|
(void)fclose(stdout);
|
||||||
|
(void)fclose(stderr);
|
||||||
|
|
||||||
/* Open the console */
|
/* Open the console */
|
||||||
|
|
||||||
fd = open("/dev/console", O_RDONLY);
|
fd = open(CONFIG_NSH_SLCDCONDEV, O_WRONLY);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Associate /dev/console as stdin */
|
/* Associate /dev/slcd0 to stdout/stderr */
|
||||||
|
|
||||||
(void)dup2(fd, 0);
|
(void)dup2(fd, 1);
|
||||||
|
(void)dup2(fd, 2);
|
||||||
|
|
||||||
/* Close the console device that we just opened */
|
/* Close the console device that we just opened */
|
||||||
|
|
||||||
@ -91,13 +93,8 @@ static int nsh_clone_console(FAR struct console_stdio_s *pstate)
|
|||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Use /dev/console as console input */
|
(void)fdopen(1, "a");
|
||||||
|
(void)fdopen(2, "a");
|
||||||
pstate->cn_confd = 0;
|
|
||||||
|
|
||||||
/* Create a standard C stream on the console device */
|
|
||||||
|
|
||||||
pstate->cn_constream = fdopen(pstate->cn_confd, "r+");
|
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@ -165,6 +162,8 @@ int nsh_consolemain(int argc, char *argv[])
|
|||||||
/* Execute the session */
|
/* Execute the session */
|
||||||
|
|
||||||
(void)nsh_session(pstate);
|
(void)nsh_session(pstate);
|
||||||
|
|
||||||
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* HAVE_SLCD_CONSOLE */
|
#endif /* HAVE_SLCD_CONSOLE */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user