From 01bce341a9d065e8250f655c246c07a525779bc0 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sun, 20 May 2012 18:56:14 +0000 Subject: NxWM::CNxConsole and NXWidgets::CCallback can now redirect keyboard input to the NxConsole driver git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4754 42af7a65-404d-4744-a932-0658087f49c3 --- NxWidgets/ChangeLog.txt | 13 ++++++ NxWidgets/libnxwidgets/include/cbgwindow.hxx | 21 +++++++++ NxWidgets/libnxwidgets/include/ccallback.hxx | 32 +++++++++++++- NxWidgets/libnxwidgets/include/cnxtkwindow.hxx | 21 +++++++++ NxWidgets/libnxwidgets/include/cnxtoolbar.hxx | 21 +++++++++ NxWidgets/libnxwidgets/include/cnxwindow.hxx | 21 +++++++++ NxWidgets/libnxwidgets/include/inxwindow.hxx | 22 ++++++++++ NxWidgets/libnxwidgets/include/nxconfig.hxx | 8 ++++ NxWidgets/libnxwidgets/src/cbgwindow.cxx | 3 +- NxWidgets/libnxwidgets/src/ccallback.cxx | 61 +++++++++++++++++++------- NxWidgets/libnxwidgets/src/cnxtkwindow.cxx | 3 +- NxWidgets/libnxwidgets/src/cnxtoolbar.cxx | 2 +- NxWidgets/libnxwidgets/src/cnxwindow.cxx | 3 +- NxWidgets/nxwm/src/cnxconsole.cxx | 43 +++++++++++++++++- nuttx/graphics/nxconsole/Make.defs | 2 +- nuttx/graphics/nxconsole/nxcon_driver.c | 2 +- nuttx/graphics/nxconsole/nxcon_internal.h | 16 +++---- nuttx/graphics/nxconsole/nxcon_kbdin.c | 13 +++++- nuttx/graphics/nxconsole/nxcon_register.c | 4 ++ nuttx/include/nuttx/nx/nxconsole.h | 6 +-- 20 files changed, 279 insertions(+), 38 deletions(-) diff --git a/NxWidgets/ChangeLog.txt b/NxWidgets/ChangeLog.txt index 80101c920..c61d48375 100644 --- a/NxWidgets/ChangeLog.txt +++ b/NxWidgets/ChangeLog.txt @@ -111,3 +111,16 @@ threading model. 1.2 2012-xx-xx Gregory Nutt + +* NXWidgets::CCallback: callback arguement is now type CCallback and not + CWidgetControl; Added a method to redirect keyboard contacts to either + the widgets in the window (via CWidgetControl) or to an NxConsole (via + nxcon_kbdin()). +* NXWidgets::INxWindow, CBgWindow, CNxTkWindow, CNxToolbar, CNxWindow: + Now pass the CCallback intances as the callback argument instead of + the CWidgetControl instance. New method redirectNxConsole() will + support redirection of any window keyboard input to the NxConsole + (via CCallback). +* NxWM:CNxConsole: Configures the NxConsole window to redirectin keyboard + input to the NxConsole; redirects standard input to the NxConsole + device driver. diff --git a/NxWidgets/libnxwidgets/include/cbgwindow.hxx b/NxWidgets/libnxwidgets/include/cbgwindow.hxx index 435fdffbf..21b75799d 100644 --- a/NxWidgets/libnxwidgets/include/cbgwindow.hxx +++ b/NxWidgets/libnxwidgets/include/cbgwindow.hxx @@ -206,6 +206,27 @@ namespace NXWidgets bool lower(void); + /** + * Each window implementation also inherits from CCallback. CCallback, + * by default, forwards NX keyboard input to the various widgets residing + * in the window. But NxConsole is a different usage model; In this case, + * keyboard input needs to be directed to the NxConsole character driver. + * This method can be used to enable (or disable) redirection of NX + * keyboard input from the window widgets to the NxConsole + * + * @param handle. The NXCONSOLE handle. If non-NULL, NX keyboard + * input will be directed to the NxConsole driver using this + * handle; If NULL (the default), NX keyboard input will be + * directed to the widgets within the window. + */ + +#ifdef CONFIG_NXCONSOLE_NXKBDIN + inline void redirectNxConsole(NXCONSOLE handle) + { + setNxConsole(handle); + } +#endif + /** * Set an individual pixel in the window with the specified color. * diff --git a/NxWidgets/libnxwidgets/include/ccallback.hxx b/NxWidgets/libnxwidgets/include/ccallback.hxx index 09cb83a8a..8d3c13cd2 100644 --- a/NxWidgets/libnxwidgets/include/ccallback.hxx +++ b/NxWidgets/libnxwidgets/include/ccallback.hxx @@ -48,7 +48,10 @@ #include #include -#include + +#ifdef CONFIG_NXCONSOLE_NXKBDIN +# include +#endif #include "crect.hxx" @@ -88,7 +91,11 @@ namespace NXWidgets class CCallback { private: - struct nx_callback_s m_callbacks; /**< C-callable vtable of callback function pointers */ + CWidgetControl *m_widgetControl; /**< The widget control instance for this window */ + struct nx_callback_s m_callbacks; /**< C-callable vtable of callback function pointers */ +#ifdef CONFIG_NXCONSOLE_NXKBDIN + NXCONSOLE m_nxconsole; /**< The NxConsole handle for redirection of keyboard input */ +#endif // Methods in the callback vtable @@ -235,6 +242,27 @@ namespace NXWidgets { return &m_callbacks; } + + /** + * By default, NX keyboard input is given to the various widgets + * residing in the window. But NxConsole is a different usage model; + * In this case, keyboard input needs to be directed to the NxConsole + * character driver. This method can be used to enable (or disable) + * redirection of NX keyboard input from the window widgets to the + * NxConsole + * + * @param handle. The NXCONSOLE handle. If non-NULL, NX keyboard + * input will be directed to the NxConsole driver using this + * handle; If NULL (the default), NX keyboard input will be + * directed to the widgets within the window. + */ + +#ifdef CONFIG_NXCONSOLE_NXKBDIN + inline void setNxConsole(NXCONSOLE handle) + { + m_nxconsole = handle; + } +#endif }; } diff --git a/NxWidgets/libnxwidgets/include/cnxtkwindow.hxx b/NxWidgets/libnxwidgets/include/cnxtkwindow.hxx index 8fda121a9..16a0bee92 100644 --- a/NxWidgets/libnxwidgets/include/cnxtkwindow.hxx +++ b/NxWidgets/libnxwidgets/include/cnxtkwindow.hxx @@ -227,6 +227,27 @@ namespace NXWidgets bool lower(void); + /** + * Each window implementation also inherits from CCallback. CCallback, + * by default, forwards NX keyboard input to the various widgets residing + * in the window. But NxConsole is a different usage model; In this case, + * keyboard input needs to be directed to the NxConsole character driver. + * This method can be used to enable (or disable) redirection of NX + * keyboard input from the window widgets to the NxConsole + * + * @param handle. The NXCONSOLE handle. If non-NULL, NX keyboard + * input will be directed to the NxConsole driver using this + * handle; If NULL (the default), NX keyboard input will be + * directed to the widgets within the window. + */ + +#ifdef CONFIG_NXCONSOLE_NXKBDIN + inline void redirectNxConsole(NXCONSOLE handle) + { + setNxConsole(handle); + } +#endif + /** * Set an individual pixel in the window with the specified color. * diff --git a/NxWidgets/libnxwidgets/include/cnxtoolbar.hxx b/NxWidgets/libnxwidgets/include/cnxtoolbar.hxx index 8e016c15e..69a004da5 100644 --- a/NxWidgets/libnxwidgets/include/cnxtoolbar.hxx +++ b/NxWidgets/libnxwidgets/include/cnxtoolbar.hxx @@ -196,6 +196,27 @@ namespace NXWidgets bool lower(void); + /** + * Each window implementation also inherits from CCallback. CCallback, + * by default, forwards NX keyboard input to the various widgets residing + * in the window. But NxConsole is a different usage model; In this case, + * keyboard input needs to be directed to the NxConsole character driver. + * This method can be used to enable (or disable) redirection of NX + * keyboard input from the window widgets to the NxConsole + * + * @param handle. The NXCONSOLE handle. If non-NULL, NX keyboard + * input will be directed to the NxConsole driver using this + * handle; If NULL (the default), NX keyboard input will be + * directed to the widgets within the window. + */ + +#ifdef CONFIG_NXCONSOLE_NXKBDIN + inline void redirectNxConsole(NXCONSOLE handle) + { + setNxConsole(handle); + } +#endif + /** * Set an individual pixel in the toolbar with the specified color. * diff --git a/NxWidgets/libnxwidgets/include/cnxwindow.hxx b/NxWidgets/libnxwidgets/include/cnxwindow.hxx index e39c3cc81..50822cc83 100644 --- a/NxWidgets/libnxwidgets/include/cnxwindow.hxx +++ b/NxWidgets/libnxwidgets/include/cnxwindow.hxx @@ -200,6 +200,27 @@ namespace NXWidgets bool lower(void); + /** + * Each window implementation also inherits from CCallback. CCallback, + * by default, forwards NX keyboard input to the various widgets residing + * in the window. But NxConsole is a different usage model; In this case, + * keyboard input needs to be directed to the NxConsole character driver. + * This method can be used to enable (or disable) redirection of NX + * keyboard input from the window widgets to the NxConsole + * + * @param handle. The NXCONSOLE handle. If non-NULL, NX keyboard + * input will be directed to the NxConsole driver using this + * handle; If NULL (the default), NX keyboard input will be + * directed to the widgets within the window. + */ + +#ifdef CONFIG_NXCONSOLE_NXKBDIN + inline void redirectNxConsole(NXCONSOLE handle) + { + setNxConsole(handle); + } +#endif + /** * Set an individual pixel in the window with the specified color. * diff --git a/NxWidgets/libnxwidgets/include/inxwindow.hxx b/NxWidgets/libnxwidgets/include/inxwindow.hxx index 750994a71..210a1e6ce 100644 --- a/NxWidgets/libnxwidgets/include/inxwindow.hxx +++ b/NxWidgets/libnxwidgets/include/inxwindow.hxx @@ -47,6 +47,10 @@ #include #include +#ifdef CONFIG_NXCONSOLE_NXKBDIN +# include +#endif + /**************************************************************************** * Pre-Processor Definitions ****************************************************************************/ @@ -168,6 +172,24 @@ namespace NXWidgets virtual bool lower(void) = 0; + /** + * Each window implementation also inherits from CCallback. CCallback, + * by default, forwards NX keyboard input to the various widgets residing + * in the window. But NxConsole is a different usage model; In this case, + * keyboard input needs to be directed to the NxConsole character driver. + * This method can be used to enable (or disable) redirection of NX + * keyboard input from the window widgets to the NxConsole + * + * @param handle. The NXCONSOLE handle. If non-NULL, NX keyboard + * input will be directed to the NxConsole driver using this + * handle; If NULL (the default), NX keyboard input will be + * directed to the widgets within the window. + */ + +#ifdef CONFIG_NXCONSOLE_NXKBDIN + virtual void redirectNxConsole(NXCONSOLE handle) = 0; +#endif + /** * Set an individual pixel in the window with the specified color. * diff --git a/NxWidgets/libnxwidgets/include/nxconfig.hxx b/NxWidgets/libnxwidgets/include/nxconfig.hxx index 5ab883ab1..699686822 100644 --- a/NxWidgets/libnxwidgets/include/nxconfig.hxx +++ b/NxWidgets/libnxwidgets/include/nxconfig.hxx @@ -184,6 +184,14 @@ # error "Only a single color plane is supported (CONFIG_NX_NPLANES)" #endif +/* NxConsole checks. This just simplifies the conditional compilation by + * reducing the AND of these three conditions to a single condition. + */ + +#if !defined(CONFIG_NX_KBD) || !defined(CONFIG_NXCONSOLE) +# undef CONFIG_NXCONSOLE_NXKBDIN +#endif + /* NX Server/Device Configuration *******************************************/ /** * LCD device number (in case there are more than one LCDs connected) diff --git a/NxWidgets/libnxwidgets/src/cbgwindow.cxx b/NxWidgets/libnxwidgets/src/cbgwindow.cxx index 58ecc1f51..268bc5d80 100644 --- a/NxWidgets/libnxwidgets/src/cbgwindow.cxx +++ b/NxWidgets/libnxwidgets/src/cbgwindow.cxx @@ -101,7 +101,8 @@ bool CBgWindow::open(void) // Request the background the window - int ret = nx_requestbkgd(m_hNxServer, vtable, (FAR void *)m_widgetControl); + int ret = nx_requestbkgd(m_hNxServer, vtable, + (FAR void *)static_cast(this)); if (ret < 0) { return false; diff --git a/NxWidgets/libnxwidgets/src/ccallback.cxx b/NxWidgets/libnxwidgets/src/ccallback.cxx index b2256c6bb..374502a38 100644 --- a/NxWidgets/libnxwidgets/src/ccallback.cxx +++ b/NxWidgets/libnxwidgets/src/ccallback.cxx @@ -44,6 +44,10 @@ #include #include +#ifdef CONFIG_NXCONSOLE_NXKBDIN +# include +#endif + #include "cwidgetcontrol.hxx" #include "ccallback.hxx" @@ -65,6 +69,10 @@ using namespace NXWidgets; CCallback::CCallback(CWidgetControl *widgetControl) { + // Save the widgetControl + + m_widgetControl = widgetControl; + // Initialize the callback vtable m_callbacks.redraw = redraw; @@ -76,6 +84,12 @@ CCallback::CCallback(CWidgetControl *widgetControl) m_callbacks.kbdin = newKeyboardEvent; #endif m_callbacks.blocked = windowBlocked; + + // Keyboard input is initially direct to the widgets within the window + +#ifdef CONFIG_NXCONSOLE_NXKBDIN + m_nxconsole = (NXCONSOLE)0; +#endif } /** @@ -98,13 +112,13 @@ void CCallback::redraw(NXHANDLE hwnd, rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y, bMore ? "true" : "false"); - // The argument must be the CWidgetControl instance + // The argument must be the CCallback instance - CWidgetControl *This = (CWidgetControl *)arg; + CCallback *This = (CCallback *)arg; // Just forward the callback to the CWidgetControl::redrawEvent method - This->redrawEvent(rect, bMore); + This->m_widgetControl->redrawEvent(rect, bMore); } /** @@ -132,13 +146,13 @@ void CCallback::position(NXHANDLE hwnd, arg); - // The argument must be the CWidgetControl instance + // The argument must be the CCallback instance - CWidgetControl *This = (CWidgetControl *)arg; + CCallback *This = (CCallback *)arg; // Just forward the callback to the CWidgetControl::geometry method - This->geometryEvent(hwnd, size, pos, bounds); + This->m_widgetControl->geometryEvent(hwnd, size, pos, bounds); } /** @@ -160,13 +174,13 @@ void CCallback::newMouseEvent(NXHANDLE hwnd, gvdbg("hwnd=%p pos=(%d,%d) buttons=%02x arg=%p\n", hwnd, pos->x, pos->y, buttons, arg); - // The argument must be the CWidgetControl instance + // The argument must be the CCallback instance - CWidgetControl *This = (CWidgetControl *)arg; + CCallback *This = (CCallback *)arg; // Just forward the callback to the CWidgetControl::newMouseEvent method - This->newMouseEvent(pos, buttons); + This->m_widgetControl->newMouseEvent(pos, buttons); } #endif /* CONFIG_NX_MOUSE */ @@ -188,13 +202,28 @@ void CCallback::newKeyboardEvent(NXHANDLE hwnd, uint8_t nCh, { gvdbg("hwnd=%p nCh=%d arg=%p\n", hwnd, nCh, arg); - // The argument must be the CWidgetControl instance + // The argument must be the CCallback instance + + CCallback *This = (CCallback *)arg; - CWidgetControl *This = (CWidgetControl *)arg; + // Is NX keyboard input being directed to the widgets within the window + // (default) OR is NX keyboard input being re-directed to an NxConsole + // driver? - // Just forward the callback to the CWidgetControl::newKeyboardEvent method +#ifdef CONFIG_NXCONSOLE_NXKBDIN + if (This->m_nxconsole) + { + // Keyboard input is going to an NxConsole + + nxcon_kbdin(This->m_nxconsole, str, nCh); + } + else +#endif + { + // Just forward the callback to the CWidgetControl::newKeyboardEvent method - This->newKeyboardEvent(nCh, str); + This->m_widgetControl->newKeyboardEvent(nCh, str); + } } /** @@ -221,13 +250,13 @@ void CCallback::windowBlocked(NXWINDOW hwnd, FAR void *arg1, FAR void *arg2) { gvdbg("hwnd=%p arg1=%p arg2=%p\n", hwnd, arg1, arg2); - // The first argument must be the CWidgetControl instance + // The first argument must be the CCallback instance - CWidgetControl *This = (CWidgetControl *)arg1; + CCallback *This = (CCallback *)arg1; // Just forward the callback to the CWidgetControl::windowBlocked method - This->windowBlocked(arg2); + This->m_widgetControl->windowBlocked(arg2); } #endif diff --git a/NxWidgets/libnxwidgets/src/cnxtkwindow.cxx b/NxWidgets/libnxwidgets/src/cnxtkwindow.cxx index 6a9c115e1..b1d7be9e2 100644 --- a/NxWidgets/libnxwidgets/src/cnxtkwindow.cxx +++ b/NxWidgets/libnxwidgets/src/cnxtkwindow.cxx @@ -118,7 +118,8 @@ bool CNxTkWindow::open(void) // Create the window - m_hNxTkWindow = nxtk_openwindow(m_hNxServer, vtable, (FAR void *)m_widgetControl); + m_hNxTkWindow = nxtk_openwindow(m_hNxServer, vtable, + (FAR void *)static_cast(this)); return m_hNxTkWindow != NULL; } diff --git a/NxWidgets/libnxwidgets/src/cnxtoolbar.cxx b/NxWidgets/libnxwidgets/src/cnxtoolbar.cxx index 12b6bea4c..725a368fa 100644 --- a/NxWidgets/libnxwidgets/src/cnxtoolbar.cxx +++ b/NxWidgets/libnxwidgets/src/cnxtoolbar.cxx @@ -119,7 +119,7 @@ bool CNxToolbar::open(void) // Create the toolbar int ret = nxtk_opentoolbar(m_hNxTkWindow, m_height, vtable, - (FAR void *)m_widgetControl); + (FAR void *)static_cast(this)); return ret == OK; } diff --git a/NxWidgets/libnxwidgets/src/cnxwindow.cxx b/NxWidgets/libnxwidgets/src/cnxwindow.cxx index 5ba4d734c..b38667d8d 100644 --- a/NxWidgets/libnxwidgets/src/cnxwindow.cxx +++ b/NxWidgets/libnxwidgets/src/cnxwindow.cxx @@ -99,7 +99,8 @@ bool CNxWindow::open(void) // Create the window - m_hNxWindow = nx_openwindow(m_hNxServer, vtable, (FAR void *)m_widgetControl); + m_hNxWindow = nx_openwindow(m_hNxServer, vtable, + (FAR void *)static_cast(this)); return m_hNxWindow != NULL; } diff --git a/NxWidgets/nxwm/src/cnxconsole.cxx b/NxWidgets/nxwm/src/cnxconsole.cxx index 30105910b..63cd21eb6 100644 --- a/NxWidgets/nxwm/src/cnxconsole.cxx +++ b/NxWidgets/nxwm/src/cnxconsole.cxx @@ -36,6 +36,11 @@ /******************************************************************************************** * Included Files ********************************************************************************************/ +#include // REMOVE ME +#define CONFIG_DEBUG 1 // REMOVE ME +#define CONFIG_DEBUG_VERBOSE 1 // REMOVE ME +#define CONFIG_DEBUG_GRAPHICS 1 // REMOVE ME +#include // REMOVE ME #include @@ -202,6 +207,7 @@ bool CNxConsole::run(void) if (m_pid >= 0 || m_nxcon != 0) { + gdbg("ERROR: All ready running or connected\n"); return false; } @@ -211,6 +217,7 @@ bool CNxConsole::run(void) { // This might fail if a signal is received while we are waiting. + gdbg("ERROR: Failed to get semaphore\n"); return false; } @@ -252,6 +259,7 @@ bool CNxConsole::run(void) bool result = true; if (m_pid < 0) { + gdbg("ERROR: Failed to create the NxConsole task\n"); result = false; } else @@ -267,14 +275,22 @@ bool CNxConsole::run(void) if (ret == OK && g_nxconvars.result) { + // Re-direct NX keyboard input to the new NxConsole driver + + DEBUGASSERT(g_nxconvars.nxcon != 0); +#ifdef CONFIG_NXCONSOLE_NXKBDIN + window->redirectNxConsole(g_nxconvars.nxcon); +#endif // Save the handle to use in the stop method m_nxcon = g_nxconvars.nxcon; } else { - // Stop the application + // sem_timedwait failed OR the NxConsole task reported a + // failure. Stop the application + gdbg("ERROR: Failed start the NxConsole task\n"); stop(); result = false; } @@ -313,6 +329,15 @@ void CNxConsole::stop(void) if (m_nxcon) { + // Re-store NX keyboard input routing + +#ifdef CONFIG_NXCONSOLE_NXKBDIN + NXWidgets::INxWindow *window = m_window->getWindow(); + window->redirectNxConsole((NXCONSOLE)0); +#endif + + // Unregister the NxConsole driver + nxcon_unregister(m_nxcon); m_nxcon = 0; } @@ -405,6 +430,7 @@ int CNxConsole::nxconsole(int argc, char *argv[]) if (on_exit(exitHandler, g_nxconvars.console) != 0) { + gdbg("ERROR: on_exit failed\n"); goto errout; } @@ -414,6 +440,7 @@ int CNxConsole::nxconsole(int argc, char *argv[]) g_nxconvars.minor); if (!g_nxconvars.nxcon) { + gdbg("ERROR: Failed register the console device\n"); goto errout; } @@ -428,9 +455,14 @@ int CNxConsole::nxconsole(int argc, char *argv[]) // Open the NxConsole driver +#ifdef CONFIG_NXCONSOLE_NXKBDIN + fd = open(devname, O_RDWR); +#else fd = open(devname, O_WRONLY); +#endif if (fd < 0) { + gdbg("ERROR: Failed open the console device\n"); goto errout_with_nxcon; } @@ -442,12 +474,21 @@ int CNxConsole::nxconsole(int argc, char *argv[]) (void)std::fflush(stdout); (void)std::fflush(stderr); +#ifdef CONFIG_NXCONSOLE_NXKBDIN + (void)std::fclose(stdin); +#endif (void)std::fclose(stdout); (void)std::fclose(stderr); +#ifdef CONFIG_NXCONSOLE_NXKBDIN + (void)std::dup2(fd, 0); +#endif (void)std::dup2(fd, 1); (void)std::dup2(fd, 2); +#ifdef CONFIG_NXCONSOLE_NXKBDIN + (void)std::fdopen(0, "r"); +#endif (void)std::fdopen(1, "w"); (void)std::fdopen(2, "w"); diff --git a/nuttx/graphics/nxconsole/Make.defs b/nuttx/graphics/nxconsole/Make.defs index 03747763a..a57b22885 100644 --- a/nuttx/graphics/nxconsole/Make.defs +++ b/nuttx/graphics/nxconsole/Make.defs @@ -40,7 +40,7 @@ NXCON_CSRCS += nxcon_vt100.c nxcon_unregister.c nxtk_register.c NXCON_CSRCS += nxtool_register.c ifeq ($(CONFIG_NXCONSOLE_NXKBDIN),y) -NXCON_CSRCS += nxcon_kbdin.c +NXCON_CSRCS += nxcon_kbdin.c endif ifeq ($(CONFIG_DEBUG),y) diff --git a/nuttx/graphics/nxconsole/nxcon_driver.c b/nuttx/graphics/nxconsole/nxcon_driver.c index d90218e60..c647f97bb 100755 --- a/nuttx/graphics/nxconsole/nxcon_driver.c +++ b/nuttx/graphics/nxconsole/nxcon_driver.c @@ -128,7 +128,7 @@ static int nxcon_open(FAR struct file *filep) #ifndef CONFIG_NXCONSOLE_NXKBDIN if ((filep->f_oflags & O_RDOK) != 0) { - gdbg("Attempted open with read access\n"); + gdbg("ERROR: Attempted open with read access\n"); return -EACCES; } #endif diff --git a/nuttx/graphics/nxconsole/nxcon_internal.h b/nuttx/graphics/nxconsole/nxcon_internal.h index 47a51663f..dc976a662 100644 --- a/nuttx/graphics/nxconsole/nxcon_internal.h +++ b/nuttx/graphics/nxconsole/nxcon_internal.h @@ -144,20 +144,20 @@ struct nxcon_state_s #ifdef CONFIG_DEBUG pid_t holder; /* Deadlock avoidance */ #endif + uint8_t minor; /* Device minor number */ /* Text output support */ - struct nxgl_point_s fpos; /* Next display position */ - - uint16_t maxchars; /* Size of the bm[] array */ - uint16_t nchars; /* Number of chars in the bm[] array */ - - uint8_t minor; /* Device minor number */ uint8_t fheight; /* Max height of a font in pixels */ uint8_t fwidth; /* Max width of a font in pixels */ uint8_t spwidth; /* The width of a space */ uint8_t maxglyphs; /* Size of the glyph[] array */ + uint16_t maxchars; /* Size of the bm[] array */ + uint16_t nchars; /* Number of chars in the bm[] array */ + + struct nxgl_point_s fpos; /* Next display position */ + /* VT100 escape sequence processing */ char seq[VT100_MAX_SEQUENCE]; /* Buffered characters */ @@ -210,8 +210,8 @@ extern const struct file_operations g_nxcon_drvrops; int nxcon_semwait(FAR struct nxcon_state_s *priv); int nxcon_sempost(FAR struct nxcon_state_s *priv); #else -# define nxcon_semwait(p) sem_wait(&p->exclsem); -# define nxcon_sempost(p) sem_post(&p->exclsem); +# define nxcon_semwait(p) sem_wait(&p->exclsem) +# define nxcon_sempost(p) sem_post(&p->exclsem) #endif /* Common device registration */ diff --git a/nuttx/graphics/nxconsole/nxcon_kbdin.c b/nuttx/graphics/nxconsole/nxcon_kbdin.c index d88505ab9..5914d4069 100644 --- a/nuttx/graphics/nxconsole/nxcon_kbdin.c +++ b/nuttx/graphics/nxconsole/nxcon_kbdin.c @@ -126,6 +126,7 @@ ssize_t nxcon_read(FAR struct file *filep, FAR char *buffer, size_t len) ret = nxcon_semwait(priv); if (ret < 0) { + gdbg("ERROR: nxcon_semwait failed\n"); return ret; } @@ -198,6 +199,8 @@ ssize_t nxcon_read(FAR struct file *filep, FAR char *buffer, size_t len) int errval = errno; + gdbg("ERROR: nxcon_semwait failed\n"); + /* Were we awakened by a signal? Did we read anything before * we received the signal? */ @@ -283,6 +286,7 @@ int nxcon_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup) ret = nxcon_semwait(priv); if (ret < 0) { + gdbg("ERROR: nxcon_semwait failed\n"); return ret; } @@ -310,6 +314,8 @@ int nxcon_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup) if (i >= CONFIG_NXCONSOLE_NPOLLWAITERS) { + gdbg("ERROR: Too many poll waiters\n"); + fds->priv = NULL; ret = -EBUSY; goto errout; @@ -343,6 +349,8 @@ int nxcon_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup) #ifdef CONFIG_DEBUG if (!slot) { + gdbg("ERROR: No slot\n"); + ret = -EIO; goto errout; } @@ -361,7 +369,7 @@ errout: #endif /**************************************************************************** - * Name: nxcon_kdbin + * Name: nxcon_kbdin * * Description: * This function should be driven by the window kbdin callback function @@ -386,13 +394,14 @@ errout: * ****************************************************************************/ -void nxcon_kdbin(NXCONSOLE handle, FAR const uint8_t *buffer, uint8_t buflen) +void nxcon_kbdin(NXCONSOLE handle, FAR const uint8_t *buffer, uint8_t buflen) { FAR struct nxcon_state_s *priv; ssize_t nwritten; int nexthead; char ch; + gvdbg("buflen=%d\n"); DEBUGASSERT(handle); /* Get the reference to the driver structure from the handle */ diff --git a/nuttx/graphics/nxconsole/nxcon_register.c b/nuttx/graphics/nxconsole/nxcon_register.c index 3eea4e67a..cadda7394 100644 --- a/nuttx/graphics/nxconsole/nxcon_register.c +++ b/nuttx/graphics/nxconsole/nxcon_register.c @@ -99,6 +99,10 @@ FAR struct nxcon_state_s * memcpy(&priv->wndo, wndo, sizeof( struct nxcon_window_s)); sem_init(&priv->exclsem, 0, 1); +#ifdef CONFIG_DEBUG + priv->holder = NO_HOLDER; +#endif + #ifdef CONFIG_NXCONSOLE_NXKBDIN sem_init(&priv->waitsem, 0, 0); #endif diff --git a/nuttx/include/nuttx/nx/nxconsole.h b/nuttx/include/nuttx/nx/nxconsole.h index 57324e5da..6ff719237 100644 --- a/nuttx/include/nuttx/nx/nxconsole.h +++ b/nuttx/include/nuttx/nx/nxconsole.h @@ -100,7 +100,7 @@ * CONFIG_NXCONSOLE_NXKBDIN * Take input from the NX keyboard input callback. By default, keyboard * input is taken from stdin (/dev/console). If this option is set, then - * the interface nxcon_kdbin() is enabled. That interface may be driven + * the interface nxcon_kbdin() is enabled. That interface may be driven * by window callback functions so that keyboard input *only* goes to the * top window. * CONFIG_NXCONSOLE_KBDBUFSIZE @@ -328,7 +328,7 @@ EXTERN void nxcon_redraw(NXCONSOLE handle, FAR const struct nxgl_rect_s *rect, bool more); /**************************************************************************** - * Name: nxcon_kdbin + * Name: nxcon_kbdin * * Description: * This function should be driven by the window kbdin callback function @@ -354,7 +354,7 @@ EXTERN void nxcon_redraw(NXCONSOLE handle, FAR const struct nxgl_rect_s *rect, ****************************************************************************/ #ifdef CONFIG_NXCONSOLE_NXKBDIN -EXTERN void nxcon_kdbin(NXCONSOLE handle, FAR const uint8_t *buffer, +EXTERN void nxcon_kbdin(NXCONSOLE handle, FAR const uint8_t *buffer, uint8_t buflen); #endif -- cgit v1.2.3