diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-10-08 11:34:22 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-10-08 11:34:22 -0600 |
commit | 59ac0e4d0352fad72b80018438e350ba405294b5 (patch) | |
tree | e11ebcb862370c10e4d8633d77673d4377d51a66 /apps | |
parent | 68c842108f9509299434ceb6f1595f0e4ddd4505 (diff) | |
download | nuttx-59ac0e4d0352fad72b80018438e350ba405294b5.tar.gz nuttx-59ac0e4d0352fad72b80018438e350ba405294b5.tar.bz2 nuttx-59ac0e4d0352fad72b80018438e350ba405294b5.zip |
Update everything under apps/ to use the corrected syslog interfaces
Diffstat (limited to 'apps')
-rw-r--r-- | apps/examples/buttons/buttons_main.c | 18 | ||||
-rw-r--r-- | apps/examples/cc3000/cc3000basic.c | 8 | ||||
-rw-r--r-- | apps/nshlib/nsh_usbtrace.c | 35 | ||||
-rw-r--r-- | apps/system/cdcacm/cdcacm.h | 20 | ||||
-rw-r--r-- | apps/system/cdcacm/cdcacm_main.c | 14 | ||||
-rw-r--r-- | apps/system/cle/cle.c | 36 | ||||
-rw-r--r-- | apps/system/composite/composite.h | 20 | ||||
-rw-r--r-- | apps/system/composite/composite_main.c | 192 | ||||
-rw-r--r-- | apps/system/stackmonitor/stackmonitor.c | 22 | ||||
-rw-r--r-- | apps/system/usbmonitor/usbmonitor.c | 31 | ||||
-rw-r--r-- | apps/system/usbmsc/usbmsc.h | 20 | ||||
-rw-r--r-- | apps/system/usbmsc/usbmsc_main.c | 159 | ||||
-rw-r--r-- | apps/system/vi/vi.c | 41 |
13 files changed, 339 insertions, 277 deletions
diff --git a/apps/examples/buttons/buttons_main.c b/apps/examples/buttons/buttons_main.c index 9aab98008..a76c173a2 100644 --- a/apps/examples/buttons/buttons_main.c +++ b/apps/examples/buttons/buttons_main.c @@ -305,7 +305,8 @@ static void show_buttons(uint8_t oldset, uint8_t newset) * interrupt handler. */ - lowsyslog(" %s %s\n", g_buttoninfo[BUTTON_INDEX(i)].name, state); + lowsyslog(LOG_INFO, " %s %s\n", + g_buttoninfo[BUTTON_INDEX(i)].name, state); } } } @@ -315,8 +316,9 @@ static void button_handler(int id, int irq) { uint8_t newset = board_buttons(); - lowsyslog("IRQ:%d Button %d:%s SET:%02x:\n", + lowsyslog(LOG_INFO, "IRQ:%d Button %d:%s SET:%02x:\n", irq, id, g_buttoninfo[BUTTON_INDEX(id)].name, newset); + show_buttons(g_oldset, newset); g_oldset = newset; } @@ -416,7 +418,7 @@ int buttons_main(int argc, char *argv[]) maxbuttons = strtol(argv[1], NULL, 10); } - lowsyslog("maxbuttons: %d\n", maxbuttons); + lowsyslog(LOG_INFO, "maxbuttons: %d\n", maxbuttons); #endif /* Initialize the button GPIOs */ @@ -430,9 +432,9 @@ int buttons_main(int argc, char *argv[]) { xcpt_t oldhandler = board_button_irq(i, g_buttoninfo[BUTTON_INDEX(i)].handler); - /* Use lowsyslog() for compatibility with interrrupt handler output. */ + /* Use lowsyslog() for compatibility with interrupt handler output. */ - lowsyslog("Attached handler at %p to button %d [%s], oldhandler:%p\n", + lowsyslog(LOG_INFO, "Attached handler at %p to button %d [%s], oldhandler:%p\n", g_buttoninfo[BUTTON_INDEX(i)].handler, i, g_buttoninfo[BUTTON_INDEX(i)].name, oldhandler); @@ -445,7 +447,7 @@ int buttons_main(int argc, char *argv[]) if (oldhandler != NULL) { - lowsyslog("WARNING: oldhandler:%p is not NULL! " + lowsyslog(LOG_INFO, "WARNING: oldhandler:%p is not NULL! " "Button events may be lost or aliased!\n", oldhandler); } @@ -475,11 +477,11 @@ int buttons_main(int argc, char *argv[]) flags = irqsave(); - /* Use lowsyslog() for compatibility with interrrupt handler + /* Use lowsyslog() for compatibility with interrupt handler * output. */ - lowsyslog("POLL SET:%02x:\n", newset); + lowsyslog(LOG_INFO, "POLL SET:%02x:\n", newset); show_buttons(g_oldset, newset); g_oldset = newset; irqrestore(flags); diff --git a/apps/examples/cc3000/cc3000basic.c b/apps/examples/cc3000/cc3000basic.c index 19ff1a8c8..db6215762 100644 --- a/apps/examples/cc3000/cc3000basic.c +++ b/apps/examples/cc3000/cc3000basic.c @@ -195,10 +195,10 @@ static void _stkmon_disp(FAR struct tcb_s *tcb, FAR void *arg) #if CONFIG_TASK_NAME_SIZE > 0 strncpy(buff,tcb->name,CONFIG_TASK_NAME_SIZE); buff[CONFIG_TASK_NAME_SIZE] = '\0'; - syslog("%5d %6d %6d %s\n", + syslog(LOG_INFO, "%5d %6d %6d %s\n", tcb->pid, tcb->adj_stack_size, up_check_tcbstack(tcb), buff); #else - syslog("%5d %6d %6d\n", + syslog(LOG_INFO, "%5d %6d %6d\n", tcb->pid, tcb->adj_stack_size, up_check_tcbstack(tcb)); #endif } @@ -256,9 +256,9 @@ static bool wait_on(long timeoutMs, volatile unsigned long *what, void stkmon_disp(void) { #if CONFIG_TASK_NAME_SIZE > 0 - syslog("%-5s %-6s %-6s %s\n", "PID", "SIZE", "USED", "THREAD NAME"); + syslog(LOG_INFO, "%-5s %-6s %-6s %s\n", "PID", "SIZE", "USED", "THREAD NAME"); #else - syslog("%-5s %-6s %-6s\n", "PID", "SIZE", "USED"); + syslog(LOG_INFO, "%-5s %-6s %-6s\n", "PID", "SIZE", "USED"); #endif sched_foreach(_stkmon_disp, NULL); } diff --git a/apps/nshlib/nsh_usbtrace.c b/apps/nshlib/nsh_usbtrace.c index 09f4df7e6..86341552e 100644 --- a/apps/nshlib/nsh_usbtrace.c +++ b/apps/nshlib/nsh_usbtrace.c @@ -49,18 +49,6 @@ /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ -/* Output USB trace data to the console device using printf() unless (1) - * debug is enabled, then we want to keep the trace output in sync with the - * debug output by using syslog()we are using a USB console. In that case, - * we don't want the trace output on the USB console; let's try sending it - * a SYSLOG device (hopefully one is set up!) - */ - -#if defined(CONFIG_DEBUG) || defined(HAVE_USB_CONSOLE) -# define trmessage syslog -#else -# define trmessage printf -#endif /**************************************************************************** * Private Types @@ -94,9 +82,30 @@ * ****************************************************************************/ +static int usbtrace_syslog(FAR const char *fmt, ...) +{ + va_list ap; + int ret; + + /* Let vsyslog do the real work */ + + va_start(ap, fmt); + ret = vsyslog(LOG_INFO, fmt, ap); + va_end(ap); + return ret; +} + +/**************************************************************************** + * Name: nsh_tracecallback + * + * Description: + * This is part of the USB trace logic + * + ****************************************************************************/ + static int nsh_tracecallback(struct usbtrace_s *trace, void *arg) { - usbtrace_trprintf((trprintf_t)trmessage, trace->event, trace->value); + usbtrace_trprintf(usbtrace_syslog, trace->event, trace->value); return 0; } diff --git a/apps/system/cdcacm/cdcacm.h b/apps/system/cdcacm/cdcacm.h index bc9cf2f9e..d8a351239 100644 --- a/apps/system/cdcacm/cdcacm.h +++ b/apps/system/cdcacm/cdcacm.h @@ -108,26 +108,6 @@ #define TRACE_BITSET (TRACE_INIT_BITS|TRACE_ERROR_BITS|TRACE_CLASS_BITS|\ TRACE_TRANSFER_BITS|TRACE_CONTROLLER_BITS|TRACE_INTERRUPT_BITS) -/* Debug ********************************************************************/ - -#ifdef CONFIG_CPP_HAVE_VARARGS -# ifdef CONFIG_DEBUG -# define message(...) lowsyslog(__VA_ARGS__) -# define msgflush() -# else -# define message(...) printf(__VA_ARGS__) -# define msgflush() fflush(stdout) -# endif -#else -# ifdef CONFIG_DEBUG -# define message lowsyslog -# define msgflush() -# else -# define message printf -# define msgflush() fflush(stdout) -# endif -#endif - /**************************************************************************** * Public Types ****************************************************************************/ diff --git a/apps/system/cdcacm/cdcacm_main.c b/apps/system/cdcacm/cdcacm_main.c index e8ebebb2d..a9f8b504c 100644 --- a/apps/system/cdcacm/cdcacm_main.c +++ b/apps/system/cdcacm/cdcacm_main.c @@ -50,7 +50,7 @@ #include "cdcacm.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** @@ -93,7 +93,7 @@ int sercon_main(int argc, char *argv[]) if (g_cdcacm.handle) { - message("sercon:: ERROR: Already connected\n"); + printf("sercon:: ERROR: Already connected\n"); return EXIT_FAILURE; } @@ -105,15 +105,15 @@ int sercon_main(int argc, char *argv[]) /* Initialize the USB CDC/ACM serial driver */ - message("sercon: Registering CDC/ACM serial driver\n"); + printf("sercon: Registering CDC/ACM serial driver\n"); ret = cdcacm_initialize(CONFIG_SYSTEM_CDCACM_DEVMINOR, &g_cdcacm.handle); if (ret < 0) { - message("sercon: ERROR: Failed to create the CDC/ACM serial device: %d\n", -ret); + printf("sercon: ERROR: Failed to create the CDC/ACM serial device: %d\n", -ret); return EXIT_FAILURE; } - message("sercon: Successfully registered the CDC/ACM serial driver\n"); + printf("sercon: Successfully registered the CDC/ACM serial driver\n"); return EXIT_SUCCESS; } @@ -136,7 +136,7 @@ int serdis_main(int argc, char *argv[]) if (!g_cdcacm.handle) { - message("serdis: ERROR: Not connected\n"); + printf("serdis: ERROR: Not connected\n"); return EXIT_FAILURE; } @@ -150,6 +150,6 @@ int serdis_main(int argc, char *argv[]) cdcacm_uninitialize(g_cdcacm.handle); g_cdcacm.handle = NULL; - message("serdis: Disconnected\n"); + printf("serdis: Disconnected\n"); return EXIT_SUCCESS; } diff --git a/apps/system/cle/cle.c b/apps/system/cle/cle.c index b8e5084ab..1f744cf5c 100644 --- a/apps/system/cle/cle.c +++ b/apps/system/cle/cle.c @@ -39,6 +39,7 @@ #include <nuttx/config.h> +#include <stdarg.h> #include <stdint.h> #include <stdbool.h> #include <stdio.h> @@ -108,26 +109,26 @@ #ifdef CONFIG_CPP_HAVE_VARARGS # if CONFIG_SYSTEM_CLE_DEBUGLEVEL > 0 # define cledbg(format, ...) \ - syslog(EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__) + syslog(LOG_DEBUG, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__) # else # define cledbg(x...) # endif # if CONFIG_SYSTEM_CLE_DEBUGLEVEL > 1 # define clevdbg(format, ...) \ - syslog(EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__) + syslog(LOG_DEBUG, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__) # else # define clevdbg(x...) # endif #else # if CONFIG_SYSTEM_CLE_DEBUGLEVEL > 0 -# define cledbg syslog +# define cledbg cle_debug # else # define cledbg (void) # endif # if CONFIG_SYSTEM_CLE_DEBUGLEVEL > 1 -# define clevdbg syslog +# define clevdbg cle_debug # else # define clevdbg (void) # endif @@ -170,6 +171,10 @@ struct cle_s * Private Function Prototypes ****************************************************************************/ +#if !defined(CONFIG_CPP_HAVE_VARARGS) && CONFIG_SYSTEM_CLE_DEBUGLEVEL > 0 +static int cle_debug(FAR const char *fmt, ...); +#endif + /* Low-level display and data entry functions */ static void cle_write(FAR struct cle_s *priv, FAR const char *buffer, @@ -209,6 +214,29 @@ static const char g_fmtcursorpos[] = VT100_FMT_CURSORPOS; ****************************************************************************/ /**************************************************************************** + * Name: cle_debug + * + * Description: + * Print a debug message to the syslog + * + ****************************************************************************/ + +#if !defined(CONFIG_CPP_HAVE_VARARGS) && CONFIG_SYSTEM_CLE_DEBUGLEVEL > 0 +static int cle_debug(FAR const char *fmt, ...) +{ + va_list ap; + int ret; + + /* Let vsyslog do the real work */ + + va_start(ap, fmt); + ret = vsyslog(LOG_DEBUG, fmt, ap); + va_end(ap); + return ret; +} +#endif + +/**************************************************************************** * Name: cle_write * * Description: diff --git a/apps/system/composite/composite.h b/apps/system/composite/composite.h index 699dcf05e..1f4274f62 100644 --- a/apps/system/composite/composite.h +++ b/apps/system/composite/composite.h @@ -165,26 +165,6 @@ #define TRACE_BITSET (TRACE_INIT_BITS|TRACE_ERROR_BITS|TRACE_CLASS_BITS|\ TRACE_TRANSFER_BITS|TRACE_CONTROLLER_BITS|TRACE_INTERRUPT_BITS) -/* Debug ********************************************************************/ - -#ifdef CONFIG_CPP_HAVE_VARARGS -# ifdef CONFIG_DEBUG -# define message(...) lowsyslog(__VA_ARGS__) -# define msgflush() -# else -# define message(...) printf(__VA_ARGS__) -# define msgflush() fflush(stdout) -# endif -#else -# ifdef CONFIG_DEBUG -# define message lowsyslog -# define msgflush() -# else -# define message printf -# define msgflush() fflush(stdout) -# endif -#endif - /**************************************************************************** * Public Types ****************************************************************************/ diff --git a/apps/system/composite/composite_main.c b/apps/system/composite/composite_main.c index 05e0a3cea..e05059093 100644 --- a/apps/system/composite/composite_main.c +++ b/apps/system/composite/composite_main.c @@ -83,20 +83,22 @@ static void show_memory_usage(struct mallinfo *mmbefore, { int diff; - message(" total used free largest\n"); - message("Before:%11d%11d%11d%11d\n", - mmbefore->arena, mmbefore->uordblks, mmbefore->fordblks, mmbefore->mxordblk); - message("After: %11d%11d%11d%11d\n", - mmafter->arena, mmafter->uordblks, mmafter->fordblks, mmafter->mxordblk); + printf(" total used free largest\n"); + printf("Before:%11d%11d%11d%11d\n", + mmbefore->arena, mmbefore->uordblks, mmbefore->fordblks, + mmbefore->mxordblk); + printf("After: %11d%11d%11d%11d\n", + mmafter->arena, mmafter->uordblks, mmafter->fordblks, + mmafter->mxordblk); diff = mmbefore->uordblks - mmafter->uordblks; if (diff < 0) { - message("Change:%11d allocated\n", -diff); + printf("Change:%11d allocated\n", -diff); } else if (diff > 0) { - message("Change:%11d freed\n", diff); + printf("Change:%11d freed\n", diff); } } #else @@ -120,7 +122,7 @@ static void check_test_memory_usage(FAR const char *msg) /* Show the change from the previous time */ - message("\%s:\n", msg); + printf("\%s:\n", msg); show_memory_usage(&g_composite.mmprevious, &g_composite.mmcurrent); /* Set up for the next test */ @@ -152,7 +154,7 @@ static void final_memory_usage(FAR const char *msg) /* Show the change from the previous time */ - message("\n%s:\n", msg); + printf("\n%s:\n", msg); show_memory_usage(&g_composite.mmstart, &g_composite.mmcurrent); } #else @@ -169,171 +171,184 @@ static int composite_enumerate(struct usbtrace_s *trace, void *arg) switch (trace->event) { case TRACE_DEVINIT: - message("USB controller initialization: %04x\n", trace->value); + printf("USB controller initialization: %04x\n", trace->value); break; case TRACE_DEVUNINIT: - message("USB controller un-initialization: %04x\n", trace->value); + printf("USB controller un-initialization: %04x\n", trace->value); break; case TRACE_DEVREGISTER: - message("usbdev_register(): %04x\n", trace->value); + printf("usbdev_register(): %04x\n", trace->value); break; case TRACE_DEVUNREGISTER: - message("usbdev_unregister(): %04x\n", trace->value); + printf("usbdev_unregister(): %04x\n", trace->value); break; case TRACE_EPCONFIGURE: - message("Endpoint configure(): %04x\n", trace->value); + printf("Endpoint configure(): %04x\n", trace->value); break; case TRACE_EPDISABLE: - message("Endpoint disable(): %04x\n", trace->value); + printf("Endpoint disable(): %04x\n", trace->value); break; case TRACE_EPALLOCREQ: - message("Endpoint allocreq(): %04x\n", trace->value); + printf("Endpoint allocreq(): %04x\n", trace->value); break; case TRACE_EPFREEREQ: - message("Endpoint freereq(): %04x\n", trace->value); + printf("Endpoint freereq(): %04x\n", trace->value); break; case TRACE_EPALLOCBUFFER: - message("Endpoint allocbuffer(): %04x\n", trace->value); + printf("Endpoint allocbuffer(): %04x\n", trace->value); break; case TRACE_EPFREEBUFFER: - message("Endpoint freebuffer(): %04x\n", trace->value); + printf("Endpoint freebuffer(): %04x\n", trace->value); break; case TRACE_EPSUBMIT: - message("Endpoint submit(): %04x\n", trace->value); + printf("Endpoint submit(): %04x\n", trace->value); break; case TRACE_EPCANCEL: - message("Endpoint cancel(): %04x\n", trace->value); + printf("Endpoint cancel(): %04x\n", trace->value); break; case TRACE_EPSTALL: - message("Endpoint stall(true): %04x\n", trace->value); + printf("Endpoint stall(true): %04x\n", trace->value); break; case TRACE_EPRESUME: - message("Endpoint stall(false): %04x\n", trace->value); + printf("Endpoint stall(false): %04x\n", trace->value); break; case TRACE_DEVALLOCEP: - message("Device allocep(): %04x\n", trace->value); + printf("Device allocep(): %04x\n", trace->value); break; case TRACE_DEVFREEEP: - message("Device freeep(): %04x\n", trace->value); + printf("Device freeep(): %04x\n", trace->value); break; case TRACE_DEVGETFRAME: - message("Device getframe(): %04x\n", trace->value); + printf("Device getframe(): %04x\n", trace->value); break; case TRACE_DEVWAKEUP: - message("Device wakeup(): %04x\n", trace->value); + printf("Device wakeup(): %04x\n", trace->value); break; case TRACE_DEVSELFPOWERED: - message("Device selfpowered(): %04x\n", trace->value); + printf("Device selfpowered(): %04x\n", trace->value); break; case TRACE_DEVPULLUP: - message("Device pullup(): %04x\n", trace->value); + printf("Device pullup(): %04x\n", trace->value); break; case TRACE_CLASSBIND: - message("Class bind(): %04x\n", trace->value); + printf("Class bind(): %04x\n", trace->value); break; case TRACE_CLASSUNBIND: - message("Class unbind(): %04x\n", trace->value); + printf("Class unbind(): %04x\n", trace->value); break; case TRACE_CLASSDISCONNECT: - message("Class disconnect(): %04x\n", trace->value); + printf("Class disconnect(): %04x\n", trace->value); break; case TRACE_CLASSSETUP: - message("Class setup(): %04x\n", trace->value); + printf("Class setup(): %04x\n", trace->value); break; case TRACE_CLASSSUSPEND: - message("Class suspend(): %04x\n", trace->value); + printf("Class suspend(): %04x\n", trace->value); break; case TRACE_CLASSRESUME: - message("Class resume(): %04x\n", trace->value); + printf("Class resume(): %04x\n", trace->value); break; case TRACE_CLASSRDCOMPLETE: - message("Class RD request complete: %04x\n", trace->value); + printf("Class RD request complete: %04x\n", trace->value); break; case TRACE_CLASSWRCOMPLETE: - message("Class WR request complete: %04x\n", trace->value); + printf("Class WR request complete: %04x\n", trace->value); break; default: switch (TRACE_ID(trace->event)) { case TRACE_CLASSAPI_ID: /* Other class driver system API calls */ - message("Class API call %d: %04x\n", TRACE_DATA(trace->event), trace->value); + printf("Class API call %d: %04x\n", + TRACE_DATA(trace->event), trace->value); break; case TRACE_CLASSSTATE_ID: /* Track class driver state changes */ - message("Class state %d: %04x\n", TRACE_DATA(trace->event), trace->value); + printf("Class state %d: %04x\n", + TRACE_DATA(trace->event), trace->value); break; case TRACE_INTENTRY_ID: /* Interrupt handler entry */ - message("Interrrupt %d entry: %04x\n", TRACE_DATA(trace->event), trace->value); + printf("Interrupt %d entry: %04x\n", + TRACE_DATA(trace->event), trace->value); break; case TRACE_INTDECODE_ID: /* Decoded interrupt trace->event */ - message("Interrrupt decode %d: %04x\n", TRACE_DATA(trace->event), trace->value); + printf("Interrupt decode %d: %04x\n", + TRACE_DATA(trace->event), trace->value); break; case TRACE_INTEXIT_ID: /* Interrupt handler exit */ - message("Interrrupt %d exit: %04x\n", TRACE_DATA(trace->event), trace->value); + printf("Interrupt %d exit: %04x\n", + TRACE_DATA(trace->event), trace->value); break; case TRACE_OUTREQQUEUED_ID: /* Request queued for OUT endpoint */ - message("EP%d OUT request queued: %04x\n", TRACE_DATA(trace->event), trace->value); + printf("EP%d OUT request queued: %04x\n", + TRACE_DATA(trace->event), trace->value); break; case TRACE_INREQQUEUED_ID: /* Request queued for IN endpoint */ - message("EP%d IN request queued: %04x\n", TRACE_DATA(trace->event), trace->value); + printf("EP%d IN request queued: %04x\n", + TRACE_DATA(trace->event), trace->value); break; case TRACE_READ_ID: /* Read (OUT) action */ - message("EP%d OUT read: %04x\n", TRACE_DATA(trace->event), trace->value); + printf("EP%d OUT read: %04x\n", + TRACE_DATA(trace->event), trace->value); break; case TRACE_WRITE_ID: /* Write (IN) action */ - message("EP%d IN write: %04x\n", TRACE_DATA(trace->event), trace->value); + printf("EP%d IN write: %04x\n", + TRACE_DATA(trace->event), trace->value); break; case TRACE_COMPLETE_ID: /* Request completed */ - message("EP%d request complete: %04x\n", TRACE_DATA(trace->event), trace->value); + printf("EP%d request complete: %04x\n", + TRACE_DATA(trace->event), trace->value); break; case TRACE_DEVERROR_ID: /* USB controller driver error event */ - message("Controller error: %02x:%04x\n", TRACE_DATA(trace->event), trace->value); + printf("Controller error: %02x:%04x\n", + TRACE_DATA(trace->event), trace->value); break; case TRACE_CLSERROR_ID: /* USB class driver error event */ - message("Class error: %02x:%04x\n", TRACE_DATA(trace->event), trace->value); + printf("Class error: %02x:%04x\n", + TRACE_DATA(trace->event), trace->value); break; default: - message("Unrecognized event: %02x:%02x:%04x\n", - TRACE_ID(trace->event) >> 8, TRACE_DATA(trace->event), trace->value); + printf("Unrecognized event: %02x:%02x:%04x\n", + TRACE_ID(trace->event) >> 8, + TRACE_DATA(trace->event), trace->value); break; } } @@ -357,7 +372,7 @@ static int dumptrace(void) ret = usbtrace_enumerate(composite_enumerate, NULL); if (ret < 0) { - message("dumptrace: usbtrace_enumerate failed: %d\n", -ret); + printf("dumptrace: usbtrace_enumerate failed: %d\n", -ret); } return ret; } @@ -381,26 +396,26 @@ static int open_serial(void) do { - message("open_serial: Opening USB serial driver\n"); + printf("open_serial: Opening USB serial driver\n"); g_composite.outfd = open(CONFIG_SYSTEM_COMPOSITE_SERDEV, O_WRONLY); if (g_composite.outfd < 0) { errcode = errno; - message("open_serial: ERROR: Failed to open %s for writing: %d\n", + printf("open_serial: ERROR: Failed to open %s for writing: %d\n", CONFIG_SYSTEM_COMPOSITE_SERDEV, errcode); /* ENOTCONN means that the USB device is not yet connected */ if (errcode == ENOTCONN) { - message("open_serial: Not connected. Wait and try again.\n"); + printf("open_serial: Not connected. Wait and try again.\n"); sleep(5); } else { /* Give up on other errors */ - message("open_serial: Aborting\n"); + printf("open_serial: Aborting\n"); return -errcode; } } @@ -425,13 +440,13 @@ static int open_serial(void) if (g_composite.infd < 0) { errcode = errno; - message("open_serial: ERROR: Failed to open%s for reading: %d\n", + printf("open_serial: ERROR: Failed to open%s for reading: %d\n", CONFIG_SYSTEM_COMPOSITE_SERDEV, errcode); close(g_composite.outfd); return -errcode; } - message("open_serial: Successfully opened the serial driver\n"); + printf("open_serial: Successfully opened the serial driver\n"); return OK; } @@ -453,7 +468,7 @@ static int echo_serial(void) errcode = errno; if (errcode != EAGAIN) { - message("echo_serial: ERROR: read failed: %d\n", errcode); + printf("echo_serial: ERROR: read failed: %d\n", errcode); return -errcode; } return OK; @@ -465,12 +480,12 @@ static int echo_serial(void) if (byteswritten < 0) { errcode = errno; - message("echo_serial: ERROR: write failed: %d\n", errcode); + printf("echo_serial: ERROR: write failed: %d\n", errcode); return -errcode; } else if (byteswritten != bytesread) { - message("echo_serial: ERROR: read size: %d write size: %d\n", + printf("echo_serial: ERROR: read size: %d write size: %d\n", bytesread, byteswritten); } @@ -518,53 +533,57 @@ int board_mscclassobject(FAR struct usbdevclass_driver_s **classdev) /* Configure the mass storage device */ - message("board_mscclassobject: Configuring with NLUNS=%d\n", CONFIG_SYSTEM_COMPOSITE_NLUNS); + printf("board_mscclassobject: Configuring with NLUNS=%d\n", CONFIG_SYSTEM_COMPOSITE_NLUNS); ret = usbmsc_configure(CONFIG_SYSTEM_COMPOSITE_NLUNS, &g_composite.mschandle); if (ret < 0) { - message("board_mscclassobject: usbmsc_configure failed: %d\n", -ret); + printf("board_mscclassobject: usbmsc_configure failed: %d\n", -ret); return ret; } - message("board_mscclassobject: MSC handle=%p\n", g_composite.mschandle); + + printf("board_mscclassobject: MSC handle=%p\n", g_composite.mschandle); check_test_memory_usage("After usbmsc_configure()"); /* Bind the LUN(s) */ - message("board_mscclassobject: Bind LUN=0 to %s\n", CONFIG_SYSTEM_COMPOSITE_DEVPATH1); + printf("board_mscclassobject: Bind LUN=0 to %s\n", CONFIG_SYSTEM_COMPOSITE_DEVPATH1); ret = usbmsc_bindlun(g_composite.mschandle, CONFIG_SYSTEM_COMPOSITE_DEVPATH1, 0, 0, 0, false); if (ret < 0) { - message("board_mscclassobject: usbmsc_bindlun failed for LUN 1 using %s: %d\n", + printf("board_mscclassobject: usbmsc_bindlun failed for LUN 1 using %s: %d\n", CONFIG_SYSTEM_COMPOSITE_DEVPATH1, -ret); usbmsc_uninitialize(g_composite.mschandle); return ret; } + check_test_memory_usage("After usbmsc_bindlun()"); #if CONFIG_SYSTEM_COMPOSITE_NLUNS > 1 - message("board_mscclassobject: Bind LUN=1 to %s\n", CONFIG_SYSTEM_COMPOSITE_DEVPATH2); + printf("board_mscclassobject: Bind LUN=1 to %s\n", CONFIG_SYSTEM_COMPOSITE_DEVPATH2); ret = usbmsc_bindlun(g_composite.mschandle, CONFIG_SYSTEM_COMPOSITE_DEVPATH2, 1, 0, 0, false); if (ret < 0) { - message("board_mscclassobject: usbmsc_bindlun failed for LUN 2 using %s: %d\n", + printf("board_mscclassobject: usbmsc_bindlun failed for LUN 2 using %s: %d\n", CONFIG_SYSTEM_COMPOSITE_DEVPATH2, -ret); usbmsc_uninitialize(g_composite.mschandle); return ret; } + check_test_memory_usage("After usbmsc_bindlun() #2"); #if CONFIG_SYSTEM_COMPOSITE_NLUNS > 2 - message("board_mscclassobject: Bind LUN=2 to %s\n", CONFIG_SYSTEM_COMPOSITE_DEVPATH3); + printf("board_mscclassobject: Bind LUN=2 to %s\n", CONFIG_SYSTEM_COMPOSITE_DEVPATH3); ret = usbmsc_bindlun(g_composite.mschandle, CONFIG_SYSTEM_COMPOSITE_DEVPATH3, 2, 0, 0, false); if (ret < 0) { - message("board_mscclassobject: usbmsc_bindlun failed for LUN 3 using %s: %d\n", + printf("board_mscclassobject: usbmsc_bindlun failed for LUN 3 using %s: %d\n", CONFIG_SYSTEM_COMPOSITE_DEVPATH3, -ret); usbmsc_uninitialize(g_composite.mschandle); return ret; } + check_test_memory_usage("After usbmsc_bindlun() #3"); #endif @@ -575,7 +594,7 @@ int board_mscclassobject(FAR struct usbdevclass_driver_s **classdev) ret = usbmsc_classobject(g_composite.mschandle, classdev); if (ret < 0) { - message("board_mscclassobject: usbmsc_classobject failed: %d\n", -ret); + printf("board_mscclassobject: usbmsc_classobject failed: %d\n", -ret); usbmsc_uninitialize(g_composite.mschandle); } @@ -630,12 +649,13 @@ int board_cdcclassobject(FAR struct usbdevclass_driver_s **classdev) /* Initialize the USB serial driver */ - message("board_cdcclassobject: Initializing USB serial driver\n"); + printf("board_cdcclassobject: Initializing USB serial driver\n"); ret = cdcacm_classobject(CONFIG_SYSTEM_COMPOSITE_TTYUSB, classdev); if (ret < 0) { - message("board_cdcclassobject: ERROR: Failed to create the USB serial device: %d\n", -ret); + printf("board_cdcclassobject: ERROR: Failed to create the USB serial device: %d\n", -ret); } + return ret; } @@ -693,7 +713,7 @@ int conn_main(int argc, char *argv[]) if (g_composite.cmphandle) { - message("conn_main: ERROR: Already connected\n"); + printf("conn_main: ERROR: Already connected\n"); return 1; } #endif @@ -710,13 +730,14 @@ int conn_main(int argc, char *argv[]) /* Perform architecture-specific initialization */ - message("conn_main: Performing architecture-specific intialization\n"); + printf("conn_main: Performing architecture-specific intialization\n"); ret = composite_archinitialize(); if (ret < 0) { - message("conn_main: composite_archinitialize failed: %d\n", -ret); + printf("conn_main: composite_archinitialize failed: %d\n", -ret); return 1; } + check_test_memory_usage("After composite_archinitialize()"); /* Initialize the USB composite device device */ @@ -724,9 +745,10 @@ int conn_main(int argc, char *argv[]) g_composite.cmphandle = composite_initialize(); if (!g_composite.cmphandle) { - message("conn_main: composite_initialize failed\n"); + printf("conn_main: composite_initialize failed\n"); return 1; } + check_test_memory_usage("After composite_initialize()"); #if CONFIG_USBDEV_TRACE && CONFIG_USBDEV_TRACE_INITIALIDSET != 0 @@ -765,7 +787,7 @@ int conn_main(int argc, char *argv[]) { /* Sleep for a bit */ - msgflush(); + fflush(stdout); sleep(5); /* Echo any serial data */ @@ -779,26 +801,27 @@ int conn_main(int argc, char *argv[]) /* Dump trace data */ # ifdef CONFIG_USBDEV_TRACE - message("\n" "conn_main: USB TRACE DATA:\n"); + printf("\n" "conn_main: USB TRACE DATA:\n"); ret = dumptrace(); if (ret < 0) { goto errout; } + check_test_memory_usage("After usbtrace_enumerate()"); # else - message("conn_main: Still alive\n"); + printf("conn_main: Still alive\n"); # endif } #else - message("conn_main: Connected\n"); + printf("conn_main: Connected\n"); check_test_memory_usage("After composite device connection"); #endif /* Dump debug memory usage */ - message("conn_main: Exiting\n"); + printf("conn_main: Exiting\n"); #if !defined(CONFIG_NSH_BUILTIN_APPS) && !defined(CONFIG_DISABLE_SIGNALS) close(g_composite.infd); close(g_composite.outfd); @@ -840,16 +863,17 @@ int disconn_main(int argc, char *argv[]) if (!g_composite.cmphandle) { - message("disconn_main: ERROR: Not connected\n"); + printf("disconn_main: ERROR: Not connected\n"); return 1; } + check_test_memory_usage("Since MS connection"); /* Then disconnect the device and uninitialize the USB mass storage driver */ composite_uninitialize(g_composite.cmphandle); g_composite.cmphandle = NULL; - message("disconn_main: Disconnected\n"); + printf("disconn_main: Disconnected\n"); check_test_memory_usage("After composite_uninitialize()"); /* Dump debug memory usage */ diff --git a/apps/system/stackmonitor/stackmonitor.c b/apps/system/stackmonitor/stackmonitor.c index 8587fda63..094ced4b5 100644 --- a/apps/system/stackmonitor/stackmonitor.c +++ b/apps/system/stackmonitor/stackmonitor.c @@ -98,17 +98,17 @@ static struct stkmon_state_s g_stackmonitor; static void stkmon_task(FAR struct tcb_s *tcb, FAR void *arg) { #if CONFIG_NAME_MAX > 0 - syslog("%5d %6d %6d %s\n", + syslog(LOG_INFO, ("%5d %6d %6d %s\n", tcb->pid, tcb->adj_stack_size, up_check_tcbstack(tcb), tcb->name); #else - syslog("%5d %6d %6d\n", + syslog(LOG_INFO, ("%5d %6d %6d\n", tcb->pid, tcb->adj_stack_size, up_check_tcbstack(tcb)); #endif } static int stackmonitor_daemon(int argc, char **argv) { - syslog(STKMON_PREFIX "Running: %d\n", g_stackmonitor.pid); + syslog(LOG_INFO, (STKMON_PREFIX "Running: %d\n", g_stackmonitor.pid); /* Loop until we detect that there is a request to stop. */ @@ -116,9 +116,9 @@ static int stackmonitor_daemon(int argc, char **argv) { sleep(CONFIG_SYSTEM_STACKMONITOR_INTERVAL); #if CONFIG_NAME_MAX > 0 - syslog("%-5s %-6s %-6s %s\n", "PID", "SIZE", "USED", "THREAD NAME"); + syslog(LOG_INFO, ("%-5s %-6s %-6s %s\n", "PID", "SIZE", "USED", "THREAD NAME"); #else - syslog("%-5s %-6s %-6s\n", "PID", "SIZE", "USED"); + syslog(LOG_INFO, ("%-5s %-6s %-6s\n", "PID", "SIZE", "USED"); #endif sched_foreach(stkmon_task, NULL); } @@ -127,7 +127,7 @@ static int stackmonitor_daemon(int argc, char **argv) g_stackmonitor.stop = false; g_stackmonitor.started = false; - syslog(STKMON_PREFIX "Stopped: %d\n", g_stackmonitor.pid); + syslog(LOG_INFO, (STKMON_PREFIX "Stopped: %d\n", g_stackmonitor.pid); return 0; } @@ -158,14 +158,14 @@ int stackmonitor_start(int argc, char **argv) if (ret < 0) { int errcode = errno; - syslog(STKMON_PREFIX + syslog(LOG_INFO, (STKMON_PREFIX "ERROR: Failed to start the stack monitor: %d\n", errcode); } else { g_stackmonitor.pid = ret; - syslog(STKMON_PREFIX "Started: %d\n", g_stackmonitor.pid); + syslog(LOG_INFO, (STKMON_PREFIX "Started: %d\n", g_stackmonitor.pid); } sched_unlock(); @@ -173,7 +173,7 @@ int stackmonitor_start(int argc, char **argv) } sched_unlock(); - syslog(STKMON_PREFIX "%s: %d\n", + syslog(LOG_INFO, (STKMON_PREFIX "%s: %d\n", g_stackmonitor.stop ? "Stopping" : "Running", g_stackmonitor.pid); return 0; } @@ -188,11 +188,11 @@ int stackmonitor_stop(int argc, char **argv) * it will see the the stop indication and will exist. */ - syslog(STKMON_PREFIX "Stopping: %d\n", g_stackmonitor.pid); + syslog(LOG_INFO, (STKMON_PREFIX "Stopping: %d\n", g_stackmonitor.pid); g_stackmonitor.stop = true; } - syslog(STKMON_PREFIX "Stopped: %d\n", g_stackmonitor.pid); + syslog(LOG_INFO, (STKMON_PREFIX "Stopped: %d\n", g_stackmonitor.pid); return 0; } diff --git a/apps/system/usbmonitor/usbmonitor.c b/apps/system/usbmonitor/usbmonitor.c index 25bc681e5..fa61c221f 100644 --- a/apps/system/usbmonitor/usbmonitor.c +++ b/apps/system/usbmonitor/usbmonitor.c @@ -41,6 +41,7 @@ #include <nuttx/progmem.h> #include <sys/types.h> +#include <stdarg.h> #include <stdbool.h> #include <unistd.h> #include <sched.h> @@ -138,16 +139,29 @@ static struct usbmon_state_s g_usbmonitor; ****************************************************************************/ #ifdef CONFIG_USBDEV_TRACE +static int usbtrace_syslog(FAR const char *fmt, ...) +{ + va_list ap; + int ret; + + /* Let vsyslog do the real work */ + + va_start(ap, fmt); + ret = vsyslog(LOG_INFO, fmt, ap); + va_end(ap); + return ret; +} + static int usbmonitor_tracecallback(struct usbtrace_s *trace, void *arg) { - usbtrace_trprintf((trprintf_t)syslog, trace->event, trace->value); + usbtrace_trprintf(usbtrace_syslog, trace->event, trace->value); return 0; } #endif static int usbmonitor_daemon(int argc, char **argv) { - syslog(USBMON_PREFIX "Running: %d\n", g_usbmonitor.pid); + syslog(LOG_INFO, USBMON_PREFIX "Running: %d\n", g_usbmonitor.pid); /* Loop until we detect that there is a request to stop. */ @@ -166,7 +180,7 @@ static int usbmonitor_daemon(int argc, char **argv) g_usbmonitor.stop = false; g_usbmonitor.started = false; - syslog(USBMON_PREFIX "Stopped: %d\n", g_usbmonitor.pid); + syslog(LOG_INFO, USBMON_PREFIX "Stopped: %d\n", g_usbmonitor.pid); return 0; } @@ -203,14 +217,15 @@ int usbmonitor_start(int argc, char **argv) if (ret < 0) { int errcode = errno; - syslog(USBMON_PREFIX + syslog(LOG_INFO, USBMON_PREFIX "ERROR: Failed to start the USB monitor: %d\n", errcode); } else { g_usbmonitor.pid = ret; - syslog(USBMON_PREFIX "Started: %d\n", g_usbmonitor.pid); + syslog(LOG_INFO, USBMON_PREFIX "Started: %d\n", + g_usbmonitor.pid); } sched_unlock(); @@ -218,7 +233,7 @@ int usbmonitor_start(int argc, char **argv) } sched_unlock(); - syslog(USBMON_PREFIX "%s: %d\n", + syslog(LOG_INFO, USBMON_PREFIX "%s: %d\n", g_usbmonitor.stop ? "Stopping" : "Running", g_usbmonitor.pid); return 0; } @@ -233,7 +248,7 @@ int usbmonitor_stop(int argc, char **argv) * it will see the the stop indication and will exist. */ - syslog(USBMON_PREFIX "Stopping: %d\n", g_usbmonitor.pid); + syslog(LOG_INFO, USBMON_PREFIX "Stopping: %d\n", g_usbmonitor.pid); g_usbmonitor.stop = true; #ifdef CONFIG_USBDEV_TRACE @@ -243,7 +258,7 @@ int usbmonitor_stop(int argc, char **argv) #endif } - syslog(USBMON_PREFIX "Stopped: %d\n", g_usbmonitor.pid); + syslog(LOG_INFO, USBMON_PREFIX "Stopped: %d\n", g_usbmonitor.pid); return 0; } diff --git a/apps/system/usbmsc/usbmsc.h b/apps/system/usbmsc/usbmsc.h index c54803ee2..5b19a9e03 100644 --- a/apps/system/usbmsc/usbmsc.h +++ b/apps/system/usbmsc/usbmsc.h @@ -89,26 +89,6 @@ # undef CONFIG_SYSTEM_USBMSC_DEVPATH3 #endif -/* Debug ********************************************************************/ - -#ifdef CONFIG_CPP_HAVE_VARARGS -# ifdef CONFIG_DEBUG -# define message(...) lowsyslog(__VA_ARGS__) -# define msgflush() -# else -# define message(...) printf(__VA_ARGS__) -# define msgflush() fflush(stdout) -# endif -#else -# ifdef CONFIG_DEBUG -# define message lowsyslog -# define msgflush() -# else -# define message printf -# define msgflush() fflush(stdout) -# endif -#endif - /**************************************************************************** * Public Types ****************************************************************************/ diff --git a/apps/system/usbmsc/usbmsc_main.c b/apps/system/usbmsc/usbmsc_main.c index b2f6aa66d..76fa81138 100644 --- a/apps/system/usbmsc/usbmsc_main.c +++ b/apps/system/usbmsc/usbmsc_main.c @@ -116,20 +116,22 @@ static void show_memory_usage(struct mallinfo *mmbefore, { int diff; - message(" total used free largest\n"); - message("Before:%11d%11d%11d%11d\n", - mmbefore->arena, mmbefore->uordblks, mmbefore->fordblks, mmbefore->mxordblk); - message("After: %11d%11d%11d%11d\n", - mmafter->arena, mmafter->uordblks, mmafter->fordblks, mmafter->mxordblk); + printf(" total used free largest\n"); + printf("Before:%11d%11d%11d%11d\n", + mmbefore->arena, mmbefore->uordblks, mmbefore->fordblks, + mmbefore->mxordblk); + printf("After: %11d%11d%11d%11d\n", + mmafter->arena, mmafter->uordblks, mmafter->fordblks, + mmafter->mxordblk); diff = mmbefore->uordblks - mmafter->uordblks; if (diff < 0) { - message("Change:%11d allocated\n", -diff); + printf("Change:%11d allocated\n", -diff); } else if (diff > 0) { - message("Change:%11d freed\n", diff); + printf("Change:%11d freed\n", diff); } } #else @@ -153,7 +155,7 @@ static void check_test_memory_usage(FAR const char *msg) /* Show the change from the previous time */ - message("\%s:\n", msg); + printf("\%s:\n", msg); show_memory_usage(&g_usbmsc.mmprevious, &g_usbmsc.mmcurrent); /* Set up for the next test */ @@ -185,7 +187,7 @@ static void final_memory_usage(FAR const char *msg) /* Show the change from the previous time */ - message("\n%s:\n", msg); + printf("\n%s:\n", msg); show_memory_usage(&g_usbmsc.mmstart, &g_usbmsc.mmcurrent); } #else @@ -202,171 +204,184 @@ static int usbmsc_enumerate(struct usbtrace_s *trace, void *arg) switch (trace->event) { case TRACE_DEVINIT: - message("USB controller initialization: %04x\n", trace->value); + printf("USB controller initialization: %04x\n", trace->value); break; case TRACE_DEVUNINIT: - message("USB controller un-initialization: %04x\n", trace->value); + printf("USB controller un-initialization: %04x\n", trace->value); break; case TRACE_DEVREGISTER: - message("usbdev_register(): %04x\n", trace->value); + printf("usbdev_register(): %04x\n", trace->value); break; case TRACE_DEVUNREGISTER: - message("usbdev_unregister(): %04x\n", trace->value); + printf("usbdev_unregister(): %04x\n", trace->value); break; case TRACE_EPCONFIGURE: - message("Endpoint configure(): %04x\n", trace->value); + printf("Endpoint configure(): %04x\n", trace->value); break; case TRACE_EPDISABLE: - message("Endpoint disable(): %04x\n", trace->value); + printf("Endpoint disable(): %04x\n", trace->value); break; case TRACE_EPALLOCREQ: - message("Endpoint allocreq(): %04x\n", trace->value); + printf("Endpoint allocreq(): %04x\n", trace->value); break; case TRACE_EPFREEREQ: - message("Endpoint freereq(): %04x\n", trace->value); + printf("Endpoint freereq(): %04x\n", trace->value); break; case TRACE_EPALLOCBUFFER: - message("Endpoint allocbuffer(): %04x\n", trace->value); + printf("Endpoint allocbuffer(): %04x\n", trace->value); break; case TRACE_EPFREEBUFFER: - message("Endpoint freebuffer(): %04x\n", trace->value); + printf("Endpoint freebuffer(): %04x\n", trace->value); break; case TRACE_EPSUBMIT: - message("Endpoint submit(): %04x\n", trace->value); + printf("Endpoint submit(): %04x\n", trace->value); break; case TRACE_EPCANCEL: - message("Endpoint cancel(): %04x\n", trace->value); + printf("Endpoint cancel(): %04x\n", trace->value); break; case TRACE_EPSTALL: - message("Endpoint stall(true): %04x\n", trace->value); + printf("Endpoint stall(true): %04x\n", trace->value); break; case TRACE_EPRESUME: - message("Endpoint stall(false): %04x\n", trace->value); + printf("Endpoint stall(false): %04x\n", trace->value); break; case TRACE_DEVALLOCEP: - message("Device allocep(): %04x\n", trace->value); + printf("Device allocep(): %04x\n", trace->value); break; case TRACE_DEVFREEEP: - message("Device freeep(): %04x\n", trace->value); + printf("Device freeep(): %04x\n", trace->value); break; case TRACE_DEVGETFRAME: - message("Device getframe(): %04x\n", trace->value); + printf("Device getframe(): %04x\n", trace->value); break; case TRACE_DEVWAKEUP: - message("Device wakeup(): %04x\n", trace->value); + printf("Device wakeup(): %04x\n", trace->value); break; case TRACE_DEVSELFPOWERED: - message("Device selfpowered(): %04x\n", trace->value); + printf("Device selfpowered(): %04x\n", trace->value); break; case TRACE_DEVPULLUP: - message("Device pullup(): %04x\n", trace->value); + printf("Device pullup(): %04x\n", trace->value); break; case TRACE_CLASSBIND: - message("Class bind(): %04x\n", trace->value); + printf("Class bind(): %04x\n", trace->value); break; case TRACE_CLASSUNBIND: - message("Class unbind(): %04x\n", trace->value); + printf("Class unbind(): %04x\n", trace->value); break; case TRACE_CLASSDISCONNECT: - message("Class disconnect(): %04x\n", trace->value); + printf("Class disconnect(): %04x\n", trace->value); break; case TRACE_CLASSSETUP: - message("Class setup(): %04x\n", trace->value); + printf("Class setup(): %04x\n", trace->value); break; case TRACE_CLASSSUSPEND: - message("Class suspend(): %04x\n", trace->value); + printf("Class suspend(): %04x\n", trace->value); break; case TRACE_CLASSRESUME: - message("Class resume(): %04x\n", trace->value); + printf("Class resume(): %04x\n", trace->value); break; case TRACE_CLASSRDCOMPLETE: - message("Class RD request complete: %04x\n", trace->value); + printf("Class RD request complete: %04x\n", trace->value); break; case TRACE_CLASSWRCOMPLETE: - message("Class WR request complete: %04x\n", trace->value); + printf("Class WR request complete: %04x\n", trace->value); break; default: switch (TRACE_ID(trace->event)) { case TRACE_CLASSAPI_ID: /* Other class driver system API calls */ - message("Class API call %d: %04x\n", TRACE_DATA(trace->event), trace->value); + printf("Class API call %d: %04x\n", + TRACE_DATA(trace->event), trace->value); break; case TRACE_CLASSSTATE_ID: /* Track class driver state changes */ - message("Class state %d: %04x\n", TRACE_DATA(trace->event), trace->value); + printf("Class state %d: %04x\n", + TRACE_DATA(trace->event), trace->value); break; case TRACE_INTENTRY_ID: /* Interrupt handler entry */ - message("Interrrupt %d entry: %04x\n", TRACE_DATA(trace->event), trace->value); + printf("Interrupt %d entry: %04x\n", + TRACE_DATA(trace->event), trace->value); break; case TRACE_INTDECODE_ID: /* Decoded interrupt trace->event */ - message("Interrrupt decode %d: %04x\n", TRACE_DATA(trace->event), trace->value); + printf("Interrupt decode %d: %04x\n", + TRACE_DATA(trace->event), trace->value); break; case TRACE_INTEXIT_ID: /* Interrupt handler exit */ - message("Interrrupt %d exit: %04x\n", TRACE_DATA(trace->event), trace->value); + printf("Interrupt %d exit: %04x\n", + TRACE_DATA(trace->event), trace->value); break; case TRACE_OUTREQQUEUED_ID: /* Request queued for OUT endpoint */ - message("EP%d OUT request queued: %04x\n", TRACE_DATA(trace->event), trace->value); + printf("EP%d OUT request queued: %04x\n", + TRACE_DATA(trace->event), trace->value); break; case TRACE_INREQQUEUED_ID: /* Request queued for IN endpoint */ - message("EP%d IN request queued: %04x\n", TRACE_DATA(trace->event), trace->value); + printf("EP%d IN request queued: %04x\n", + TRACE_DATA(trace->event), trace->value); break; case TRACE_READ_ID: /* Read (OUT) action */ - message("EP%d OUT read: %04x\n", TRACE_DATA(trace->event), trace->value); + printf("EP%d OUT read: %04x\n", + TRACE_DATA(trace->event), trace->value); break; case TRACE_WRITE_ID: /* Write (IN) action */ - message("EP%d IN write: %04x\n", TRACE_DATA(trace->event), trace->value); + printf("EP%d IN write: %04x\n", + TRACE_DATA(trace->event), trace->value); break; case TRACE_COMPLETE_ID: /* Request completed */ - message("EP%d request complete: %04x\n", TRACE_DATA(trace->event), trace->value); + printf("EP%d request complete: %04x\n", + TRACE_DATA(trace->event), trace->value); break; case TRACE_DEVERROR_ID: /* USB controller driver error event */ - message("Controller error: %02x:%04x\n", TRACE_DATA(trace->event), trace->value); + printf("Controller error: %02x:%04x\n", + TRACE_DATA(trace->event), trace->value); break; case TRACE_CLSERROR_ID: /* USB class driver error event */ - message("Class error: %02x:%04x\n", TRACE_DATA(trace->event), trace->value); + printf("Class error: %02x:%04x\n", + TRACE_DATA(trace->event), trace->value); break; default: - message("Unrecognized event: %02x:%02x:%04x\n", - TRACE_ID(trace->event) >> 8, TRACE_DATA(trace->event), trace->value); + printf("Unrecognized event: %02x:%02x:%04x\n", + TRACE_ID(trace->event) >> 8, + TRACE_DATA(trace->event), trace->value); break; } } @@ -410,7 +425,7 @@ int msconn_main(int argc, char *argv[]) if (g_usbmsc.mshandle) { - message("mcsonn_main: ERROR: Already connected\n"); + printf("mcsonn_main: ERROR: Already connected\n"); return EXIT_FAILURE; } #endif @@ -434,11 +449,11 @@ int msconn_main(int argc, char *argv[]) /* Register block drivers (architecture-specific) */ - message("mcsonn_main: Creating block drivers\n"); + printf("mcsonn_main: Creating block drivers\n"); ret = usbmsc_archinitialize(); if (ret < 0) { - message("mcsonn_main: usbmsc_archinitialize failed: %d\n", -ret); + printf("mcsonn_main: usbmsc_archinitialize failed: %d\n", -ret); return EXIT_FAILURE; } @@ -446,23 +461,23 @@ int msconn_main(int argc, char *argv[]) /* Then exports the LUN(s) */ - message("mcsonn_main: Configuring with NLUNS=%d\n", CONFIG_SYSTEM_USBMSC_NLUNS); + printf("mcsonn_main: Configuring with NLUNS=%d\n", CONFIG_SYSTEM_USBMSC_NLUNS); ret = usbmsc_configure(CONFIG_SYSTEM_USBMSC_NLUNS, &handle); if (ret < 0) { - message("mcsonn_main: usbmsc_configure failed: %d\n", -ret); + printf("mcsonn_main: usbmsc_configure failed: %d\n", -ret); usbmsc_uninitialize(handle); return EXIT_FAILURE; } - message("mcsonn_main: handle=%p\n", handle); + printf("mcsonn_main: handle=%p\n", handle); check_test_memory_usage("After usbmsc_configure()"); - message("mcsonn_main: Bind LUN=0 to %s\n", CONFIG_SYSTEM_USBMSC_DEVPATH1); + printf("mcsonn_main: Bind LUN=0 to %s\n", CONFIG_SYSTEM_USBMSC_DEVPATH1); ret = usbmsc_bindlun(handle, CONFIG_SYSTEM_USBMSC_DEVPATH1, 0, 0, 0, false); if (ret < 0) { - message("mcsonn_main: usbmsc_bindlun failed for LUN 1 using %s: %d\n", + printf("mcsonn_main: usbmsc_bindlun failed for LUN 1 using %s: %d\n", CONFIG_SYSTEM_USBMSC_DEVPATH1, -ret); usbmsc_uninitialize(handle); return EXIT_FAILURE; @@ -472,11 +487,11 @@ int msconn_main(int argc, char *argv[]) #if CONFIG_SYSTEM_USBMSC_NLUNS > 1 - message("mcsonn_main: Bind LUN=1 to %s\n", CONFIG_SYSTEM_USBMSC_DEVPATH2); + printf("mcsonn_main: Bind LUN=1 to %s\n", CONFIG_SYSTEM_USBMSC_DEVPATH2); ret = usbmsc_bindlun(handle, CONFIG_SYSTEM_USBMSC_DEVPATH2, 1, 0, 0, false); if (ret < 0) { - message("mcsonn_main: usbmsc_bindlun failed for LUN 2 using %s: %d\n", + printf("mcsonn_main: usbmsc_bindlun failed for LUN 2 using %s: %d\n", CONFIG_SYSTEM_USBMSC_DEVPATH2, -ret); usbmsc_uninitialize(handle); return EXIT_FAILURE; @@ -486,11 +501,11 @@ int msconn_main(int argc, char *argv[]) #if CONFIG_SYSTEM_USBMSC_NLUNS > 2 - message("mcsonn_main: Bind LUN=2 to %s\n", CONFIG_SYSTEM_USBMSC_DEVPATH3); + printf("mcsonn_main: Bind LUN=2 to %s\n", CONFIG_SYSTEM_USBMSC_DEVPATH3); ret = usbmsc_bindlun(handle, CONFIG_SYSTEM_USBMSC_DEVPATH3, 2, 0, 0, false); if (ret < 0) { - message("mcsonn_main: usbmsc_bindlun failed for LUN 3 using %s: %d\n", + printf("mcsonn_main: usbmsc_bindlun failed for LUN 3 using %s: %d\n", CONFIG_SYSTEM_USBMSC_DEVPATH3, -ret); usbmsc_uninitialize(handle); return EXIT_FAILURE; @@ -504,7 +519,7 @@ int msconn_main(int argc, char *argv[]) ret = usbmsc_exportluns(handle); if (ret < 0) { - message("mcsonn_main: usbmsc_exportluns failed: %d\n", -ret); + printf("mcsonn_main: usbmsc_exportluns failed: %d\n", -ret); usbmsc_uninitialize(handle); return EXIT_FAILURE; } @@ -522,22 +537,22 @@ int msconn_main(int argc, char *argv[]) for (;;) { - msgflush(); + fflush(stdout); sleep(5); # ifdef CONFIG_SYSTEM_USBMSC_TRACE - message("\nmcsonn_main: USB TRACE DATA:\n"); + printf("\nmcsonn_main: USB TRACE DATA:\n"); ret = usbtrace_enumerate(usbmsc_enumerate, NULL); if (ret < 0) { - message("mcsonn_main: usbtrace_enumerate failed: %d\n", -ret); + printf("mcsonn_main: usbtrace_enumerate failed: %d\n", -ret); usbmsc_uninitialize(handle); return EXIT_FAILURE; } check_test_memory_usage("After usbtrace_enumerate()"); # else - message("mcsonn_main: Still alive\n"); + printf("mcsonn_main: Still alive\n"); # endif } #elif defined(CONFIG_NSH_BUILTIN_APPS) @@ -546,7 +561,7 @@ int msconn_main(int argc, char *argv[]) * command. */ - message("mcsonn_main: Connected\n"); + printf("mcsonn_main: Connected\n"); g_usbmsc.mshandle = handle; check_test_memory_usage("After MS connection"); @@ -554,7 +569,7 @@ int msconn_main(int argc, char *argv[]) /* Just exit */ - message("mcsonn_main: Exiting\n"); + printf("mcsonn_main: Exiting\n"); /* Dump debug memory usage */ @@ -586,7 +601,7 @@ int msdis_main(int argc, char *argv[]) if (!g_usbmsc.mshandle) { - message("msdis: ERROR: Not connected\n"); + printf("msdis: ERROR: Not connected\n"); return EXIT_FAILURE; } @@ -596,7 +611,7 @@ int msdis_main(int argc, char *argv[]) usbmsc_uninitialize(g_usbmsc.mshandle); g_usbmsc.mshandle = NULL; - message("msdis: Disconnected\n"); + printf("msdis: Disconnected\n"); check_test_memory_usage("After usbmsc_uninitialize()"); /* Dump debug memory usage */ diff --git a/apps/system/vi/vi.c b/apps/system/vi/vi.c index ebc19f5bb..6c145a23d 100644 --- a/apps/system/vi/vi.c +++ b/apps/system/vi/vi.c @@ -41,6 +41,7 @@ #include <sys/stat.h> +#include <stdarg.h> #include <stdint.h> #include <stdbool.h> #include <stdlib.h> @@ -150,9 +151,9 @@ #ifdef CONFIG_CPP_HAVE_VARARGS # if CONFIG_SYSTEM_VI_DEBUGLEVEL > 0 # define vidbg(format, ...) \ - syslog(EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__) + syslog(LOG_DEBUG, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__) # define vvidbg(format, ap) \ - vsyslog(format, ap) + vsyslog(LOG_DEBUG, format, ap) # else # define vidbg(x...) # define vvidbg(x...) @@ -160,21 +161,21 @@ # if CONFIG_SYSTEM_VI_DEBUGLEVEL > 1 # define vivdbg(format, ...) \ - syslog(EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__) + syslog(LOG_DEBUG, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__) # else # define vivdbg(x...) # endif #else # if CONFIG_SYSTEM_VI_DEBUGLEVEL > 0 -# define vidbg syslog -# define vvidbg vsyslog +# define vidbg vi_debug +# define vvidbg vi_vdebug # else # define vidbg (void) # define vvidbg (void) # endif # if CONFIG_SYSTEM_VI_DEBUGLEVEL > 1 -# define vivdbg syslog +# define vivdbg vi_debug # else # define vivdbg (void) # endif @@ -448,6 +449,34 @@ static const char g_fmtnotcmd[] = "Not an editor command: %s"; ****************************************************************************/ /**************************************************************************** + * Name: vi_vdebug and vi_debug + * + * Description: + * Print a debug message to the syslog + * + ****************************************************************************/ + +#if !defined(CONFIG_CPP_HAVE_VARARGS) && CONFIG_SYSTEM_VI_DEBUGLEVEL > 0 +static inline int vi_vdebug(FAR const char *fmt, va_list ap) +{ + return vsyslog(LOG_DEBUG, fmt, ap); +} + +static int vi_debug(FAR const char *fmt, ...) +{ + va_list ap; + int ret; + + /* Let vsyslog do the real work */ + + va_start(ap, fmt); + ret = vsyslog(LOG_DEBUG, fmt, ap); + va_end(ap); + return ret; +} +#endif + +/**************************************************************************** * Low-level display and data entry functions ****************************************************************************/ |