Can now run an NSH session within an NX window
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4539 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
parent
2fc23074b6
commit
223ff4e564
|
@ -213,3 +213,5 @@
|
|||
* vsn/hello: Removed. The modified apps/examples/hello is enough "Hello,
|
||||
World!"
|
||||
* apps/examples/nxconsole: Add a test of the NX console device.
|
||||
* apps/examples/nxconsole: The NX console example now supports running
|
||||
the NuttShell (NSH) within an NX window.
|
||||
|
|
|
@ -56,7 +56,7 @@ SUBDIRS = adc buttons can cdcacm composite dhcpd ftpc ftpd hello helloxx \
|
|||
CNTXTDIRS = pwm
|
||||
|
||||
ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
|
||||
CNTXTDIRS += adc can cdcacm composite ftpd dhcpd nettest nxconsole qencoder telnetd
|
||||
CNTXTDIRS += adc can cdcacm composite ftpd dhcpd nettest qencoder telnetd
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_HELLO_BUILTIN),y)
|
||||
|
|
|
@ -617,9 +617,11 @@ examples/nx
|
|||
examples/nxconsole
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
|
||||
This directory contains a simple test of the NX console device defined in
|
||||
include/nuttx/nx/nxconsole.h. Prerequisite configuration settings for this
|
||||
test include:
|
||||
This directory contains yet another version of the NuttShell (NSH). This
|
||||
version uses the NX console device defined in include/nuttx/nx/nxconsole.h
|
||||
for output. the result is that the NSH input still come from the standard
|
||||
console input (probably a serial console). But the text output will go to
|
||||
an NX winbdow. 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
|
||||
|
@ -628,12 +630,11 @@ examples/nxconsole
|
|||
CONFIG_DISABLE_SIGNALS=n -- Signals are needed
|
||||
CONFIG_DISABLE_PTHREAD=n -- pthreads are needed
|
||||
CONFIG_NX_BLOCKING=y -- pthread APIs must be blocking
|
||||
CONFIG_NSH_CONSOLE=y -- NSH must be configured to use a console.
|
||||
|
||||
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
|
||||
CONFIG_EXAMPLES_NXCON_VPLANE -- The plane to select from the frame-
|
||||
buffer driver for use in the test. Default: 0
|
||||
CONFIG_EXAMPLES_NXCON_DEVNO - The LCD device to select from the LCD
|
||||
|
@ -669,6 +670,10 @@ examples/nxconsole
|
|||
CONFIG_EXAMPLES_NXCON_DEVNAME -- The quoated, full path to the
|
||||
NX console device corresponding to CONFIG_EXAMPLES_NXCON_MINOR.
|
||||
Default: "/dev/nxcon0"
|
||||
CONFIG_EXAMPLES_NXCONSOLE_PRIO - Priority of the NxConsole task.
|
||||
Default: SCHED_PRIORITY_DEFAULT
|
||||
CONFIG_EXAMPLES_NXCONSOLE_STACKSIZE - Stack size allocated for the
|
||||
NxConsole task. Default: 2048
|
||||
|
||||
The following configuration settings determine how to set up the NX
|
||||
server (CONFIG_NX_MULTIUSER):
|
||||
|
|
|
@ -56,12 +56,6 @@ endif
|
|||
|
||||
ROOTDEPPATH = --dep-path .
|
||||
|
||||
# NxConsole built-in application info
|
||||
|
||||
APPNAME = nxcon
|
||||
PRIORITY = SCHED_PRIORITY_DEFAULT
|
||||
STACKSIZE = 2048
|
||||
|
||||
# Common build
|
||||
|
||||
VPATH =
|
||||
|
@ -81,13 +75,7 @@ $(COBJS): %$(OBJEXT): %.c
|
|||
done ; )
|
||||
@touch .built
|
||||
|
||||
.context:
|
||||
ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
|
||||
$(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
|
||||
@touch $@
|
||||
endif
|
||||
|
||||
context: .context
|
||||
context:
|
||||
|
||||
.depend: Makefile $(SRCS)
|
||||
@$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||
|
|
|
@ -56,21 +56,37 @@
|
|||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
/* Need NX graphics support */
|
||||
|
||||
#ifndef CONFIG_NX
|
||||
# error "NX is not enabled (CONFIG_NX=y)"
|
||||
#endif
|
||||
|
||||
/* Can't do the NxConsole example if the NxConsole driver is not built */
|
||||
|
||||
#ifndef CONFIG_NXCONSOLE
|
||||
# error "NxConsole is not enabled (CONFIG_NXCONSOLE=y)"
|
||||
#endif
|
||||
|
||||
/* NxConsole requires NX Multi-user mode */
|
||||
|
||||
#ifndef CONFIG_NX_MULTIUSER
|
||||
# error "Multi-user NX support is required (CONFIG_NX_MULTIUSER=y)"
|
||||
#endif
|
||||
|
||||
/* If there is no NSH console, then why are we running this example? */
|
||||
|
||||
#ifndef CONFIG_NSH_CONSOLE
|
||||
# warning "Expected CONFIG_NSH_CONSOLE=y"
|
||||
#endif
|
||||
|
||||
/* The NSH telnet console requires networking support (and TCP/IP) */
|
||||
|
||||
#ifndef CONFIG_NET
|
||||
# undef CONFIG_NSH_TELNET
|
||||
#endif
|
||||
|
||||
/* If not specified, assume that the hardware supports one video plane */
|
||||
|
||||
#if CONFIG_NX_NPLANES != 1
|
||||
|
@ -209,6 +225,16 @@
|
|||
# define CONFIG_EXAMPLES_NXCON_DEVNAME "/dev/nxcon0"
|
||||
#endif
|
||||
|
||||
/* NxConsole task */
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_NXCONSOLE_PRIO
|
||||
# define CONFIG_EXAMPLES_NXCONSOLE_PRIO SCHED_PRIORITY_DEFAULT
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_NXCONSOLE_STACKSIZE
|
||||
# define CONFIG_EXAMPLES_NXCONSOLE_STACKSIZE 2048
|
||||
#endif
|
||||
|
||||
/* Debug ********************************************************************/
|
||||
|
||||
#ifdef CONFIG_CPP_HAVE_VARARGS
|
||||
|
@ -242,6 +268,7 @@ struct nxcon_state_s
|
|||
volatile bool haveres; /* True: Have screen resolution */
|
||||
volatile bool connected; /* True: Connected to server */
|
||||
sem_t eventsem; /* Control waiting for display events */
|
||||
pid_t pid; /* Console task ID */
|
||||
NXHANDLE hnx; /* The connection handler */
|
||||
NXTKWINDOW hwnd; /* The window */
|
||||
NXCONSOLE hdrvr; /* The console driver */
|
||||
|
|
|
@ -63,14 +63,14 @@
|
|||
#include <nuttx/nx/nxfonts.h>
|
||||
#include <nuttx/nx/nxconsole.h>
|
||||
|
||||
#include <apps/nsh.h>
|
||||
|
||||
#include "nxcon_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define NCON_MSG_NLINES 24
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
@ -83,37 +83,6 @@
|
|||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NX_KBD
|
||||
static const uint8_t g_pumsg[] = "Pop-Up!";
|
||||
static const char *g_nxcon_msg[NCON_MSG_NLINES] =
|
||||
{
|
||||
"\nJULIET\n", /* Line 1 */
|
||||
"Wilt thou be gone?\n", /* Line 2 */
|
||||
" It is not yet near day:\n", /* Line 3 */
|
||||
"It was the nightingale,\n", /* Line 4 */
|
||||
" and not the lark,\n", /* Line 5 */
|
||||
"That pierced the fearful hollow\n", /* Line 6 */
|
||||
" of thine ear;\n", /* Line 7 */
|
||||
"Nightly she sings\n", /* Line 8 */
|
||||
" on yon pomegranate-tree:\n", /* Line 9 */
|
||||
"Believe me, love,\n", /* Line 10 */
|
||||
" it was the nightingale.\n", /* Line 11 */
|
||||
"\nROMEO\n", /* Line 12 */
|
||||
"It was the lark,\n", /* Line 13 */
|
||||
" the herald of the morn,\n", /* Line 14 */
|
||||
"No nightingale:\n", /* Line 15 */
|
||||
" look, love, what envious streaks\n", /* Line 16 */
|
||||
"Do lace the severing clouds\n", /* Line 17 */
|
||||
" in yonder east:\n", /* Line 18 */
|
||||
"Night's candles are burnt out,\n", /* Line 19 */
|
||||
" and jocund day\n", /* Line 20 */
|
||||
"Stands tiptoe\n", /* Line 21 */
|
||||
" on the misty mountain tops.\n", /* Line 22 */
|
||||
"I must be gone and live,\n", /* Line 23 */
|
||||
" or stay and die.\n" /* Line 24 */
|
||||
};
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
@ -207,71 +176,113 @@ static int nxcon_initialize(void)
|
|||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxcon_task
|
||||
****************************************************************************/
|
||||
|
||||
static int nxcon_task(int argc, char **argv)
|
||||
{
|
||||
/* If the console front end is selected, then run it on this thread */
|
||||
|
||||
#ifdef CONFIG_NSH_CONSOLE
|
||||
(void)nsh_consolemain(0, NULL);
|
||||
#endif
|
||||
|
||||
printf("nxcon_task: Unregister the NX console device\n");
|
||||
(void)nxcon_unregister(g_nxcon_vars.hdrvr);
|
||||
|
||||
printf("nxcon_task: Close the window\n");
|
||||
(void)nxtk_closewindow(g_nxcon_vars.hwnd);
|
||||
|
||||
/* Disconnect from the server */
|
||||
|
||||
printf("nxcon_task: Disconnect from the server\n");
|
||||
nx_disconnect(g_nxcon_vars.hnx);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: user_start/nxcon_main
|
||||
* Name: user_start
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NSH_BUILTIN_APPS
|
||||
# define MAIN_NAME nxcon_main
|
||||
# define MAIN_NAME_STRING "nxcon_main"
|
||||
#else
|
||||
# define MAIN_NAME user_start
|
||||
# define MAIN_NAME_STRING "user_start"
|
||||
#endif
|
||||
|
||||
int MAIN_NAME(int argc, char **argv)
|
||||
int user_start(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 fd;
|
||||
int ret;
|
||||
|
||||
/* General Initialization *************************************************/
|
||||
/* Reset all global data */
|
||||
|
||||
message("user_start: Started\n");
|
||||
memset(&g_nxcon_vars, 0, sizeof(struct nxcon_state_s));
|
||||
|
||||
/* Call all C++ static constructors */
|
||||
|
||||
#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE)
|
||||
up_cxxinitialize();
|
||||
#endif
|
||||
|
||||
/* NSH Initialization *****************************************************/
|
||||
/* Initialize the NSH library */
|
||||
|
||||
message("user_start: Initialize NSH\n");
|
||||
nsh_initialize();
|
||||
|
||||
/* If the Telnet console is selected as a front-end, then start the
|
||||
* Telnet daemon.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NSH_TELNET
|
||||
ret = nsh_telnetstart();
|
||||
if (ret < 0)
|
||||
{
|
||||
/* The daemon is NOT running. Report the the error then fail...
|
||||
* either with the serial console up or just exiting.
|
||||
*/
|
||||
|
||||
fprintf(stderr, "ERROR: Failed to start TELNET daemon: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
/* NX Initialization ******************************************************/
|
||||
/* Initialize NX */
|
||||
|
||||
message("user_start: Initialize NX\n");
|
||||
ret = nxcon_initialize();
|
||||
message(MAIN_NAME_STRING ": NX handle=%p\n", g_nxcon_vars.hnx);
|
||||
message("user_start: NX handle=%p\n", g_nxcon_vars.hnx);
|
||||
if (!g_nxcon_vars.hnx || ret < 0)
|
||||
{
|
||||
message(MAIN_NAME_STRING ": Failed to get NX handle: %d\n", errno);
|
||||
message("user_start: Failed to get NX handle: %d\n", errno);
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Set the background to the configured background color */
|
||||
|
||||
message(MAIN_NAME_STRING ": Set background color=%d\n", CONFIG_EXAMPLES_NXCON_BGCOLOR);
|
||||
message("user_start: Set background color=%d\n", CONFIG_EXAMPLES_NXCON_BGCOLOR);
|
||||
color = CONFIG_EXAMPLES_NXCON_BGCOLOR;
|
||||
ret = nx_setbgcolor(g_nxcon_vars.hnx, &color);
|
||||
if (ret < 0)
|
||||
{
|
||||
message(MAIN_NAME_STRING ": nx_setbgcolor failed: %d\n", errno);
|
||||
message("user_start: nx_setbgcolor failed: %d\n", errno);
|
||||
goto errout_with_nx;
|
||||
}
|
||||
|
||||
/* Window Configuration ***************************************************/
|
||||
/* Create a window */
|
||||
|
||||
message(MAIN_NAME_STRING ": Create window\n");
|
||||
message("user_start: Create window\n");
|
||||
g_nxcon_vars.hwnd = nxtk_openwindow(g_nxcon_vars.hnx, &g_nxconcb, NULL);
|
||||
if (!g_nxcon_vars.hwnd)
|
||||
{
|
||||
message(MAIN_NAME_STRING ": nxtk_openwindow failed: %d\n", errno);
|
||||
message("user_start: nxtk_openwindow failed: %d\n", errno);
|
||||
goto errout_with_nx;
|
||||
}
|
||||
message(MAIN_NAME_STRING ": hwnd=%p\n", g_nxcon_vars.hwnd);
|
||||
message("user_start: hwnd=%p\n", g_nxcon_vars.hwnd);
|
||||
|
||||
/* Wait until we have the screen resolution. We'll have this immediately
|
||||
* unless we are dealing with the NX server.
|
||||
|
@ -281,7 +292,7 @@ int MAIN_NAME(int argc, char **argv)
|
|||
{
|
||||
(void)sem_wait(&g_nxcon_vars.eventsem);
|
||||
}
|
||||
message(MAIN_NAME_STRING ": Screen resolution (%d,%d)\n", g_nxcon_vars.xres, g_nxcon_vars.yres);
|
||||
message("user_start: Screen resolution (%d,%d)\n", g_nxcon_vars.xres, g_nxcon_vars.yres);
|
||||
|
||||
/* Determine the size and position of the window */
|
||||
|
||||
|
@ -293,38 +304,42 @@ int MAIN_NAME(int argc, char **argv)
|
|||
|
||||
/* Set the window position */
|
||||
|
||||
message(MAIN_NAME_STRING ": Set window position to (%d,%d)\n",
|
||||
message("user_start: Set window position to (%d,%d)\n",
|
||||
g_nxcon_vars.wpos.x, g_nxcon_vars.wpos.y);
|
||||
|
||||
ret = nxtk_setposition(g_nxcon_vars.hwnd, &g_nxcon_vars.wpos);
|
||||
if (ret < 0)
|
||||
{
|
||||
message(MAIN_NAME_STRING ": nxtk_setposition failed: %d\n", errno);
|
||||
message("user_start: nxtk_setposition failed: %d\n", errno);
|
||||
goto errout_with_hwnd;
|
||||
}
|
||||
|
||||
/* Set the window size */
|
||||
|
||||
message(MAIN_NAME_STRING ": Set window size to (%d,%d)\n",
|
||||
message("user_start: Set window size to (%d,%d)\n",
|
||||
g_nxcon_vars.wndo.wsize.w, g_nxcon_vars.wndo.wsize.h);
|
||||
|
||||
ret = nxtk_setsize(g_nxcon_vars.hwnd, &g_nxcon_vars.wndo.wsize);
|
||||
if (ret < 0)
|
||||
{
|
||||
message(MAIN_NAME_STRING ": nxtk_setsize failed: %d\n", errno);
|
||||
message("user_start: nxtk_setsize failed: %d\n", errno);
|
||||
goto errout_with_hwnd;
|
||||
}
|
||||
|
||||
/* Open the toolbar */
|
||||
|
||||
message(MAIN_NAME_STRING ": Add toolbar to window\n");
|
||||
message("user_start: Add toolbar to window\n");
|
||||
ret = nxtk_opentoolbar(g_nxcon_vars.hwnd, CONFIG_EXAMPLES_NXCON_TOOLBAR_HEIGHT, &g_nxtoolcb, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
message(MAIN_NAME_STRING ": nxtk_opentoolbar failed: %d\n", errno);
|
||||
message("user_start: nxtk_opentoolbar failed: %d\n", errno);
|
||||
goto errout_with_hwnd;
|
||||
}
|
||||
|
||||
/* Sleep a little bit to allow the server to catch up */
|
||||
|
||||
sleep(2);
|
||||
|
||||
/* NxConsole Configuration ************************************************/
|
||||
/* Use the window to create an NX console */
|
||||
|
||||
|
@ -335,99 +350,63 @@ int MAIN_NAME(int argc, char **argv)
|
|||
g_nxcon_vars.hdrvr = nxtk_register(g_nxcon_vars.hwnd, &g_nxcon_vars.wndo, CONFIG_EXAMPLES_NXCON_MINOR);
|
||||
if (!g_nxcon_vars.hdrvr)
|
||||
{
|
||||
message(MAIN_NAME_STRING ": nxtk_register failed: %d\n", errno);
|
||||
message("user_start: nxtk_register failed: %d\n", errno);
|
||||
goto errout_with_hwnd;
|
||||
}
|
||||
|
||||
/* Open the driver */
|
||||
/* Open the NxConsole driver */
|
||||
|
||||
#if 0 /* Don't re-direct... too hard to debug */
|
||||
fd = open(CONFIG_EXAMPLES_NXCON_DEVNAME, O_WRONLY);
|
||||
if (fd < 0)
|
||||
{
|
||||
message(MAIN_NAME_STRING ": open %s read-only failed: %d\n",
|
||||
message("user_start: open %s read-only failed: %d\n",
|
||||
CONFIG_EXAMPLES_NXCON_DEVNAME, errno);
|
||||
goto errout_with_driver;
|
||||
}
|
||||
|
||||
/* Start Console Task *****************************************************/
|
||||
/* 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.
|
||||
* Note that stdin is retained (file descriptor 0, probably the the serial console).
|
||||
*/
|
||||
|
||||
message("user_start: Starting the console task\n");
|
||||
msgflush();
|
||||
|
||||
(void)fflush(stdout);
|
||||
(void)fflush(stderr);
|
||||
|
||||
(void)fclose(stdout);
|
||||
(void)fclose(stderr);
|
||||
|
||||
(void)dup2(fd, 1);
|
||||
(void)dup2(fd, 2);
|
||||
|
||||
/* And we can close our original driver fd */
|
||||
/* And we can close our original driver file descriptor */
|
||||
|
||||
close(fd);
|
||||
#else
|
||||
/* Open the Console driver as a write-only stream */
|
||||
|
||||
/* And start the console task. It will inherit stdin, stdout, and stderr
|
||||
* from this task.
|
||||
*/
|
||||
|
||||
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
|
||||
g_nxcon_vars.pid = TASK_CREATE("NxConsole", CONFIG_EXAMPLES_NXCONSOLE_PRIO,
|
||||
CONFIG_EXAMPLES_NXCONSOLE_STACKSIZE,
|
||||
nxcon_task, NULL);
|
||||
ASSERT(g_nxcon_vars.pid > 0);
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
/* Test Loop **************************************************************/
|
||||
/* Now loop, adding text to the NX console */
|
||||
|
||||
ndx = 0;
|
||||
for (;;)
|
||||
{
|
||||
/* Sleep for one second */
|
||||
|
||||
sleep(1);
|
||||
|
||||
/* 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
|
||||
/* If this is an NSH built-in app, then just return after all
|
||||
* of the lines have been presented.
|
||||
*/
|
||||
|
||||
break;
|
||||
#else
|
||||
/* Otherwise, just reset the index to the first line and continue */
|
||||
|
||||
ndx = 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
exitcode = EXIT_SUCCESS;
|
||||
|
||||
/* Clean-up and Error Exits ***********************************************/
|
||||
|
||||
#if 1 /* Don't re-direct... too hard to debug */
|
||||
fclose(outstream);
|
||||
#endif
|
||||
/* Error Exits ************************************************************/
|
||||
|
||||
errout_with_driver:
|
||||
message(MAIN_NAME_STRING ": Unregister the NX console device\n");
|
||||
(void)nxcon_unregister(g_nxcon_vars.hdrvr);
|
||||
|
||||
errout_with_hwnd:
|
||||
message(MAIN_NAME_STRING ": Close the window\n");
|
||||
(void)nxtk_closewindow(g_nxcon_vars.hwnd);
|
||||
|
||||
errout_with_nx:
|
||||
/* Disconnect from the server */
|
||||
|
||||
message(MAIN_NAME_STRING ": Disconnect from the server\n");
|
||||
nx_disconnect(g_nxcon_vars.hnx);
|
||||
errout:
|
||||
return exitcode;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
|
@ -115,6 +115,8 @@ const struct nx_callback_s g_nxconcb =
|
|||
static void nxwndo_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
|
||||
bool more, FAR void *arg)
|
||||
{
|
||||
nxgl_mxpixel_t wcolor[CONFIG_NX_NPLANES];
|
||||
|
||||
gvdbg("hwnd=%p rect={(%d,%d),(%d,%d)} more=%s\n",
|
||||
hwnd, rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y,
|
||||
more ? "true" : "false");
|
||||
|
@ -127,6 +129,13 @@ static void nxwndo_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
|
|||
|
||||
nxcon_redraw(g_nxcon_vars.hdrvr, rect, more);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If the driver has not been opened, then just redraw the window color */
|
||||
|
||||
wcolor[0] = CONFIG_EXAMPLES_NXCON_WCOLOR;
|
||||
(void)nxtk_fillwindow(hwnd, rect, wcolor);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
@ -2604,3 +2604,7 @@
|
|||
user NX mode only).
|
||||
* arch/arm/src/stm32/stm32_i2c.c: Correct a bug in the STM32 I2C driver. The
|
||||
behavior of I2C status bits seems to be different between F1 and F4.
|
||||
* configs/stm3210e-eval/nxconsole: New STM32 F1 configuration that runs the
|
||||
NuttShell (NSH) within an NX window.
|
||||
* graphics/nxconsole/nxcon_sem.c: Add protection from re-entrance with debug
|
||||
is enabled.
|
||||
|
|
|
@ -408,6 +408,7 @@
|
|||
<p>
|
||||
NxConsole is a write-only character device (not shown) that is built on top of an NX window.
|
||||
This character device can be used to provide <code>stdout</code> and <code>stderr</code> and, hence, can provide the output side of NuttX console.
|
||||
NxConsole is only available when the multi-user NX implementation is selected (<code>CONFIG_NX_MULTIUSER</code>).
|
||||
</p>
|
||||
|
||||
<table width ="100%">
|
||||
|
|
|
@ -49,7 +49,3 @@ CONFIGURED_APPS += examples/nxhello
|
|||
CONFIGURED_APPS += examples/nxlines
|
||||
CONFIGURED_APPS += examples/touchscreen
|
||||
|
||||
ifeq ($(CONFIG_NXCONSOLE),y)
|
||||
CONFIGURED_APPS += examples/nxconsole
|
||||
endif
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ Contents
|
|||
- Temperature Sensor
|
||||
- RTC
|
||||
- STM3210E-EVAL-specific Configuration Options
|
||||
- NxConsole
|
||||
- Configurations
|
||||
|
||||
Development Environment
|
||||
|
@ -351,28 +350,6 @@ RTC
|
|||
overflow interrupt may be lost even if the STM32 is powered down only momentarily.
|
||||
Therefore hi-res solution is only useful in systems where the power is always on.
|
||||
|
||||
NxConsole
|
||||
=========
|
||||
|
||||
Several of the graphic-releted configurations are set to use the
|
||||
examples/nxconsole test. To enable this configuration,
|
||||
First, select NX Multi-User mode:
|
||||
|
||||
CONFG_NX_MULTIUSER=y
|
||||
CONFIG_DISABLE_MQUEUE=n
|
||||
|
||||
Then add the following definition to the defconfig file to enable
|
||||
the NxConsole driver:
|
||||
|
||||
CONFIG_NXCONSOLE=y
|
||||
|
||||
Make sure the that following is in place the appconfig file (perhaps
|
||||
eliminating other examples):
|
||||
|
||||
CONFIGURED_APPS += examples/nxconsole
|
||||
|
||||
See apps/examples/README.txt for further details.
|
||||
|
||||
STM3210E-EVAL-specific Configuration Options
|
||||
============================================
|
||||
|
||||
|
@ -748,8 +725,36 @@ Where <subdir> is one of the following:
|
|||
focuses on general window controls, movement, mouse and keyboard
|
||||
input.
|
||||
|
||||
CONFIG_STM32_CODESOURCERYW=y : CodeSourcery under Windows
|
||||
CONFIG_LCD_RPORTRAIT=y : 240x320 reverse portrait
|
||||
CONFIG_STM32_CODESOURCERYW=y : CodeSourcery under Windows
|
||||
CONFIG_LCD_RPORTRAIT=y : 240x320 reverse portrait
|
||||
|
||||
nxconsole:
|
||||
----------
|
||||
This is yet another NSH configuration. This NSH configuration differs
|
||||
from the other, however, in that it uses the NxConsole driver to host
|
||||
the NSH shell.
|
||||
|
||||
Some of the differences in this configuratino include these settings
|
||||
in the defconfig file:
|
||||
|
||||
These select NX Multi-User mode:
|
||||
|
||||
CONFG_NX_MULTIUSER=y
|
||||
CONFIG_DISABLE_MQUEUE=n
|
||||
|
||||
The following definition in the defconfig file to enables the NxConsole
|
||||
driver:
|
||||
|
||||
CONFIG_NXCONSOLE=y
|
||||
|
||||
The appconfig file selects examples/nxconsole instead of examples/nsh:
|
||||
|
||||
CONFIGURED_APPS += examples/nxconsole
|
||||
|
||||
Other configuration settings:
|
||||
|
||||
CONFIG_STM32_BUILDROOT=y : NuttX buildroot under Linux or Cygwin
|
||||
CONFIG_LCD_LANDSCAPE=y : 320x240 landscape
|
||||
|
||||
nxlines:
|
||||
------
|
||||
|
@ -757,8 +762,8 @@ Where <subdir> is one of the following:
|
|||
example focuses on placing lines on the background in various
|
||||
orientations.
|
||||
|
||||
CONFIG_STM32_CODESOURCERYW=y : CodeSourcery under Windows
|
||||
CONFIG_LCD_RPORTRAIT=y : 240x320 reverse portrait
|
||||
CONFIG_STM32_CODESOURCERYW=y : CodeSourcery under Windows
|
||||
CONFIG_LCD_RPORTRAIT=y : 240x320 reverse portrait
|
||||
|
||||
nxtext:
|
||||
------
|
||||
|
@ -767,8 +772,8 @@ Where <subdir> is one of the following:
|
|||
windows occur. Text should continue to update normally with
|
||||
or without the popup windows present.
|
||||
|
||||
CONFIG_STM32_BUILDROOT=y : NuttX buildroot under Linux or Cygwin
|
||||
CONFIG_LCD_RPORTRAIT=y : 240x320 reverse portrait
|
||||
CONFIG_STM32_BUILDROOT=y : NuttX buildroot under Linux or Cygwin
|
||||
CONFIG_LCD_RPORTRAIT=y : 240x320 reverse portrait
|
||||
|
||||
NOTE: When I tried building this example with the CodeSourcery
|
||||
tools, I got a hardfault inside of its libgcc. I haven't
|
||||
|
@ -781,14 +786,14 @@ Where <subdir> is one of the following:
|
|||
examples/ostest. By default, this project assumes that you are
|
||||
using the DFU bootloader.
|
||||
|
||||
CONFIG_STM32_BUILDROOT=y : NuttX buildroot under Linux or Cygwin
|
||||
CONFIG_STM32_BUILDROOT=y : NuttX buildroot under Linux or Cygwin
|
||||
|
||||
RIDE
|
||||
----
|
||||
This configuration builds a trivial bring-up binary. It is
|
||||
useful only because it words with the RIDE7 IDE and R-Link debugger.
|
||||
|
||||
CONFIG_STM32_RAISONANCE=y : Raisonance RIDE7 under Windows
|
||||
CONFIG_STM32_RAISONANCE=y : Raisonance RIDE7 under Windows
|
||||
|
||||
usbserial:
|
||||
---------
|
||||
|
@ -796,46 +801,46 @@ Where <subdir> is one of the following:
|
|||
driver at examples/usbserial. See examples/README.txt for
|
||||
more information.
|
||||
|
||||
CONFIG_STM32_BUILDROOT=y : NuttX buildroot under Linux or Cygwin
|
||||
CONFIG_STM32_BUILDROOT=y : NuttX buildroot under Linux or Cygwin
|
||||
|
||||
USB debug output can be enabled as by changing the following
|
||||
settings in the configuration file:
|
||||
|
||||
-CONFIG_DEBUG=n
|
||||
-CONFIG_DEBUG_VERBOSE=n
|
||||
-CONFIG_DEBUG_USB=n
|
||||
+CONFIG_DEBUG=y
|
||||
+CONFIG_DEBUG_VERBOSE=y
|
||||
+CONFIG_DEBUG_USB=y
|
||||
-CONFIG_DEBUG=n
|
||||
-CONFIG_DEBUG_VERBOSE=n
|
||||
-CONFIG_DEBUG_USB=n
|
||||
+CONFIG_DEBUG=y
|
||||
+CONFIG_DEBUG_VERBOSE=y
|
||||
+CONFIG_DEBUG_USB=y
|
||||
|
||||
-CONFIG_EXAMPLES_USBSERIAL_TRACEINIT=n
|
||||
-CONFIG_EXAMPLES_USBSERIAL_TRACECLASS=n
|
||||
-CONFIG_EXAMPLES_USBSERIAL_TRACETRANSFERS=n
|
||||
-CONFIG_EXAMPLES_USBSERIAL_TRACECONTROLLER=n
|
||||
-CONFIG_EXAMPLES_USBSERIAL_TRACEINTERRUPTS=n
|
||||
+CONFIG_EXAMPLES_USBSERIAL_TRACEINIT=y
|
||||
+CONFIG_EXAMPLES_USBSERIAL_TRACECLASS=y
|
||||
+CONFIG_EXAMPLES_USBSERIAL_TRACETRANSFERS=y
|
||||
+CONFIG_EXAMPLES_USBSERIAL_TRACECONTROLLER=y
|
||||
+CONFIG_EXAMPLES_USBSERIAL_TRACEINTERRUPTS=y
|
||||
-CONFIG_EXAMPLES_USBSERIAL_TRACEINIT=n
|
||||
-CONFIG_EXAMPLES_USBSERIAL_TRACECLASS=n
|
||||
-CONFIG_EXAMPLES_USBSERIAL_TRACETRANSFERS=n
|
||||
-CONFIG_EXAMPLES_USBSERIAL_TRACECONTROLLER=n
|
||||
-CONFIG_EXAMPLES_USBSERIAL_TRACEINTERRUPTS=n
|
||||
+CONFIG_EXAMPLES_USBSERIAL_TRACEINIT=y
|
||||
+CONFIG_EXAMPLES_USBSERIAL_TRACECLASS=y
|
||||
+CONFIG_EXAMPLES_USBSERIAL_TRACETRANSFERS=y
|
||||
+CONFIG_EXAMPLES_USBSERIAL_TRACECONTROLLER=y
|
||||
+CONFIG_EXAMPLES_USBSERIAL_TRACEINTERRUPTS=y
|
||||
|
||||
By default, the usbserial example uses the Prolific PL2303
|
||||
serial/USB converter emulation. The example can be modified
|
||||
to use the CDC/ACM serial class by making the following changes
|
||||
to the configuration file:
|
||||
|
||||
-CONFIG_PL2303=y
|
||||
+CONFIG_PL2303=n
|
||||
-CONFIG_PL2303=y
|
||||
+CONFIG_PL2303=n
|
||||
|
||||
-CONFIG_CDCACM=n
|
||||
+CONFIG_CDCACM=y
|
||||
-CONFIG_CDCACM=n
|
||||
+CONFIG_CDCACM=y
|
||||
|
||||
The example can also be converted to use the alternative
|
||||
USB serial example at apps/examples/usbterm by changing the
|
||||
following:
|
||||
|
||||
-CONFIGURED_APPS += examples/usbserial
|
||||
+CONFIGURED_APPS += examples/usbterm
|
||||
-CONFIGURED_APPS += examples/usbserial
|
||||
+CONFIGURED_APPS += examples/usbterm
|
||||
|
||||
In either the original appconfig file (before configuring)
|
||||
or in the final apps/.config file (after configuring).
|
||||
|
@ -846,5 +851,5 @@ Where <subdir> is one of the following:
|
|||
class driver at examples/usbstorage. See examples/README.txt for
|
||||
more information.
|
||||
|
||||
CONFIG_STM32_BUILDROOT=y : NuttX buildroot under Linux or Cygwin
|
||||
CONFIG_STM32_BUILDROOT=y : NuttX buildroot under Linux or Cygwin
|
||||
|
||||
|
|
|
@ -52,10 +52,6 @@ CONFIGURED_APPS += examples/nxhello
|
|||
#CONFIGURED_APPS += examples/nxtext
|
||||
CONFIGURED_APPS += examples/usbstorage
|
||||
|
||||
ifeq ($(CONFIG_NXCONSOLE),y)
|
||||
CONFIGURED_APPS += examples/nxconsole
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_I2C),y)
|
||||
CONFIGURED_APPS += system/i2c
|
||||
endif
|
||||
|
|
|
@ -34,12 +34,6 @@
|
|||
############################################################################
|
||||
|
||||
# Path to example in apps/examples containing the user_start entry point
|
||||
# Various NX tests can be supported, simply comment-out examples/nx and
|
||||
# uncomment the test you wish to perform
|
||||
|
||||
CONFIGURED_APPS += examples/nx
|
||||
#CONFIGURED_APPS += examples/nxhello
|
||||
#CONFIGURED_APPS += examples/nxlines
|
||||
#CONFIGURED_APPS += examples/nxtext
|
||||
#CONFIGURED_APPS += examples/nxconsole
|
||||
|
||||
|
|
|
@ -0,0 +1,176 @@
|
|||
############################################################################
|
||||
# configs/stm3210e-eval/nxconsole/Make.defs
|
||||
#
|
||||
# Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
include ${TOPDIR}/.config
|
||||
|
||||
# Setup for the selected toolchain
|
||||
|
||||
ifeq ($(CONFIG_STM32_DFU),y)
|
||||
LDSCRIPT = ld.script.dfu
|
||||
else
|
||||
LDSCRIPT = ld.script
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_STM32_CODESOURCERYW),y)
|
||||
# CodeSourcery under Windows
|
||||
CROSSDEV = arm-none-eabi-
|
||||
WINTOOL = y
|
||||
ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft
|
||||
MAXOPTIMIZATION = -O1
|
||||
endif
|
||||
ifeq ($(CONFIG_STM32_CODESOURCERYL),y)
|
||||
# CodeSourcery under Linux
|
||||
CROSSDEV = arm-none-eabi-
|
||||
ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft
|
||||
MAXOPTIMIZATION = -O1
|
||||
endif
|
||||
ifeq ($(CONFIG_STM32_DEVKITARM),y)
|
||||
# devkitARM under Windows
|
||||
CROSSDEV = arm-eabi-
|
||||
WINTOOL = y
|
||||
ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft
|
||||
MAXOPTIMIZATION = -O2
|
||||
endif
|
||||
ifeq ($(CONFIG_STM32_RAISONANCE),y)
|
||||
# Raisonance RIDE7 under Windows
|
||||
CROSSDEV = arm-none-eabi-
|
||||
WINTOOL = y
|
||||
ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft
|
||||
MAXOPTIMIZATION = -O2
|
||||
endif
|
||||
ifeq ($(CONFIG_STM32_BUILDROOT),y)
|
||||
# NuttX buildroot under Linux or Cygwin
|
||||
CROSSDEV = arm-elf-
|
||||
ARCHCPUFLAGS = -mtune=cortex-m3 -march=armv7-m -mfloat-abi=soft
|
||||
MAXOPTIMIZATION = -Os
|
||||
endif
|
||||
|
||||
ifeq ($(WINTOOL),y)
|
||||
# Windows-native toolchains
|
||||
DIRLINK = $(TOPDIR)/tools/winlink.sh
|
||||
DIRUNLINK = $(TOPDIR)/tools/unlink.sh
|
||||
MKDEP = $(TOPDIR)/tools/mknulldeps.sh
|
||||
ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}"
|
||||
ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}"
|
||||
ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/nxconsole/$(LDSCRIPT)}"
|
||||
else
|
||||
# Linux/Cygwin-native toolchain
|
||||
MKDEP = $(TOPDIR)/tools/mkdeps.sh
|
||||
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
|
||||
ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx
|
||||
ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/nxconsole/$(LDSCRIPT)
|
||||
endif
|
||||
|
||||
CC = $(CROSSDEV)gcc
|
||||
CXX = $(CROSSDEV)g++
|
||||
CPP = $(CROSSDEV)gcc -E
|
||||
LD = $(CROSSDEV)ld
|
||||
AR = $(CROSSDEV)ar rcs
|
||||
NM = $(CROSSDEV)nm
|
||||
OBJCOPY = $(CROSSDEV)objcopy
|
||||
OBJDUMP = $(CROSSDEV)objdump
|
||||
|
||||
ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'}
|
||||
ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1}
|
||||
|
||||
ifeq ("${CONFIG_DEBUG_SYMBOLS}","y")
|
||||
ARCHOPTIMIZATION = -g
|
||||
else
|
||||
ARCHOPTIMIZATION = $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer
|
||||
endif
|
||||
|
||||
ARCHCFLAGS = -fno-builtin
|
||||
ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fno-rtti
|
||||
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow
|
||||
ARCHWARNINGSXX = -Wall -Wshadow
|
||||
ARCHDEFINES =
|
||||
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
|
||||
|
||||
CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
|
||||
CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
|
||||
CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
|
||||
CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
|
||||
CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES)
|
||||
AFLAGS = $(CFLAGS) -D__ASSEMBLY__
|
||||
|
||||
NXFLATLDFLAGS1 = -r -d -warn-common
|
||||
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat.ld -no-check-sections
|
||||
LDNXFLATFLAGS = -e main -s 2048
|
||||
|
||||
OBJEXT = .o
|
||||
LIBEXT = .a
|
||||
EXEEXT =
|
||||
|
||||
ifneq ($(CROSSDEV),arm-elf-)
|
||||
LDFLAGS += -nostartfiles -nodefaultlibs
|
||||
endif
|
||||
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
||||
LDFLAGS += -g
|
||||
endif
|
||||
|
||||
define PREPROCESS
|
||||
@echo "CPP: $1->$2"
|
||||
@$(CPP) $(CPPFLAGS) $1 -o $2
|
||||
endef
|
||||
|
||||
define COMPILE
|
||||
@echo "CC: $1"
|
||||
@$(CC) -c $(CFLAGS) $1 -o $2
|
||||
endef
|
||||
|
||||
define COMPILEXX
|
||||
@echo "CXX: $1"
|
||||
@$(CXX) -c $(CXXFLAGS) $1 -o $2
|
||||
endef
|
||||
|
||||
define ASSEMBLE
|
||||
@echo "AS: $1"
|
||||
@$(CC) -c $(AFLAGS) $1 -o $2
|
||||
endef
|
||||
|
||||
define ARCHIVE
|
||||
echo "AR: $2"; \
|
||||
$(AR) $1 $2 || { echo "$(AR) $1 $2 FAILED!" ; exit 1 ; }
|
||||
endef
|
||||
|
||||
define CLEAN
|
||||
@rm -f *.o *.a
|
||||
endef
|
||||
|
||||
HOSTCC = gcc
|
||||
HOSTINCLUDES = -I.
|
||||
HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -g -pipe
|
||||
HOSTLDFLAGS =
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
############################################################################
|
||||
# configs/stm3210e-eval/nxconsole/appconfig
|
||||
#
|
||||
# Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
# Path to example in apps/examples containing the user_start entry point
|
||||
|
||||
CONFIGURED_APPS += examples/nxconsole
|
||||
|
||||
CONFIGURED_APPS += system/readline
|
||||
CONFIGURED_APPS += nshlib
|
||||
|
||||
# Optional built-in applications
|
||||
|
||||
ifeq ($(CONFIG_USBDEV),y)
|
||||
CONFIGURED_APPS += examples/usbstorage
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_I2C),y)
|
||||
CONFIGURED_APPS += system/i2c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CAN),y)
|
||||
CONFIGURED_APPS += examples/can
|
||||
endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,112 @@
|
|||
/****************************************************************************
|
||||
* configs/stm3210e-eval/nxconsole/ld.script
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* The STM32F103ZET6 has 512Kb of FLASH beginning at address 0x0800:0000 and
|
||||
* 64Kb of SRAM beginning at address 0x2000:0000. When booting from FLASH,
|
||||
* FLASH memory is aliased to address 0x0000:0000 where the code expects to
|
||||
* begin execution by jumping to the entry point in the 0x0800:0000 address
|
||||
* range.
|
||||
*/
|
||||
|
||||
MEMORY
|
||||
{
|
||||
flash (rx) : ORIGIN = 0x08000000, LENGTH = 512K
|
||||
sram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K
|
||||
}
|
||||
|
||||
OUTPUT_ARCH(arm)
|
||||
ENTRY(_stext)
|
||||
SECTIONS
|
||||
{
|
||||
.text : {
|
||||
_stext = ABSOLUTE(.);
|
||||
*(.vectors)
|
||||
*(.text .text.*)
|
||||
*(.fixup)
|
||||
*(.gnu.warning)
|
||||
*(.rodata .rodata.*)
|
||||
*(.gnu.linkonce.t.*)
|
||||
*(.glue_7)
|
||||
*(.glue_7t)
|
||||
*(.got)
|
||||
*(.gcc_except_table)
|
||||
*(.gnu.linkonce.r.*)
|
||||
_etext = ABSOLUTE(.);
|
||||
} > flash
|
||||
|
||||
_eronly = ABSOLUTE(.);
|
||||
|
||||
/* The STM32F103Z has 64Kb of SRAM beginning at the following address */
|
||||
|
||||
.data : {
|
||||
_sdata = ABSOLUTE(.);
|
||||
*(.data .data.*)
|
||||
*(.gnu.linkonce.d.*)
|
||||
CONSTRUCTORS
|
||||
_edata = ABSOLUTE(.);
|
||||
} > sram AT > flash
|
||||
|
||||
.ARM.extab : {
|
||||
*(.ARM.extab*)
|
||||
} >sram
|
||||
|
||||
__exidx_start = ABSOLUTE(.);
|
||||
.ARM.exidx : {
|
||||
*(.ARM.exidx*)
|
||||
} >sram
|
||||
__exidx_end = ABSOLUTE(.);
|
||||
|
||||
.bss : {
|
||||
_sbss = ABSOLUTE(.);
|
||||
*(.bss .bss.*)
|
||||
*(.gnu.linkonce.b.*)
|
||||
*(COMMON)
|
||||
_ebss = ABSOLUTE(.);
|
||||
} > sram
|
||||
|
||||
/* Stabs debugging sections. */
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
.comment 0 : { *(.comment) }
|
||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||
.debug_info 0 : { *(.debug_info) }
|
||||
.debug_line 0 : { *(.debug_line) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
/****************************************************************************
|
||||
* configs/stm3210e-eval/nxconsole/ld.script.dfu
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* The STM32F103ZET6 has 512Kb of FLASH beginning at address 0x0800:0000 and
|
||||
* 64Kb of SRAM beginning at address 0x2000:0000. Here we assume that the
|
||||
* STM3210E-EVAL's DFU bootloader is being used. In that case, the corrct
|
||||
* load .text load address is 0x08003000 (leaving 464Kb).
|
||||
*/
|
||||
|
||||
MEMORY
|
||||
{
|
||||
flash (rx) : ORIGIN = 0x08003000, LENGTH = 464K
|
||||
sram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K
|
||||
}
|
||||
|
||||
OUTPUT_ARCH(arm)
|
||||
ENTRY(_stext)
|
||||
SECTIONS
|
||||
{
|
||||
.text : {
|
||||
_stext = ABSOLUTE(.);
|
||||
*(.vectors)
|
||||
*(.text .text.*)
|
||||
*(.fixup)
|
||||
*(.gnu.warning)
|
||||
*(.rodata .rodata.*)
|
||||
*(.gnu.linkonce.t.*)
|
||||
*(.glue_7)
|
||||
*(.glue_7t)
|
||||
*(.got)
|
||||
*(.gcc_except_table)
|
||||
*(.gnu.linkonce.r.*)
|
||||
_etext = ABSOLUTE(.);
|
||||
} > flash
|
||||
|
||||
_eronly = ABSOLUTE(.);
|
||||
|
||||
/* The STM32F103Z has 64Kb of SRAM beginning at the following address */
|
||||
|
||||
.data : {
|
||||
_sdata = ABSOLUTE(.);
|
||||
*(.data .data.*)
|
||||
*(.gnu.linkonce.d.*)
|
||||
CONSTRUCTORS
|
||||
_edata = ABSOLUTE(.);
|
||||
} > sram AT > flash
|
||||
|
||||
.ARM.extab : {
|
||||
*(.ARM.extab*)
|
||||
} >sram
|
||||
|
||||
__exidx_start = ABSOLUTE(.);
|
||||
.ARM.exidx : {
|
||||
*(.ARM.exidx*)
|
||||
} >sram
|
||||
__exidx_end = ABSOLUTE(.);
|
||||
|
||||
.bss : {
|
||||
_sbss = ABSOLUTE(.);
|
||||
*(.bss .bss.*)
|
||||
*(.gnu.linkonce.b.*)
|
||||
*(COMMON)
|
||||
_ebss = ABSOLUTE(.);
|
||||
} > sram
|
||||
|
||||
/* Stabs debugging sections. */
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
.comment 0 : { *(.comment) }
|
||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||
.debug_info 0 : { *(.debug_info) }
|
||||
.debug_line 0 : { *(.debug_line) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
#!/bin/bash
|
||||
# configs/stm3210e-eval/nxconsole/setenv.sh
|
||||
#
|
||||
# Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
if [ "$_" = "$0" ] ; then
|
||||
echo "You must source this script, not run it!" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
WD=`pwd`
|
||||
if [ ! -x "setenv.sh" ]; then
|
||||
echo "This script must be executed from the top-level NuttX build directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "${PATH_ORIG}" ]; then
|
||||
export PATH_ORIG="${PATH}"
|
||||
fi
|
||||
|
||||
# This the Cygwin path to the location where I installed the CodeSourcery
|
||||
# toolchain under windows. You will also have to edit this if you install
|
||||
# the CodeSourcery toolchain in any other location
|
||||
export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/CodeSourcery/Sourcery G++ Lite/bin"
|
||||
|
||||
# This the Cygwin path to the location where I build the buildroot
|
||||
# toolchain.
|
||||
#export TOOLCHAIN_BIN="${WD}/../misc/buildroot/build_arm_nofpu/staging_dir/bin"
|
||||
|
||||
# Add the path to the toolchain to the PATH varialble
|
||||
export PATH="${TOOLCHAIN_BIN}:/sbin:/usr/sbin:${PATH_ORIG}"
|
||||
|
||||
echo "PATH : ${PATH}"
|
|
@ -34,11 +34,5 @@
|
|||
############################################################################
|
||||
|
||||
# Path to example in apps/examples containing the user_start entry point
|
||||
# Various NX tests can be supported, simply comment-out examples/nx and
|
||||
# uncomment the test you wish to perform
|
||||
|
||||
#CONFIGURED_APPS += examples/nx
|
||||
#CONFIGURED_APPS += examples/nxhello
|
||||
CONFIGURED_APPS += examples/nxlines
|
||||
#CONFIGURED_APPS += examples/nxtext
|
||||
#CONFIGURED_APPS += examples/nxconsole
|
||||
|
|
|
@ -34,12 +34,6 @@
|
|||
############################################################################
|
||||
|
||||
# Path to example in apps/examples containing the user_start entry point
|
||||
# Various NX tests can be supported, simply comment-out examples/nx and
|
||||
# uncomment the test you wish to perform
|
||||
|
||||
#CONFIGURED_APPS += examples/nx
|
||||
#CONFIGURED_APPS += examples/nxhello
|
||||
#CONFIGURED_APPS += examples/nxlines
|
||||
CONFIGURED_APPS += examples/nxtext
|
||||
#CONFIGURED_APPS += examples/nxconsole
|
||||
|
||||
|
|
|
@ -37,6 +37,9 @@ at the present, but here is the longer term roadmap:
|
|||
NxConsole - NxConsole is a write-only character device that is built on top of
|
||||
an NX window. This character device can be used to provide stdout
|
||||
and stderr and, hence, can provide the output side of NuttX console.
|
||||
NxConsole is only available when the multi-user NX implementation is
|
||||
selected (CONFIG_NX_MULTIUSERs).
|
||||
|
||||
|
||||
Related Header Files
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
@ -37,3 +37,7 @@ NXCON_ASRCS =
|
|||
NXCON_CSRCS = nx_register.c nxcon_driver.c nxcon_font.c nxcon_redraw.c
|
||||
NXCON_CSRCS += nxcon_register.c nxcon_scroll.c nxcon_unregister.c
|
||||
NXCON_CSRCS += nxtk_register.c nxtool_register.c
|
||||
|
||||
ifeq ($(CONFIG_DEBUG),y)
|
||||
NXCON_CSRCS += nxcon_sem.c
|
||||
endif
|
||||
|
|
|
@ -136,7 +136,7 @@ static ssize_t nxcon_write(FAR struct file *filep, FAR const char *buffer,
|
|||
|
||||
/* Get exclusive access */
|
||||
|
||||
ret = sem_wait(&priv->exclsem);
|
||||
ret = nxcon_semwait(priv);
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
|
@ -195,7 +195,7 @@ static ssize_t nxcon_write(FAR struct file *filep, FAR const char *buffer,
|
|||
nxcon_putc(priv, (uint8_t)ch);
|
||||
}
|
||||
|
||||
sem_post(&priv->exclsem);
|
||||
nxcon_sempost(priv);
|
||||
return (ssize_t)buflen;
|
||||
}
|
||||
|
||||
|
|
|
@ -241,10 +241,6 @@ nxcon_renderglyph(FAR struct nxcon_state_s *priv,
|
|||
int col;
|
||||
int ret;
|
||||
|
||||
/* Make sure that there is room for another glyph */
|
||||
|
||||
gvdbg("ch=%c [%02x]\n", isprint(ch) ? ch : '.', ch);
|
||||
|
||||
/* Allocate the glyph (always succeeds) */
|
||||
|
||||
glyph = nxcon_allocglyph(priv);
|
||||
|
@ -629,10 +625,7 @@ void nxcon_fillchar(FAR struct nxcon_state_s *priv,
|
|||
src = (FAR const void *)glyph->bitmap;
|
||||
ret = priv->ops->bitmap(priv, &intersection, &src,
|
||||
&bm->pos, (unsigned int)glyph->stride);
|
||||
if (ret < 0)
|
||||
{
|
||||
gdbg("bitmap failed: %d\n", errno);
|
||||
}
|
||||
DEBUGASSERT(ret >= 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,6 +70,10 @@
|
|||
#define NX_DEVNAME_FORMAT "/dev/nxcon%d"
|
||||
#define NX_DEVNAME_SIZE 16
|
||||
|
||||
/* Semaphore protection */
|
||||
|
||||
#define NO_HOLDER (pid_t)-1
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
@ -126,6 +130,9 @@ struct nxcon_state_s
|
|||
FAR struct nxcon_window_s wndo; /* Describes the window and font */
|
||||
NXHANDLE font; /* The current font handle */
|
||||
sem_t exclsem; /* Forces mutually exclusive access */
|
||||
#ifdef CONFIG_DEBUG
|
||||
pid_t holder; /* Deadlock avoidance */
|
||||
#endif
|
||||
struct nxgl_point_s fpos; /* Next display position */
|
||||
|
||||
uint16_t maxchars; /* Size of the bm[] array */
|
||||
|
@ -165,6 +172,16 @@ extern const struct file_operations g_nxcon_drvrops;
|
|||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
/* Semaphore helpers */
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
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);
|
||||
#endif
|
||||
|
||||
/* Common device registration */
|
||||
|
||||
FAR struct nxcon_state_s *nxcon_register(NXCONSOLE handle,
|
||||
|
|
|
@ -117,7 +117,7 @@ void nxcon_redraw(NXCONSOLE handle, FAR const struct nxgl_rect_s *rect, bool mor
|
|||
|
||||
do
|
||||
{
|
||||
ret = sem_wait(&priv->exclsem);
|
||||
ret = nxcon_semwait(priv);
|
||||
|
||||
/* Check for errors */
|
||||
|
||||
|
@ -148,5 +148,5 @@ void nxcon_redraw(NXCONSOLE handle, FAR const struct nxgl_rect_s *rect, bool mor
|
|||
{
|
||||
nxcon_fillchar(priv, rect, &priv->bm[i]);
|
||||
}
|
||||
ret = sem_post(&priv->exclsem);
|
||||
ret = nxcon_sempost(priv);
|
||||
}
|
||||
|
|
|
@ -236,4 +236,4 @@ void nxcon_scroll(FAR struct nxcon_state_s *priv, int scrollheight)
|
|||
/* Move the display in the range of 0-height up one scrollheight. */
|
||||
|
||||
nxcon_movedisplay(priv, priv->fpos.y, scrollheight);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,129 @@
|
|||
/****************************************************************************
|
||||
* nuttx/graphics/nxconsole/nxcon_unregister.c
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <semaphore.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "nxcon_internal.h"
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxcon_semwait and nxcon_sempost
|
||||
*
|
||||
* Description:
|
||||
* If debug is on, then lower level code may attempt console output while
|
||||
* we are doing console output! In this case, we will toss the nested
|
||||
* output to avoid deadlocks and infinite loops.
|
||||
*
|
||||
* Input Parameters:
|
||||
* priv - Driver data structure
|
||||
*
|
||||
* Returned Value:
|
||||
*
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nxcon_semwait(FAR struct nxcon_state_s *priv)
|
||||
{
|
||||
pid_t me;
|
||||
int ret;
|
||||
|
||||
/* Does I already hold the semaphore */
|
||||
|
||||
me = getpid();
|
||||
if (priv->holder != me)
|
||||
{
|
||||
/* No.. then wait until the thread that does hold it is finished with it */
|
||||
|
||||
ret = sem_wait(&priv->exclsem);
|
||||
if (ret == OK)
|
||||
{
|
||||
/* No I hold the semaphore */
|
||||
|
||||
priv->holder = me;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Abort, abort, abort! I have been re-entered */
|
||||
|
||||
set_errno(EBUSY);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
int nxcon_sempost(FAR struct nxcon_state_s *priv)
|
||||
{
|
||||
pid_t me = getpid();
|
||||
|
||||
/* Make sure that I really hold the semaphore */
|
||||
|
||||
ASSERT(priv->holder == me);
|
||||
|
||||
/* Then let go of it */
|
||||
|
||||
priv->holder = NO_HOLDER;
|
||||
return sem_post(&priv->exclsem);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_DEBUG */
|
|
@ -1,8 +1,8 @@
|
|||
/****************************************************************************
|
||||
* graphics/nxtk/nxtk_events.c
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Copyright (C) 2008-2009, 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -131,7 +131,7 @@ static void nxtk_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
|
|||
|
||||
nxtk_containerclip(fwnd, &intersection, rect, &fwnd->fwrect);
|
||||
|
||||
gvdbg("fwrect intersction={(%d,%d),(%d,%d)}\n",
|
||||
gvdbg("fwrect intersection={(%d,%d),(%d,%d)}\n",
|
||||
intersection.pt1.x, intersection.pt1.y,
|
||||
intersection.pt2.x, intersection.pt2.y);
|
||||
|
||||
|
@ -154,7 +154,7 @@ static void nxtk_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
|
|||
|
||||
nxtk_containerclip(fwnd, &intersection, rect, &fwnd->tbrect);
|
||||
|
||||
gvdbg("tbrect intersction={(%d,%d),(%d,%d)}\n",
|
||||
gvdbg("tbrect intersection={(%d,%d),(%d,%d)}\n",
|
||||
intersection.pt1.x, intersection.pt1.y,
|
||||
intersection.pt2.x, intersection.pt2.y);
|
||||
|
||||
|
|
Loading…
Reference in New Issue