apps/examples/usbstorage can now be built as NSH built-in commands; configs/stm3210e-eval/nsh2 now uses these usb storage commands
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3812 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
f6f94461ed
commit
1f9f4c5169
@ -82,3 +82,7 @@
|
|||||||
* apps/examples/nximage: Another super simple graphics example: It just puts
|
* apps/examples/nximage: Another super simple graphics example: It just puts
|
||||||
the NuttX logo in the center of the display. This example can also be
|
the NuttX logo in the center of the display. This example can also be
|
||||||
built as an NSH "built-in" command.
|
built as an NSH "built-in" command.
|
||||||
|
* apps/examples/usbstorage: Can now be built as two NSH "built-in" commands:
|
||||||
|
'msconn' will connect the USB mass storage device; 'msdis' will disconnect
|
||||||
|
the USB storage device.
|
||||||
|
|
||||||
|
@ -38,13 +38,29 @@
|
|||||||
# Sub-directories
|
# Sub-directories
|
||||||
|
|
||||||
SUBDIRS = buttons dhcpd ftpc hello helloxx hidkbd igmp mm mount nettest \
|
SUBDIRS = buttons dhcpd ftpc hello helloxx hidkbd igmp mm mount nettest \
|
||||||
nsh null nx nxffs nxflat nxhello nximage nxtext stest pashello pipe \
|
nsh null nx nxffs nxflat nxhello nximage nxtext ostest pashello pipe \
|
||||||
poll rgmp romfs sendmail serloop thttpd udp uip usbserial usbstorage \
|
poll rgmp romfs sendmail serloop thttpd udp uip usbserial usbstorage \
|
||||||
wget wlan
|
wget wlan
|
||||||
|
|
||||||
# Sub-directories that might need context setup
|
# Sub-directories that might need context setup
|
||||||
|
|
||||||
CNTXTDIRS = nx nxhello nximage nxtext
|
CNTXTDIRS =
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_EXAMPLES_NX_BUILTIN),y)
|
||||||
|
CNTXTDIRS += nx
|
||||||
|
endif
|
||||||
|
ifeq ($(CONFIG_EXAMPLES_NXHELLO_BUILTIN),y)
|
||||||
|
CNTXTDIRS += nxhello
|
||||||
|
endif
|
||||||
|
ifeq ($(CONFIG_EXAMPLES_NXIMAGE_BUILTIN),y)
|
||||||
|
CNTXTDIRS += nximage
|
||||||
|
endif
|
||||||
|
ifeq ($(CONFIG_EXAMPLES_NXTEXT_BUILTIN),y)
|
||||||
|
CNTXTDIRS += nxtext
|
||||||
|
endif
|
||||||
|
ifeq ($(CONFIG_EXAMPLES_USBSTRG_BUILTIN),y)
|
||||||
|
CNTXTDIRS += usbstorage
|
||||||
|
endif
|
||||||
|
|
||||||
all: nothing
|
all: nothing
|
||||||
.PHONY: nothing context depend clean distclean
|
.PHONY: nothing context depend clean distclean
|
||||||
|
@ -800,6 +800,10 @@ examples/usbstorage
|
|||||||
|
|
||||||
Configuration options:
|
Configuration options:
|
||||||
|
|
||||||
|
CONFIG_EXAMPLES_USBSTRG_BUILTIN
|
||||||
|
This example can be built as two NSH "built-in" commands if this option
|
||||||
|
is selection: 'msconn' will connect the USB mass storage device; 'msdis'
|
||||||
|
will disconnect the USB storage device.
|
||||||
CONFIG_EXAMPLES_USBSTRG_NLUNS
|
CONFIG_EXAMPLES_USBSTRG_NLUNS
|
||||||
Defines the number of logical units (LUNs) exported by the USB storage
|
Defines the number of logical units (LUNs) exported by the USB storage
|
||||||
driver. Each LUN corresponds to one exported block driver (or partition
|
driver. Each LUN corresponds to one exported block driver (or partition
|
||||||
|
@ -231,7 +231,7 @@ static inline NXEGWINDOW nxeg_openwindow(FAR const struct nx_callback_s *cb,
|
|||||||
hwnd = nx_openwindow(g_hnx, cb, (FAR void *)state);
|
hwnd = nx_openwindow(g_hnx, cb, (FAR void *)state);
|
||||||
if (!hwnd)
|
if (!hwnd)
|
||||||
{
|
{
|
||||||
message("user_start: nx_openwindow failed: %d\n", errno);
|
message("nxeg_openwindow: nx_openwindow failed: %d\n", errno);
|
||||||
g_exitcode = NXEXIT_NXOPENWINDOW;
|
g_exitcode = NXEXIT_NXOPENWINDOW;
|
||||||
}
|
}
|
||||||
return hwnd;
|
return hwnd;
|
||||||
@ -245,7 +245,7 @@ static inline NXEGWINDOW nxeg_openwindow(FAR const struct nx_callback_s *cb,
|
|||||||
hwnd = nxtk_openwindow(g_hnx, cb, (FAR void *)state);
|
hwnd = nxtk_openwindow(g_hnx, cb, (FAR void *)state);
|
||||||
if (!hwnd)
|
if (!hwnd)
|
||||||
{
|
{
|
||||||
message("user_start: nxtk_openwindow failed: %d\n", errno);
|
message("nxeg_openwindow: nxtk_openwindow failed: %d\n", errno);
|
||||||
g_exitcode = NXEXIT_NXOPENWINDOW;
|
g_exitcode = NXEXIT_NXOPENWINDOW;
|
||||||
}
|
}
|
||||||
return hwnd;
|
return hwnd;
|
||||||
@ -262,7 +262,7 @@ static inline int nxeg_closewindow(NXEGWINDOW hwnd, FAR struct nxeg_state_s *sta
|
|||||||
int ret = nx_closewindow(hwnd);
|
int ret = nx_closewindow(hwnd);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
message("user_start: nx_closewindow failed: %d\n", errno);
|
message("nxeg_closewindow: nx_closewindow failed: %d\n", errno);
|
||||||
g_exitcode = NXEXIT_NXCLOSEWINDOW;
|
g_exitcode = NXEXIT_NXCLOSEWINDOW;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -273,7 +273,7 @@ static inline int nxeg_closewindow(NXEGWINDOW hwnd, FAR struct nxeg_state_s *sta
|
|||||||
int ret = nxtk_closewindow(hwnd);
|
int ret = nxtk_closewindow(hwnd);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
message("user_start: nxtk_closewindow failed: %d\n", errno);
|
message("nxeg_closewindow: nxtk_closewindow failed: %d\n", errno);
|
||||||
g_exitcode = NXEXIT_NXCLOSEWINDOW;
|
g_exitcode = NXEXIT_NXCLOSEWINDOW;
|
||||||
}
|
}
|
||||||
nxeg_freestate(state);
|
nxeg_freestate(state);
|
||||||
@ -291,7 +291,7 @@ static inline int nxeg_setsize(NXEGWINDOW hwnd, FAR struct nxgl_size_s *size)
|
|||||||
int ret = nx_setsize(hwnd, size);
|
int ret = nx_setsize(hwnd, size);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
message("user_start: nx_setsize failed: %d\n", errno);
|
message("nxeg_setsize: nx_setsize failed: %d\n", errno);
|
||||||
g_exitcode = NXEXIT_NXSETSIZE;
|
g_exitcode = NXEXIT_NXSETSIZE;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -302,7 +302,7 @@ static inline int nxeg_setsize(NXEGWINDOW hwnd, FAR struct nxgl_size_s *size)
|
|||||||
int ret = nxtk_setsize(hwnd, size);
|
int ret = nxtk_setsize(hwnd, size);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
message("user_start: nxtk_setsize failed: %d\n", errno);
|
message("nxeg_setsize: nxtk_setsize failed: %d\n", errno);
|
||||||
g_exitcode = NXEXIT_NXSETSIZE;
|
g_exitcode = NXEXIT_NXSETSIZE;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -319,7 +319,7 @@ static inline int nxeg_setposition(NXEGWINDOW hwnd, FAR struct nxgl_point_s *pos
|
|||||||
int ret = nx_setposition(hwnd, pos);
|
int ret = nx_setposition(hwnd, pos);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
message("user_start: nx_setposition failed: %d\n", errno);
|
message("nxeg_setposition: nx_setposition failed: %d\n", errno);
|
||||||
g_exitcode = NXEXIT_NXSETPOSITION;
|
g_exitcode = NXEXIT_NXSETPOSITION;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -330,7 +330,7 @@ static inline int nxeg_setposition(NXEGWINDOW hwnd, FAR struct nxgl_point_s *pos
|
|||||||
int ret = nxtk_setposition(hwnd, pos);
|
int ret = nxtk_setposition(hwnd, pos);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
message("user_start: nxtk_setposition failed: %d\n", errno);
|
message("nxeg_setposition: nxtk_setposition failed: %d\n", errno);
|
||||||
g_exitcode = NXEXIT_NXSETPOSITION;
|
g_exitcode = NXEXIT_NXSETPOSITION;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -350,7 +350,7 @@ static inline int nxeq_opentoolbar(NXEGWINDOW hwnd, nxgl_coord_t height,
|
|||||||
ret = nxtk_opentoolbar(hwnd, height, cb, (FAR void *)state);
|
ret = nxtk_opentoolbar(hwnd, height, cb, (FAR void *)state);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
message("user_start: nxtk_opentoolbar failed: %d\n", errno);
|
message("nxeq_opentoolbar: nxtk_opentoolbar failed: %d\n", errno);
|
||||||
g_exitcode = NXEXIT_NXOPENTOOLBAR;
|
g_exitcode = NXEXIT_NXOPENTOOLBAR;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -367,7 +367,7 @@ static inline int nxeg_lower(NXEGWINDOW hwnd)
|
|||||||
int ret = nx_lower(hwnd);
|
int ret = nx_lower(hwnd);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
message("user_start: nx_lower failed: %d\n", errno);
|
message("nxeg_lower: nx_lower failed: %d\n", errno);
|
||||||
g_exitcode = NXEXIT_NXLOWER;
|
g_exitcode = NXEXIT_NXLOWER;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -378,7 +378,7 @@ static inline int nxeg_lower(NXEGWINDOW hwnd)
|
|||||||
int ret = nxtk_lower(hwnd);
|
int ret = nxtk_lower(hwnd);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
message("user_start: nxtk_lower failed: %d\n", errno);
|
message("nxeg_lower: nxtk_lower failed: %d\n", errno);
|
||||||
g_exitcode = NXEXIT_NXLOWER;
|
g_exitcode = NXEXIT_NXLOWER;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -395,7 +395,7 @@ static inline int nxeg_raise(NXEGWINDOW hwnd)
|
|||||||
int ret = nx_raise(hwnd);
|
int ret = nx_raise(hwnd);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
message("user_start: nx_raise failed: %d\n", errno);
|
message("nxeg_raise: nx_raise failed: %d\n", errno);
|
||||||
g_exitcode = NXEXIT_NXRAISE;
|
g_exitcode = NXEXIT_NXRAISE;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -406,7 +406,7 @@ static inline int nxeg_raise(NXEGWINDOW hwnd)
|
|||||||
int ret = nxtk_raise(hwnd);
|
int ret = nxtk_raise(hwnd);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
message("user_start: nxtk_raise failed: %d\n", errno);
|
message("nxeg_raise: nxtk_raise failed: %d\n", errno);
|
||||||
g_exitcode = NXEXIT_NXRAISE;
|
g_exitcode = NXEXIT_NXRAISE;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -490,7 +490,7 @@ static inline int nxeg_suinitialize(void)
|
|||||||
g_hnx = nx_open(dev);
|
g_hnx = nx_open(dev);
|
||||||
if (!g_hnx)
|
if (!g_hnx)
|
||||||
{
|
{
|
||||||
message("user_start: nx_open failed: %d\n", errno);
|
message("nxeg_suinitialize: nx_open failed: %d\n", errno);
|
||||||
g_exitcode = NXEXIT_NXOPEN;
|
g_exitcode = NXEXIT_NXOPEN;
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
@ -618,10 +618,14 @@ static int nxeg_initialize(void)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_EXAMPLES_NX_BUILTIN
|
#ifdef CONFIG_EXAMPLES_NX_BUILTIN
|
||||||
int nx_main(int argc, char **argv)
|
# define MAIN_NAME nx_main
|
||||||
|
# define MAIN_NAME_STRING "nx_main"
|
||||||
#else
|
#else
|
||||||
int user_start(int argc, char *argv[])
|
# define MAIN_NAME user_start
|
||||||
|
# define MAIN_NAME_STRING "user_start"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int MAIN_NAME(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
NXEGWINDOW hwnd1;
|
NXEGWINDOW hwnd1;
|
||||||
NXEGWINDOW hwnd2;
|
NXEGWINDOW hwnd2;
|
||||||
@ -633,10 +637,10 @@ int user_start(int argc, char *argv[])
|
|||||||
/* Initialize */
|
/* Initialize */
|
||||||
|
|
||||||
ret = nxeg_initialize();
|
ret = nxeg_initialize();
|
||||||
message("user_start: NX handle=%p\n", g_hnx);
|
message(MAIN_NAME_STRING ": NX handle=%p\n", g_hnx);
|
||||||
if (!g_hnx || ret < 0)
|
if (!g_hnx || ret < 0)
|
||||||
{
|
{
|
||||||
message("user_start: Failed to get NX handle: %d\n", errno);
|
message(MAIN_NAME_STRING ": Failed to get NX handle: %d\n", errno);
|
||||||
g_exitcode = NXEXIT_NXOPEN;
|
g_exitcode = NXEXIT_NXOPEN;
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
@ -646,29 +650,29 @@ int user_start(int argc, char *argv[])
|
|||||||
g_fonthandle = nxf_getfonthandle(NXFONT_DEFAULT);
|
g_fonthandle = nxf_getfonthandle(NXFONT_DEFAULT);
|
||||||
if (!g_fonthandle)
|
if (!g_fonthandle)
|
||||||
{
|
{
|
||||||
message("user_start: Failed to get font handle: %d\n", errno);
|
message(MAIN_NAME_STRING ": Failed to get font handle: %d\n", errno);
|
||||||
g_exitcode = NXEXIT_FONTOPEN;
|
g_exitcode = NXEXIT_FONTOPEN;
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the background to the configured background color */
|
/* Set the background to the configured background color */
|
||||||
|
|
||||||
message("user_start: Set background color=%d\n", CONFIG_EXAMPLES_NX_BGCOLOR);
|
message(MAIN_NAME_STRING ": Set background color=%d\n", CONFIG_EXAMPLES_NX_BGCOLOR);
|
||||||
color = CONFIG_EXAMPLES_NX_BGCOLOR;
|
color = CONFIG_EXAMPLES_NX_BGCOLOR;
|
||||||
ret = nx_setbgcolor(g_hnx, &color);
|
ret = nx_setbgcolor(g_hnx, &color);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
message("user_start: nx_setbgcolor failed: %d\n", errno);
|
message(MAIN_NAME_STRING ": nx_setbgcolor failed: %d\n", errno);
|
||||||
g_exitcode = NXEXIT_NXSETBGCOLOR;
|
g_exitcode = NXEXIT_NXSETBGCOLOR;
|
||||||
goto errout_with_nx;
|
goto errout_with_nx;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create window #1 */
|
/* Create window #1 */
|
||||||
|
|
||||||
message("user_start: Create window #1\n");
|
message(MAIN_NAME_STRING ": Create window #1\n");
|
||||||
nxeg_initstate(&g_wstate[0], 1, CONFIG_EXAMPLES_NX_COLOR1);
|
nxeg_initstate(&g_wstate[0], 1, CONFIG_EXAMPLES_NX_COLOR1);
|
||||||
hwnd1 = nxeg_openwindow(&g_nxcb, &g_wstate[0]);
|
hwnd1 = nxeg_openwindow(&g_nxcb, &g_wstate[0]);
|
||||||
message("user_start: hwnd1=%p\n", hwnd1);
|
message(MAIN_NAME_STRING ": hwnd1=%p\n", hwnd1);
|
||||||
if (!hwnd1)
|
if (!hwnd1)
|
||||||
{
|
{
|
||||||
goto errout_with_nx;
|
goto errout_with_nx;
|
||||||
@ -680,14 +684,14 @@ int user_start(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
(void)sem_wait(&g_semevent);
|
(void)sem_wait(&g_semevent);
|
||||||
}
|
}
|
||||||
message("user_start: Screen resolution (%d,%d)\n", g_xres, g_yres);
|
message(MAIN_NAME_STRING ": Screen resolution (%d,%d)\n", g_xres, g_yres);
|
||||||
|
|
||||||
/* Set the size of the window 1 */
|
/* Set the size of the window 1 */
|
||||||
|
|
||||||
size.w = g_xres / 2;
|
size.w = g_xres / 2;
|
||||||
size.h = g_yres / 2;
|
size.h = g_yres / 2;
|
||||||
|
|
||||||
message("user_start: Set window #1 size to (%d,%d)\n", size.w, size.h);
|
message(MAIN_NAME_STRING ": Set window #1 size to (%d,%d)\n", size.w, size.h);
|
||||||
ret = nxeg_setsize(hwnd1, &size);
|
ret = nxeg_setsize(hwnd1, &size);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
@ -699,7 +703,7 @@ int user_start(int argc, char *argv[])
|
|||||||
* actually do them!
|
* actually do them!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
message("user_start: Sleeping\n\n");
|
message(MAIN_NAME_STRING ": Sleeping\n\n");
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
/* Set the position of window #1 */
|
/* Set the position of window #1 */
|
||||||
@ -707,7 +711,7 @@ int user_start(int argc, char *argv[])
|
|||||||
pt.x = g_xres / 8;
|
pt.x = g_xres / 8;
|
||||||
pt.y = g_yres / 8;
|
pt.y = g_yres / 8;
|
||||||
|
|
||||||
message("user_start: Set window #1 postion to (%d,%d)\n", pt.x, pt.y);
|
message(MAIN_NAME_STRING ": Set window #1 postion to (%d,%d)\n", pt.x, pt.y);
|
||||||
ret = nxeg_setposition(hwnd1, &pt);
|
ret = nxeg_setposition(hwnd1, &pt);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
@ -716,13 +720,13 @@ int user_start(int argc, char *argv[])
|
|||||||
|
|
||||||
/* Sleep a bit */
|
/* Sleep a bit */
|
||||||
|
|
||||||
message("user_start: Sleeping\n\n");
|
message(MAIN_NAME_STRING ": Sleeping\n\n");
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
/* Open the toolbar */
|
/* Open the toolbar */
|
||||||
|
|
||||||
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
|
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
|
||||||
message("user_start: Add toolbar to window #1\n");
|
message(MAIN_NAME_STRING ": Add toolbar to window #1\n");
|
||||||
ret = nxeq_opentoolbar(hwnd1, CONFIG_EXAMPLES_NX_TOOLBAR_HEIGHT, &g_tbcb, &g_wstate[0]);
|
ret = nxeq_opentoolbar(hwnd1, CONFIG_EXAMPLES_NX_TOOLBAR_HEIGHT, &g_tbcb, &g_wstate[0]);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
@ -731,16 +735,16 @@ int user_start(int argc, char *argv[])
|
|||||||
|
|
||||||
/* Sleep a bit */
|
/* Sleep a bit */
|
||||||
|
|
||||||
message("user_start: Sleeping\n\n");
|
message(MAIN_NAME_STRING ": Sleeping\n\n");
|
||||||
sleep(1);
|
sleep(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Create window #2 */
|
/* Create window #2 */
|
||||||
|
|
||||||
message("user_start: Create window #2\n");
|
message(MAIN_NAME_STRING ": Create window #2\n");
|
||||||
nxeg_initstate(&g_wstate[1], 2, CONFIG_EXAMPLES_NX_COLOR2);
|
nxeg_initstate(&g_wstate[1], 2, CONFIG_EXAMPLES_NX_COLOR2);
|
||||||
hwnd2 = nxeg_openwindow(&g_nxcb, &g_wstate[1]);
|
hwnd2 = nxeg_openwindow(&g_nxcb, &g_wstate[1]);
|
||||||
message("user_start: hwnd2=%p\n", hwnd2);
|
message(MAIN_NAME_STRING ": hwnd2=%p\n", hwnd2);
|
||||||
if (!hwnd2)
|
if (!hwnd2)
|
||||||
{
|
{
|
||||||
goto errout_with_hwnd1;
|
goto errout_with_hwnd1;
|
||||||
@ -748,12 +752,12 @@ int user_start(int argc, char *argv[])
|
|||||||
|
|
||||||
/* Sleep a bit */
|
/* Sleep a bit */
|
||||||
|
|
||||||
message("user_start: Sleeping\n\n");
|
message(MAIN_NAME_STRING ": Sleeping\n\n");
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
/* Set the size of the window 2 == size of window 1*/
|
/* Set the size of the window 2 == size of window 1*/
|
||||||
|
|
||||||
message("user_start: Set hwnd2 size to (%d,%d)\n", size.w, size.h);
|
message(MAIN_NAME_STRING ": Set hwnd2 size to (%d,%d)\n", size.w, size.h);
|
||||||
ret = nxeg_setsize(hwnd2, &size);
|
ret = nxeg_setsize(hwnd2, &size);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
@ -762,7 +766,7 @@ int user_start(int argc, char *argv[])
|
|||||||
|
|
||||||
/* Sleep a bit */
|
/* Sleep a bit */
|
||||||
|
|
||||||
message("user_start: Sleeping\n\n");
|
message(MAIN_NAME_STRING ": Sleeping\n\n");
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
/* Set the position of window #2 */
|
/* Set the position of window #2 */
|
||||||
@ -770,7 +774,7 @@ int user_start(int argc, char *argv[])
|
|||||||
pt.x = g_xres - size.w - pt.x;
|
pt.x = g_xres - size.w - pt.x;
|
||||||
pt.y = g_yres - size.h - pt.y;
|
pt.y = g_yres - size.h - pt.y;
|
||||||
|
|
||||||
message("user_start: Set hwnd2 postion to (%d,%d)\n", pt.x, pt.y);
|
message(MAIN_NAME_STRING ": Set hwnd2 postion to (%d,%d)\n", pt.x, pt.y);
|
||||||
ret = nxeg_setposition(hwnd2, &pt);
|
ret = nxeg_setposition(hwnd2, &pt);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
@ -779,11 +783,11 @@ int user_start(int argc, char *argv[])
|
|||||||
|
|
||||||
/* Sleep a bit */
|
/* Sleep a bit */
|
||||||
|
|
||||||
message("user_start: Sleeping\n\n");
|
message(MAIN_NAME_STRING ": Sleeping\n\n");
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
|
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
|
||||||
message("user_start: Add toolbar to window #2\n");
|
message(MAIN_NAME_STRING ": Add toolbar to window #2\n");
|
||||||
ret = nxeq_opentoolbar(hwnd2, CONFIG_EXAMPLES_NX_TOOLBAR_HEIGHT, &g_tbcb, &g_wstate[1]);
|
ret = nxeq_opentoolbar(hwnd2, CONFIG_EXAMPLES_NX_TOOLBAR_HEIGHT, &g_tbcb, &g_wstate[1]);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
@ -792,30 +796,30 @@ int user_start(int argc, char *argv[])
|
|||||||
|
|
||||||
/* Sleep a bit */
|
/* Sleep a bit */
|
||||||
|
|
||||||
message("user_start: Sleeping\n\n");
|
message(MAIN_NAME_STRING ": Sleeping\n\n");
|
||||||
sleep(1);
|
sleep(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Give keyboard input to the top window -- should be window #2 */
|
/* Give keyboard input to the top window -- should be window #2 */
|
||||||
|
|
||||||
#ifdef CONFIG_NX_KBD
|
#ifdef CONFIG_NX_KBD
|
||||||
message("user_start: Send keyboard input: %s\n", g_kbdmsg1);
|
message(MAIN_NAME_STRING ": Send keyboard input: %s\n", g_kbdmsg1);
|
||||||
ret = nx_kbdin(g_hnx, strlen((FAR const char *)g_kbdmsg1), g_kbdmsg1);
|
ret = nx_kbdin(g_hnx, strlen((FAR const char *)g_kbdmsg1), g_kbdmsg1);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
message("user_start: nx_kbdin failed: %d\n", errno);
|
message(MAIN_NAME_STRING ": nx_kbdin failed: %d\n", errno);
|
||||||
goto errout_with_hwnd2;
|
goto errout_with_hwnd2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sleep a bit */
|
/* Sleep a bit */
|
||||||
|
|
||||||
message("user_start: Sleeping\n\n");
|
message(MAIN_NAME_STRING ": Sleeping\n\n");
|
||||||
sleep(1);
|
sleep(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Lower window 2 */
|
/* Lower window 2 */
|
||||||
|
|
||||||
message("user_start: Lower window #2\n");
|
message(MAIN_NAME_STRING ": Lower window #2\n");
|
||||||
ret = nxeg_lower(hwnd2);
|
ret = nxeg_lower(hwnd2);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
@ -824,7 +828,7 @@ int user_start(int argc, char *argv[])
|
|||||||
|
|
||||||
/* Sleep a bit */
|
/* Sleep a bit */
|
||||||
|
|
||||||
message("user_start: Sleeping\n\n");
|
message(MAIN_NAME_STRING ": Sleeping\n\n");
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
/* Put mouse left-button clicks all over the screen and see who responds */
|
/* Put mouse left-button clicks all over the screen and see who responds */
|
||||||
@ -834,30 +838,30 @@ int user_start(int argc, char *argv[])
|
|||||||
|
|
||||||
/* Sleep a bit */
|
/* Sleep a bit */
|
||||||
|
|
||||||
message("user_start: Sleeping\n\n");
|
message(MAIN_NAME_STRING ": Sleeping\n\n");
|
||||||
sleep(1);
|
sleep(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Give keyboard input to the top window -- should be window #1 */
|
/* Give keyboard input to the top window -- should be window #1 */
|
||||||
|
|
||||||
#ifdef CONFIG_NX_KBD
|
#ifdef CONFIG_NX_KBD
|
||||||
message("user_start: Send keyboard input: %s\n", g_kbdmsg2);
|
message(MAIN_NAME_STRING ": Send keyboard input: %s\n", g_kbdmsg2);
|
||||||
ret = nx_kbdin(g_hnx, strlen((FAR const char *)g_kbdmsg2), g_kbdmsg2);
|
ret = nx_kbdin(g_hnx, strlen((FAR const char *)g_kbdmsg2), g_kbdmsg2);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
message("user_start: nx_kbdin failed: %d\n", errno);
|
message(MAIN_NAME_STRING ": nx_kbdin failed: %d\n", errno);
|
||||||
goto errout_with_hwnd2;
|
goto errout_with_hwnd2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sleep a bit */
|
/* Sleep a bit */
|
||||||
|
|
||||||
message("user_start: Sleeping\n\n");
|
message(MAIN_NAME_STRING ": Sleeping\n\n");
|
||||||
sleep(1);
|
sleep(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Raise window 2 */
|
/* Raise window 2 */
|
||||||
|
|
||||||
message("user_start: Raise window #2\n");
|
message(MAIN_NAME_STRING ": Raise window #2\n");
|
||||||
ret = nxeg_raise(hwnd2);
|
ret = nxeg_raise(hwnd2);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
@ -872,31 +876,31 @@ int user_start(int argc, char *argv[])
|
|||||||
|
|
||||||
/* Sleep a bit */
|
/* Sleep a bit */
|
||||||
|
|
||||||
message("user_start: Sleeping\n\n");
|
message(MAIN_NAME_STRING ": Sleeping\n\n");
|
||||||
sleep(2);
|
sleep(2);
|
||||||
|
|
||||||
/* Close the window 2 */
|
/* Close the window 2 */
|
||||||
|
|
||||||
errout_with_hwnd2:
|
errout_with_hwnd2:
|
||||||
message("user_start: Close window #2\n");
|
message(MAIN_NAME_STRING ": Close window #2\n");
|
||||||
(void)nxeg_closewindow(hwnd2, &g_wstate[1]);
|
(void)nxeg_closewindow(hwnd2, &g_wstate[1]);
|
||||||
|
|
||||||
/* Close the window1 */
|
/* Close the window1 */
|
||||||
|
|
||||||
errout_with_hwnd1:
|
errout_with_hwnd1:
|
||||||
message("user_start: Close window #1\n");
|
message(MAIN_NAME_STRING ": Close window #1\n");
|
||||||
(void)nxeg_closewindow(hwnd1, &g_wstate[0]);
|
(void)nxeg_closewindow(hwnd1, &g_wstate[0]);
|
||||||
|
|
||||||
errout_with_nx:
|
errout_with_nx:
|
||||||
#ifdef CONFIG_NX_MULTIUSER
|
#ifdef CONFIG_NX_MULTIUSER
|
||||||
/* Disconnect from the server */
|
/* Disconnect from the server */
|
||||||
|
|
||||||
message("user_start: Disconnect from the server\n");
|
message(MAIN_NAME_STRING ": Disconnect from the server\n");
|
||||||
nx_disconnect(g_hnx);
|
nx_disconnect(g_hnx);
|
||||||
#else
|
#else
|
||||||
/* Close the server */
|
/* Close the server */
|
||||||
|
|
||||||
message("user_start: Close NX\n");
|
message(MAIN_NAME_STRING ": Close NX\n");
|
||||||
nx_close(g_hnx);
|
nx_close(g_hnx);
|
||||||
#endif
|
#endif
|
||||||
errout:
|
errout:
|
||||||
|
@ -248,7 +248,7 @@ static void nxhello_center(FAR struct nxgl_point_s *pos,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
pos->x = (g_nxhello.xres - width) / 2;
|
pos->x = (g_nxhello.xres - width) / 2;
|
||||||
pos->y = (g_nxhello.yres - fbm->metric.height) / 2;
|
pos->y = (g_nxhello.yres - fontset->mxheight) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -211,7 +211,7 @@ static inline int nxhello_initialize(void)
|
|||||||
# define MAIN_NAME_STRING "nxhello_main"
|
# define MAIN_NAME_STRING "nxhello_main"
|
||||||
#else
|
#else
|
||||||
# define MAIN_NAME user_start
|
# define MAIN_NAME user_start
|
||||||
# define MAIN_NAME_STRING "user_start"
|
# define MAIN_NAME_STRING MAIN_NAME_STRING ""
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int MAIN_NAME(int argc, char *argv[])
|
int MAIN_NAME(int argc, char *argv[])
|
||||||
@ -235,7 +235,7 @@ int MAIN_NAME(int argc, char *argv[])
|
|||||||
g_nxhello.hfont = nxf_getfonthandle(NXFONT_DEFAULT);
|
g_nxhello.hfont = nxf_getfonthandle(NXFONT_DEFAULT);
|
||||||
if (!g_nxhello.hfont)
|
if (!g_nxhello.hfont)
|
||||||
{
|
{
|
||||||
message("user_start: Failed to get font handle: %d\n", errno);
|
message(MAIN_NAME_STRING ": Failed to get font handle: %d\n", errno);
|
||||||
g_nxhello.code = NXEXIT_FONTOPEN;
|
g_nxhello.code = NXEXIT_FONTOPEN;
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
@ -233,7 +233,7 @@ static inline int nxtext_suinitialize(void)
|
|||||||
g_hnx = nx_open(dev);
|
g_hnx = nx_open(dev);
|
||||||
if (!g_hnx)
|
if (!g_hnx)
|
||||||
{
|
{
|
||||||
message("user_start: nx_open failed: %d\n", errno);
|
message("nxtext_initialize: nx_open failed: %d\n", errno);
|
||||||
g_exitcode = NXEXIT_NXOPEN;
|
g_exitcode = NXEXIT_NXOPEN;
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
@ -348,10 +348,14 @@ static int nxtext_initialize(void)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_EXAMPLES_NXTEXT_BUILTIN
|
#ifdef CONFIG_EXAMPLES_NXTEXT_BUILTIN
|
||||||
int nxtext_main(int argc, char **argv)
|
# define MAIN_NAME nxtext_main
|
||||||
|
# define MAIN_NAME_STRING "nxtext_main"
|
||||||
#else
|
#else
|
||||||
int user_start(int argc, char *argv[])
|
# define MAIN_NAME user_start
|
||||||
|
# define MAIN_NAME_STRING "user_start"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int MAIN_NAME(int argc, char **argv)
|
||||||
{
|
{
|
||||||
FAR struct nxtext_state_s *bgstate;
|
FAR struct nxtext_state_s *bgstate;
|
||||||
NXWINDOW hwnd = NULL;
|
NXWINDOW hwnd = NULL;
|
||||||
@ -363,10 +367,10 @@ int user_start(int argc, char *argv[])
|
|||||||
/* Initialize NX */
|
/* Initialize NX */
|
||||||
|
|
||||||
ret = nxtext_initialize();
|
ret = nxtext_initialize();
|
||||||
message("user_start: NX handle=%p\n", g_hnx);
|
message(MAIN_NAME_STRING ": NX handle=%p\n", g_hnx);
|
||||||
if (!g_hnx || ret < 0)
|
if (!g_hnx || ret < 0)
|
||||||
{
|
{
|
||||||
message("user_start: Failed to get NX handle: %d\n", errno);
|
message(MAIN_NAME_STRING ": Failed to get NX handle: %d\n", errno);
|
||||||
g_exitcode = NXEXIT_NXOPEN;
|
g_exitcode = NXEXIT_NXOPEN;
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
@ -376,19 +380,19 @@ int user_start(int argc, char *argv[])
|
|||||||
g_fonthandle = nxf_getfonthandle(NXFONT_DEFAULT);
|
g_fonthandle = nxf_getfonthandle(NXFONT_DEFAULT);
|
||||||
if (!g_fonthandle)
|
if (!g_fonthandle)
|
||||||
{
|
{
|
||||||
message("user_start: Failed to get font handle: %d\n", errno);
|
message(MAIN_NAME_STRING ": Failed to get font handle: %d\n", errno);
|
||||||
g_exitcode = NXEXIT_FONTOPEN;
|
g_exitcode = NXEXIT_FONTOPEN;
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the background to the configured background color */
|
/* Set the background to the configured background color */
|
||||||
|
|
||||||
message("user_start: Set background color=%d\n", CONFIG_EXAMPLES_NXTEXT_BGCOLOR);
|
message(MAIN_NAME_STRING ": Set background color=%d\n", CONFIG_EXAMPLES_NXTEXT_BGCOLOR);
|
||||||
color = CONFIG_EXAMPLES_NXTEXT_BGCOLOR;
|
color = CONFIG_EXAMPLES_NXTEXT_BGCOLOR;
|
||||||
ret = nx_setbgcolor(g_hnx, &color);
|
ret = nx_setbgcolor(g_hnx, &color);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
message("user_start: nx_setbgcolor failed: %d\n", errno);
|
message(MAIN_NAME_STRING ": nx_setbgcolor failed: %d\n", errno);
|
||||||
g_exitcode = NXEXIT_NXSETBGCOLOR;
|
g_exitcode = NXEXIT_NXSETBGCOLOR;
|
||||||
goto errout_with_nx;
|
goto errout_with_nx;
|
||||||
}
|
}
|
||||||
@ -399,7 +403,7 @@ int user_start(int argc, char *argv[])
|
|||||||
ret = nx_requestbkgd(g_hnx, &g_bgcb, bgstate);
|
ret = nx_requestbkgd(g_hnx, &g_bgcb, bgstate);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
message("user_start: nx_setbgcolor failed: %d\n", errno);
|
message(MAIN_NAME_STRING ": nx_setbgcolor failed: %d\n", errno);
|
||||||
g_exitcode = NXEXIT_NXREQUESTBKGD;
|
g_exitcode = NXEXIT_NXREQUESTBKGD;
|
||||||
goto errout_with_nx;
|
goto errout_with_nx;
|
||||||
}
|
}
|
||||||
@ -412,7 +416,7 @@ int user_start(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
(void)sem_wait(&g_semevent);
|
(void)sem_wait(&g_semevent);
|
||||||
}
|
}
|
||||||
message("user_start: Screen resolution (%d,%d)\n", g_xres, g_yres);
|
message(MAIN_NAME_STRING ": Screen resolution (%d,%d)\n", g_xres, g_yres);
|
||||||
|
|
||||||
/* Now loop, adding text to the background and periodically presenting
|
/* Now loop, adding text to the background and periodically presenting
|
||||||
* a pop-up window.
|
* a pop-up window.
|
||||||
@ -440,11 +444,11 @@ int user_start(int argc, char *argv[])
|
|||||||
/* Give keyboard input to the top window (which should be the pop-up) */
|
/* Give keyboard input to the top window (which should be the pop-up) */
|
||||||
|
|
||||||
#ifdef CONFIG_NX_KBD
|
#ifdef CONFIG_NX_KBD
|
||||||
message("user_start: Send keyboard input: %s\n", g_pumsg);
|
message(MAIN_NAME_STRING ": Send keyboard input: %s\n", g_pumsg);
|
||||||
ret = nx_kbdin(g_hnx, strlen((FAR const char *)g_pumsg), g_pumsg);
|
ret = nx_kbdin(g_hnx, strlen((FAR const char *)g_pumsg), g_pumsg);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
message("user_start: nx_kbdin failed: %d\n", errno);
|
message(MAIN_NAME_STRING ": nx_kbdin failed: %d\n", errno);
|
||||||
goto errout_with_hwnd;
|
goto errout_with_hwnd;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -453,7 +457,7 @@ int user_start(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
/* Destroy the pop-up window and restart the sequence */
|
/* Destroy the pop-up window and restart the sequence */
|
||||||
|
|
||||||
message("user_start: Close pop-up\n");
|
message(MAIN_NAME_STRING ": Close pop-up\n");
|
||||||
(void)nxpu_close(hwnd);
|
(void)nxpu_close(hwnd);
|
||||||
popcnt = 0;
|
popcnt = 0;
|
||||||
}
|
}
|
||||||
@ -475,7 +479,7 @@ int user_start(int argc, char *argv[])
|
|||||||
errout_with_hwnd:
|
errout_with_hwnd:
|
||||||
if (popcnt >= 3)
|
if (popcnt >= 3)
|
||||||
{
|
{
|
||||||
message("user_start: Close pop-up\n");
|
message(MAIN_NAME_STRING ": Close pop-up\n");
|
||||||
(void)nxpu_close(hwnd);
|
(void)nxpu_close(hwnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,12 +490,12 @@ errout_with_nx:
|
|||||||
#ifdef CONFIG_NX_MULTIUSER
|
#ifdef CONFIG_NX_MULTIUSER
|
||||||
/* Disconnect from the server */
|
/* Disconnect from the server */
|
||||||
|
|
||||||
message("user_start: Disconnect from the server\n");
|
message(MAIN_NAME_STRING ": Disconnect from the server\n");
|
||||||
nx_disconnect(g_hnx);
|
nx_disconnect(g_hnx);
|
||||||
#else
|
#else
|
||||||
/* Close the server */
|
/* Close the server */
|
||||||
|
|
||||||
message("user_start: Close NX\n");
|
message(MAIN_NAME_STRING ": Close NX\n");
|
||||||
nx_close(g_hnx);
|
nx_close(g_hnx);
|
||||||
#endif
|
#endif
|
||||||
errout:
|
errout:
|
||||||
|
@ -56,12 +56,22 @@ endif
|
|||||||
|
|
||||||
ROOTDEPPATH = --dep-path .
|
ROOTDEPPATH = --dep-path .
|
||||||
|
|
||||||
|
# NXTEXT built-in application info
|
||||||
|
|
||||||
|
APPNAME1 = msconn
|
||||||
|
PRIORITY1 = SCHED_PRIORITY_DEFAULT
|
||||||
|
STACKSIZE1 = 2048
|
||||||
|
|
||||||
|
APPNAME2 = msdis
|
||||||
|
PRIORITY2 = SCHED_PRIORITY_DEFAULT
|
||||||
|
STACKSIZE2 = 2048
|
||||||
|
|
||||||
# Common build
|
# Common build
|
||||||
|
|
||||||
VPATH =
|
VPATH =
|
||||||
|
|
||||||
all: .built
|
all: .built
|
||||||
.PHONY: clean depend distclean
|
.PHONY: context clean depend distclean
|
||||||
|
|
||||||
$(AOBJS): %$(OBJEXT): %.S
|
$(AOBJS): %$(OBJEXT): %.S
|
||||||
$(call ASSEMBLE, $<, $@)
|
$(call ASSEMBLE, $<, $@)
|
||||||
@ -75,7 +85,14 @@ $(COBJS): %$(OBJEXT): %.c
|
|||||||
done ; )
|
done ; )
|
||||||
@touch .built
|
@touch .built
|
||||||
|
|
||||||
context:
|
.context:
|
||||||
|
ifeq ($(CONFIG_EXAMPLES_USBSTRG_BUILTIN),y)
|
||||||
|
$(call REGISTER,$(APPNAME1),$(PRIORITY1),$(STACKSIZE1),$(APPNAME1)_main)
|
||||||
|
$(call REGISTER,$(APPNAME2),$(PRIORITY2),$(STACKSIZE2),$(APPNAME2)_main)
|
||||||
|
@touch $@
|
||||||
|
endif
|
||||||
|
|
||||||
|
context: .context
|
||||||
|
|
||||||
.depend: Makefile $(SRCS)
|
.depend: Makefile $(SRCS)
|
||||||
@$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
|
@$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||||
|
@ -93,6 +93,17 @@
|
|||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* This is the handle that references to this particular USB storage driver
|
||||||
|
* instance. It is only needed if the USB mass storage device example is
|
||||||
|
* built using CONFIG_EXAMPLES_USBSTRG_BUILTIN. In this case, the value
|
||||||
|
* of the driver handle must be remembered between the 'msconn' and 'msdis'
|
||||||
|
* commands.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_EXAMPLES_USBSTRG_BUILTIN
|
||||||
|
static FAR void *g_mshandle;
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -284,72 +295,104 @@ static int usbstrg_enumerate(struct usbtrace_s *trace, void *arg)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* user_start
|
* user_start/msconn_main
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This is the main program that configures the USB mass storage device
|
||||||
|
* and exports the LUN(s). If CONFIG_EXAMPLES_USBSTRG_BUILTIN is defined
|
||||||
|
* in the NuttX configuration, then this program can be executed by
|
||||||
|
* entering the "msconn" command at the NSH console.
|
||||||
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int user_start(int argc, char *argv[])
|
#ifdef CONFIG_EXAMPLES_USBSTRG_BUILTIN
|
||||||
|
# define MAIN_NAME msconn_main
|
||||||
|
# define MAIN_NAME_STRING "msconn"
|
||||||
|
#else
|
||||||
|
# define MAIN_NAME user_start
|
||||||
|
# define MAIN_NAME_STRING "user_start"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int MAIN_NAME(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
void *handle;
|
FAR void *handle;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
/* If this program is implemented as the NSH 'msconn' command, then we need to
|
||||||
|
* do a little error checking to assure that we are not being called re-entrantly.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_EXAMPLES_USBSTRG_BUILTIN
|
||||||
|
|
||||||
|
/* Check if there is a non-NULL USB mass storage device handle (meaning that the
|
||||||
|
* USB mass storage device is already configured).
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (g_mshandle)
|
||||||
|
{
|
||||||
|
message(MAIN_NAME_STRING ": ERROR: Already connected\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Initialize USB trace output IDs */
|
/* Initialize USB trace output IDs */
|
||||||
|
|
||||||
usbtrace_enable(TRACE_BITSET);
|
usbtrace_enable(TRACE_BITSET);
|
||||||
|
|
||||||
/* Register block drivers (architecture-specific) */
|
/* Register block drivers (architecture-specific) */
|
||||||
|
|
||||||
message("user_start: Creating block drivers\n");
|
message(MAIN_NAME_STRING ": Creating block drivers\n");
|
||||||
ret = usbstrg_archinitialize();
|
ret = usbstrg_archinitialize();
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
message("user_start: usbstrg_archinitialize failed: %d\n", -ret);
|
message(MAIN_NAME_STRING ": usbstrg_archinitialize failed: %d\n", -ret);
|
||||||
return 1;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Then exports the LUN(s) */
|
/* Then exports the LUN(s) */
|
||||||
|
|
||||||
message("user_start: Configuring with NLUNS=%d\n", CONFIG_EXAMPLES_USBSTRG_NLUNS);
|
message(MAIN_NAME_STRING ": Configuring with NLUNS=%d\n", CONFIG_EXAMPLES_USBSTRG_NLUNS);
|
||||||
ret = usbstrg_configure(CONFIG_EXAMPLES_USBSTRG_NLUNS, &handle);
|
ret = usbstrg_configure(CONFIG_EXAMPLES_USBSTRG_NLUNS, &handle);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
message("user_start: usbstrg_configure failed: %d\n", -ret);
|
message(MAIN_NAME_STRING ": usbstrg_configure failed: %d\n", -ret);
|
||||||
usbstrg_uninitialize(handle);
|
usbstrg_uninitialize(handle);
|
||||||
return 2;
|
return 3;
|
||||||
}
|
}
|
||||||
message("user_start: handle=%p\n", handle);
|
message(MAIN_NAME_STRING ": handle=%p\n", handle);
|
||||||
|
|
||||||
message("user_start: Bind LUN=0 to %s\n", CONFIG_EXAMPLES_USBSTRG_DEVPATH1);
|
message(MAIN_NAME_STRING ": Bind LUN=0 to %s\n", CONFIG_EXAMPLES_USBSTRG_DEVPATH1);
|
||||||
ret = usbstrg_bindlun(handle, CONFIG_EXAMPLES_USBSTRG_DEVPATH1, 0, 0, 0, false);
|
ret = usbstrg_bindlun(handle, CONFIG_EXAMPLES_USBSTRG_DEVPATH1, 0, 0, 0, false);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
message("user_start: usbstrg_bindlun failed for LUN 1 using %s: %d\n",
|
message(MAIN_NAME_STRING ": usbstrg_bindlun failed for LUN 1 using %s: %d\n",
|
||||||
CONFIG_EXAMPLES_USBSTRG_DEVPATH1, -ret);
|
CONFIG_EXAMPLES_USBSTRG_DEVPATH1, -ret);
|
||||||
usbstrg_uninitialize(handle);
|
usbstrg_uninitialize(handle);
|
||||||
return 2;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_EXAMPLES_USBSTRG_NLUNS > 1
|
#if CONFIG_EXAMPLES_USBSTRG_NLUNS > 1
|
||||||
|
|
||||||
message("user_start: Bind LUN=1 to %s\n", CONFIG_EXAMPLES_USBSTRG_DEVPATH2);
|
message(MAIN_NAME_STRING ": Bind LUN=1 to %s\n", CONFIG_EXAMPLES_USBSTRG_DEVPATH2);
|
||||||
ret = usbstrg_bindlun(handle, CONFIG_EXAMPLES_USBSTRG_DEVPATH2, 1, 0, 0, false);
|
ret = usbstrg_bindlun(handle, CONFIG_EXAMPLES_USBSTRG_DEVPATH2, 1, 0, 0, false);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
message("user_start: usbstrg_bindlun failed for LUN 2 using %s: %d\n",
|
message(MAIN_NAME_STRING ": usbstrg_bindlun failed for LUN 2 using %s: %d\n",
|
||||||
CONFIG_EXAMPLES_USBSTRG_DEVPATH2, -ret);
|
CONFIG_EXAMPLES_USBSTRG_DEVPATH2, -ret);
|
||||||
usbstrg_uninitialize(handle);
|
usbstrg_uninitialize(handle);
|
||||||
return 3;
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_EXAMPLES_USBSTRG_NLUNS > 2
|
#if CONFIG_EXAMPLES_USBSTRG_NLUNS > 2
|
||||||
|
|
||||||
message("user_start: Bind LUN=2 to %s\n", CONFIG_EXAMPLES_USBSTRG_DEVPATH3);
|
message(MAIN_NAME_STRING ": Bind LUN=2 to %s\n", CONFIG_EXAMPLES_USBSTRG_DEVPATH3);
|
||||||
ret = usbstrg_bindlun(handle, CONFIG_EXAMPLES_USBSTRG_DEVPATH3, 2, 0, 0, false);
|
ret = usbstrg_bindlun(handle, CONFIG_EXAMPLES_USBSTRG_DEVPATH3, 2, 0, 0, false);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
message("user_start: usbstrg_bindlun failed for LUN 3 using %s: %d\n",
|
message(MAIN_NAME_STRING ": usbstrg_bindlun failed for LUN 3 using %s: %d\n",
|
||||||
CONFIG_EXAMPLES_USBSTRG_DEVPATH3, -ret);
|
CONFIG_EXAMPLES_USBSTRG_DEVPATH3, -ret);
|
||||||
usbstrg_uninitialize(handle);
|
usbstrg_uninitialize(handle);
|
||||||
return 4;
|
return 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -358,34 +401,83 @@ int user_start(int argc, char *argv[])
|
|||||||
ret = usbstrg_exportluns(handle);
|
ret = usbstrg_exportluns(handle);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
message("user_start: usbstrg_exportluns failed: %d\n", -ret);
|
message(MAIN_NAME_STRING ": usbstrg_exportluns failed: %d\n", -ret);
|
||||||
usbstrg_uninitialize(handle);
|
usbstrg_uninitialize(handle);
|
||||||
return 5;
|
return 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now just hang around and monitor the USB storage activity */
|
/* It this program was configued as an NSH command, then just exit now.
|
||||||
|
* Also, if signals are not enabled (and, hence, sleep() is not supported.
|
||||||
|
* then we have not real option but to exit now.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !defined(CONFIG_EXAMPLES_USBSTRG_BUILTIN) && !defined(CONFIG_DISABLE_SIGNALS)
|
||||||
|
|
||||||
|
/* Otherwise, this thread will hang around and monitor the USB storage activity */
|
||||||
|
|
||||||
#ifndef CONFIG_DISABLE_SIGNALS
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
msgflush();
|
msgflush();
|
||||||
sleep(5);
|
sleep(5);
|
||||||
|
|
||||||
#ifdef CONFIG_USBDEV_TRACE
|
# ifdef CONFIG_USBDEV_TRACE
|
||||||
message("\nuser_start: USB TRACE DATA:\n");
|
message("\nuser_start: USB TRACE DATA:\n");
|
||||||
ret = usbtrace_enumerate(usbstrg_enumerate, NULL);
|
ret = usbtrace_enumerate(usbstrg_enumerate, NULL);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
message("user_start: usbtrace_enumerate failed: %d\n", -ret);
|
message(MAIN_NAME_STRING ": usbtrace_enumerate failed: %d\n", -ret);
|
||||||
usbstrg_uninitialize(handle);
|
usbstrg_uninitialize(handle);
|
||||||
return 6;
|
return 8;
|
||||||
}
|
}
|
||||||
#else
|
# else
|
||||||
message("user_start: Still alive\n");
|
message(MAIN_NAME_STRING ": Still alive\n");
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
#else
|
#elif defined(CONFIG_EXAMPLES_USBSTRG_BUILTIN)
|
||||||
message("user_start: Exiting\n");
|
|
||||||
#endif
|
/* Return the USB mass storage device handle so it can be used by the 'misconn'
|
||||||
|
* command.
|
||||||
|
*/
|
||||||
|
|
||||||
|
message(MAIN_NAME_STRING ": Connected\n");
|
||||||
|
g_mshandle = handle;
|
||||||
|
|
||||||
|
#else /* defined(CONFIG_DISABLE_SIGNALS) */
|
||||||
|
|
||||||
|
/* Just exit */
|
||||||
|
|
||||||
|
message(MAIN_NAME_STRING ": Exiting\n");
|
||||||
|
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* msdis_main
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This is a program entry point that will disconnet the USB mass storage
|
||||||
|
* device. This program is only available if CONFIG_EXAMPLES_USBSTRG_BUILTIN
|
||||||
|
* is defined in the NuttX configuration. In that case, this program can
|
||||||
|
* be executed by entering the "msdis" command at the NSH console.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_EXAMPLES_USBSTRG_BUILTIN
|
||||||
|
int msdis_main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
/* First check if the USB mass storage device is already connected */
|
||||||
|
|
||||||
|
if (!g_mshandle)
|
||||||
|
{
|
||||||
|
message("msdis: ERROR: Not connected\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Then disconnect the device and uninitialize the USB mass storage driver */
|
||||||
|
|
||||||
|
usbstrg_uninitialize(g_mshandle);
|
||||||
|
g_mshandle = NULL;
|
||||||
|
message("msdis: Disconnected\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user