diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-10-08 08:33:00 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-10-08 08:33:00 -0600 |
commit | fdb1d0a4df496e7a3232a950d5c72231363cf67a (patch) | |
tree | 5d18c1b4f9241f17396ec663ff4425bf21e6b57a | |
parent | 1753a0251a941fa4d1a5b95aec631209e9957670 (diff) | |
download | nuttx-fdb1d0a4df496e7a3232a950d5c72231363cf67a.tar.gz nuttx-fdb1d0a4df496e7a3232a950d5c72231363cf67a.tar.bz2 nuttx-fdb1d0a4df496e7a3232a950d5c72231363cf67a.zip |
Remove non-portable references to syslog from apps/examples
65 files changed, 1198 insertions, 1583 deletions
diff --git a/apps/examples/adc/adc.h b/apps/examples/adc/adc.h index 2d8af87e1..291d485fa 100644 --- a/apps/examples/adc/adc.h +++ b/apps/examples/adc/adc.h @@ -70,26 +70,6 @@ # define CONFIG_EXAMPLES_ADC_GROUPSIZE 4 #endif -/* Debug ********************************************************************/ - -#ifdef CONFIG_CPP_HAVE_VARARGS -# ifdef CONFIG_DEBUG -# define message(...) syslog(__VA_ARGS__) -# define msgflush() -# else -# define message(...) printf(__VA_ARGS__) -# define msgflush() fflush(stdout) -# endif -#else -# ifdef CONFIG_DEBUG -# define message syslog -# define msgflush() -# else -# define message printf -# define msgflush() fflush(stdout) -# endif -#endif - /**************************************************************************** * Public Types ****************************************************************************/ diff --git a/apps/examples/adc/adc_main.c b/apps/examples/adc/adc_main.c index 01b5a4c88..884598b6d 100644 --- a/apps/examples/adc/adc_main.c +++ b/apps/examples/adc/adc_main.c @@ -113,16 +113,16 @@ static void adc_devpath(FAR struct adc_state_s *adc, FAR const char *devpath) #ifdef CONFIG_NSH_BUILTIN_APPS static void adc_help(FAR struct adc_state_s *adc) { - message("Usage: adc [OPTIONS]\n"); - message("\nArguments are \"sticky\". For example, once the ADC device is\n"); - message("specified, that device will be re-used until it is changed.\n"); - message("\n\"sticky\" OPTIONS include:\n"); - message(" [-p devpath] selects the ADC device. " + printf("Usage: adc [OPTIONS]\n"); + printf("\nArguments are \"sticky\". For example, once the ADC device is\n"); + printf("specified, that device will be re-used until it is changed.\n"); + printf("\n\"sticky\" OPTIONS include:\n"); + printf(" [-p devpath] selects the ADC device. " "Default: %s Current: %s\n", CONFIG_EXAMPLES_ADC_DEVPATH, g_adcstate.devpath ? g_adcstate.devpath : "NONE"); - message(" [-n count] selects the samples to collect. " + printf(" [-n count] selects the samples to collect. " "Default: 1 Current: %d\n", adc->count); - message(" [-h] shows this message and exits\n"); + printf(" [-h] shows this message and exits\n"); } #endif @@ -182,7 +182,7 @@ static void parse_args(FAR struct adc_state_s *adc, int argc, FAR char **argv) ptr = argv[index]; if (ptr[0] != '-') { - message("Invalid options format: %s\n", ptr); + printf("Invalid options format: %s\n", ptr); exit(0); } @@ -192,7 +192,7 @@ static void parse_args(FAR struct adc_state_s *adc, int argc, FAR char **argv) nargs = arg_decimal(&argv[index], &value); if (value < 0) { - message("Count must be non-negative: %ld\n", value); + printf("Count must be non-negative: %ld\n", value); exit(1); } @@ -211,7 +211,7 @@ static void parse_args(FAR struct adc_state_s *adc, int argc, FAR char **argv) exit(0); default: - message("Unsupported option: %s\n", ptr); + printf("Unsupported option: %s\n", ptr); adc_help(adc); exit(1); } @@ -249,11 +249,11 @@ int adc_main(int argc, char *argv[]) * this test. */ - message("adc_main: Initializing external ADC device\n"); + printf("adc_main: Initializing external ADC device\n"); ret = adc_devinit(); if (ret != OK) { - message("adc_main: adc_devinit failed: %d\n", ret); + printf("adc_main: adc_devinit failed: %d\n", ret); errval = 1; goto errout; } @@ -281,18 +281,18 @@ int adc_main(int argc, char *argv[]) */ #if defined(CONFIG_NSH_BUILTIN_APPS) || CONFIG_EXAMPLES_ADC_NSAMPLES > 0 - message("adc_main: g_adcstate.count: %d\n", g_adcstate.count); + printf("adc_main: g_adcstate.count: %d\n", g_adcstate.count); #endif /* Open the ADC device for reading */ - message("adc_main: Hardware initialized. Opening the ADC device: %s\n", + printf("adc_main: Hardware initialized. Opening the ADC device: %s\n", g_adcstate.devpath); fd = open(g_adcstate.devpath, O_RDONLY); if (fd < 0) { - message("adc_main: open %s failed: %d\n", g_adcstate.devpath, errno); + printf("adc_main: open %s failed: %d\n", g_adcstate.devpath, errno); errval = 2; goto errout; } @@ -313,7 +313,7 @@ int adc_main(int argc, char *argv[]) * through the loop. */ - msgflush(); + fflush(stdout); #ifdef CONFIG_EXAMPLES_ADC_SWTRIG /* Issue the software trigger to start ADC conversion */ @@ -322,7 +322,7 @@ int adc_main(int argc, char *argv[]) if (ret < 0) { int errcode = errno; - message("adc_main: ANIOC_TRIGGER ioctl failed: %d\n", errcode); + printf("adc_main: ANIOC_TRIGGER ioctl failed: %d\n", errcode); } #endif @@ -338,17 +338,17 @@ int adc_main(int argc, char *argv[]) errval = errno; if (errval != EINTR) { - message("adc_main: read %s failed: %d\n", + printf("adc_main: read %s failed: %d\n", g_adcstate.devpath, errval); errval = 3; goto errout_with_dev; } - message("adc_main: Interrupted read...\n"); + printf("adc_main: Interrupted read...\n"); } else if (nbytes == 0) { - message("adc_main: No data read, Ignoring\n"); + printf("adc_main: No data read, Ignoring\n"); } /* Print the sample data on successful return */ @@ -358,15 +358,15 @@ int adc_main(int argc, char *argv[]) int nsamples = nbytes / sizeof(struct adc_msg_s); if (nsamples * sizeof(struct adc_msg_s) != nbytes) { - message("adc_main: read size=%d is not a multiple of sample size=%d, Ignoring\n", + printf("adc_main: read size=%d is not a multiple of sample size=%d, Ignoring\n", nbytes, sizeof(struct adc_msg_s)); } else { - message("Sample:\n"); + printf("Sample:\n"); for (i = 0; i < nsamples ; i++) { - message("%d: channel: %d value: %d\n", + printf("%d: channel: %d value: %d\n", i+1, sample[i].am_channel, sample[i].am_data); } } @@ -382,7 +382,7 @@ errout_with_dev: close(fd); errout: - message("Terminating!\n"); - msgflush(); + printf("Terminating!\n"); + fflush(stdout); return errval; } diff --git a/apps/examples/can/can.h b/apps/examples/can/can.h index d9f9236f7..794a84b33 100644 --- a/apps/examples/can/can.h +++ b/apps/examples/can/can.h @@ -85,26 +85,6 @@ # define CONFIG_EXAMPLES_CAN_NMSGS 32 #endif -/* Debug ********************************************************************/ - -#ifdef CONFIG_CPP_HAVE_VARARGS -# ifdef CONFIG_DEBUG -# define message(...) syslog(__VA_ARGS__) -# define msgflush() -# else -# define message(...) printf(__VA_ARGS__) -# define msgflush() fflush(stdout) -# endif -#else -# ifdef CONFIG_DEBUG -# define message syslog -# define msgflush() -# else -# define message printf -# define msgflush() fflush(stdout) -# endif -#endif - /**************************************************************************** * Public Types ****************************************************************************/ diff --git a/apps/examples/can/can_main.c b/apps/examples/can/can_main.c index 471e81904..d74dd9495 100644 --- a/apps/examples/can/can_main.c +++ b/apps/examples/can/can_main.c @@ -146,31 +146,31 @@ int can_main(int argc, char *argv[]) { nmsgs = strtol(argv[1], NULL, 10); } - message("can_main: nmsgs: %d\n", nmsgs); + printf("can_main: nmsgs: %d\n", nmsgs); #elif defined(CONFIG_EXAMPLES_CAN_NMSGS) - message("can_main: nmsgs: %d\n", CONFIG_EXAMPLES_CAN_NMSGS); + printf("can_main: nmsgs: %d\n", CONFIG_EXAMPLES_CAN_NMSGS); #endif /* Initialization of the CAN hardware is performed by logic external to * this test. */ - message("can_main: Initializing external CAN device\n"); + printf("can_main: Initializing external CAN device\n"); ret = can_devinit(); if (ret != OK) { - message("can_main: can_devinit failed: %d\n", ret); + printf("can_main: can_devinit failed: %d\n", ret); errval = 1; goto errout; } /* Open the CAN device for reading */ - message("can_main: Hardware initialized. Opening the CAN device\n"); + printf("can_main: Hardware initialized. Opening the CAN device\n"); fd = open(CONFIG_EXAMPLES_CAN_DEVPATH, CAN_OFLAGS); if (fd < 0) { - message("can_main: open %s failed: %d\n", + printf("can_main: open %s failed: %d\n", CONFIG_EXAMPLES_CAN_DEVPATH, errno); errval = 2; goto errout_with_dev; @@ -198,7 +198,7 @@ int can_main(int argc, char *argv[]) * through the loop. */ - msgflush(); + fflush(stdout); /* Construct the next TX message */ @@ -221,14 +221,14 @@ int can_main(int argc, char *argv[]) nbytes = write(fd, &txmsg, msgsize); if (nbytes != msgsize) { - message("ERROR: write(%ld) returned %ld\n", (long)msgsize, (long)nbytes); + printf("ERROR: write(%ld) returned %ld\n", (long)msgsize, (long)nbytes); errval = 3; goto errout_with_dev; } #endif #ifdef CONFIG_EXAMPLES_CAN_WRITEONLY - message(" ID: %4d DLC: %d\n", msgid, msgdlc); + printf(" ID: %4d DLC: %d\n", msgid, msgdlc); #endif /* Read the RX message */ @@ -238,14 +238,14 @@ int can_main(int argc, char *argv[]) nbytes = read(fd, &rxmsg, msgsize); if (nbytes < CAN_MSGLEN(0) || nbytes > msgsize) { - message("ERROR: read(%ld) returned %ld\n", (long)msgsize, (long)nbytes); + printf("ERROR: read(%ld) returned %ld\n", (long)msgsize, (long)nbytes); errval = 4; goto errout_with_dev; } #endif #ifndef CONFIG_EXAMPLES_CAN_READONLY - message(" ID: %4d DLC: %d\n", rxmsg.cm_hdr.ch_id, rxmsg.cm_hdr.ch_dlc); + printf(" ID: %4d DLC: %d\n", rxmsg.cm_hdr.ch_id, rxmsg.cm_hdr.ch_dlc); #endif /* Verify that the received messages are the same */ @@ -253,7 +253,7 @@ int can_main(int argc, char *argv[]) #ifdef CONFIG_EXAMPLES_CAN_READWRITE if (memcmp(&txmsg.cm_hdr, &rxmsg.cm_hdr, sizeof(struct can_hdr_s)) != 0) { - message("ERROR: Sent header does not match received header:\n"); + printf("ERROR: Sent header does not match received header:\n"); lib_dumpbuffer("Sent header", (FAR const uint8_t*)&txmsg.cm_hdr, sizeof(struct can_hdr_s)); lib_dumpbuffer("Received header", (FAR const uint8_t*)&rxmsg.cm_hdr, @@ -264,10 +264,10 @@ int can_main(int argc, char *argv[]) if (memcmp(txmsg.cm_data, rxmsg.cm_data, msgdlc) != 0) { - message("ERROR: Data does not match. DLC=%d\n", msgdlc); + printf("ERROR: Data does not match. DLC=%d\n", msgdlc); for (i = 0; i < msgdlc; i++) { - message(" %d: TX %02x RX %02x\n", i, txmsg.cm_data[i], rxmsg.cm_data[i]); + printf(" %d: TX %02x RX %02x\n", i, txmsg.cm_data[i], rxmsg.cm_data[i]); errval = 5; goto errout_with_dev; } @@ -275,7 +275,7 @@ int can_main(int argc, char *argv[]) /* Report success */ - message(" ID: %4d DLC: %d -- OK\n", msgid, msgdlc); + printf(" ID: %4d DLC: %d -- OK\n", msgid, msgdlc); #endif /* Set up for the next pass */ @@ -299,7 +299,7 @@ errout_with_dev: close(fd); errout: - message("Terminating!\n"); - msgflush(); + printf("Terminating!\n"); + fflush(stdout); return errval; } diff --git a/apps/examples/configdata/configdata_main.c b/apps/examples/configdata/configdata_main.c index d96129429..5a414e077 100644 --- a/apps/examples/configdata/configdata_main.c +++ b/apps/examples/configdata/configdata_main.c @@ -102,14 +102,6 @@ # define CONFIG_EXAMPLES_CONFIGDATA_VERBOSE 0 #endif -#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_FS) -# define message syslog -# define msgflush() -#else -# define message printf -# define msgflush() fflush(stdout); -#endif - /**************************************************************************** * Private Types ****************************************************************************/ @@ -164,13 +156,13 @@ extern FAR struct mtd_dev_s *configdata_archinitialize(void); static void configdata_showmemusage(struct mallinfo *mmbefore, struct mallinfo *mmafter) { - message("VARIABLE BEFORE AFTER\n"); - message("======== ======== ========\n"); - message("arena %8x %8x\n", mmbefore->arena, mmafter->arena); - message("ordblks %8d %8d\n", mmbefore->ordblks, mmafter->ordblks); - message("mxordblk %8x %8x\n", mmbefore->mxordblk, mmafter->mxordblk); - message("uordblks %8x %8x\n", mmbefore->uordblks, mmafter->uordblks); - message("fordblks %8x %8x\n", mmbefore->fordblks, mmafter->fordblks); + printf("VARIABLE BEFORE AFTER\n"); + printf("======== ======== ========\n"); + printf("arena %8x %8x\n", mmbefore->arena, mmafter->arena); + printf("ordblks %8d %8d\n", mmbefore->ordblks, mmafter->ordblks); + printf("mxordblk %8x %8x\n", mmbefore->mxordblk, mmafter->mxordblk); + printf("uordblks %8x %8x\n", mmbefore->uordblks, mmafter->uordblks); + printf("fordblks %8x %8x\n", mmbefore->fordblks, mmafter->fordblks); } /**************************************************************************** @@ -189,7 +181,7 @@ static void configdata_loopmemusage(void) /* Show the change from the previous loop */ - message("\nEnd of loop memory usage:\n"); + printf("\nEnd of loop memory usage:\n"); configdata_showmemusage(&g_mmprevious, &g_mmafter); /* Set up for the next test */ @@ -212,13 +204,13 @@ static void configdata_endmemusage(void) #else (void)mallinfo(&g_mmafter); #endif - message("\nFinal memory usage:\n"); + printf("\nFinal memory usage:\n"); configdata_showmemusage(&g_mmbefore, &g_mmafter); - message("\nTotal adds: %d Total deletes : %d\n", - g_ntotalalloc, g_ntotaldelete); - message("Total tests: %d Number passed: %d Failed: %d\n", - g_ntests, g_nverified, g_ntests - g_nverified); + printf("\nTotal adds: %d Total deletes : %d\n", + g_ntotalalloc, g_ntotaldelete); + printf("Total tests: %d Number passed: %d Failed: %d\n", + g_ntests, g_nverified, g_ntests - g_nverified); } /**************************************************************************** @@ -349,14 +341,14 @@ static int configdata_fillconfig(void) if (ret < 0) { #if CONFIG_EXAMPLES_CONFIGDATA_VERBOSE != 0 - message(" /dev/config full\n"); + printf(" /dev/config full\n"); #endif return ERROR; } #if CONFIG_EXAMPLES_CONFIGDATA_VERBOSE != 0 - message(" Created entry %04X, %d Len=%d\n", - entry->id, entry->instance, entry->len); + printf(" Created entry %04X, %d Len=%d\n", + entry->id, entry->instance, entry->len); #endif g_nentries++; g_ntotalalloc++; @@ -393,9 +385,9 @@ static inline int configdata_rdentry(FAR struct configdata_entrydesc_s *entry) crc = crc32(g_entryimage, entry->len); if (crc != entry->crc) { - message("ERROR: Bad CRC: %d vs %d\n", crc, entry->crc); - message(" Entry id: %04X\n", entry->id); - message(" Entry size: %d\n", entry->len); + printf("ERROR: Bad CRC: %d vs %d\n", crc, entry->crc); + printf(" Entry id: %04X\n", entry->id); + printf(" Entry size: %d\n", entry->len); return ERROR; } @@ -434,15 +426,15 @@ static int configdata_verifyconfig(void) g_nverified++; #if CONFIG_EXAMPLES_CONFIGDATA_VERBOSE != 0 - message(" Verified delete %04X, %d\n", entry->id, - entry->instance); + printf(" Verified delete %04X, %d\n", entry->id, + entry->instance); #endif } else { - message("ERROR: Failed to read an entry: %d\n", i); - message(" Entry id: %04X\n", entry->id); - message(" Entry size: %d\n", entry->len); + printf("ERROR: Failed to read an entry: %d\n", i); + printf(" Entry id: %04X\n", entry->id); + printf(" Entry size: %d\n", entry->len); err = ERROR; } } @@ -452,16 +444,16 @@ static int configdata_verifyconfig(void) if (entry->deleted) { - message("ERROR: Succesffully read a deleted entry\n"); - message(" Entry id: %04X\n", entry->id); - message(" Entry size: %d\n", entry->len); + printf("ERROR: Succesffully read a deleted entry\n"); + printf(" Entry id: %04X\n", entry->id); + printf(" Entry size: %d\n", entry->len); err = ERROR; } else { g_nverified++; #if CONFIG_EXAMPLES_CONFIGDATA_VERBOSE != 0 - message(" Verifed entry %04X, %d\n", entry->id, entry->instance); + printf(" Verifed entry %04X, %d\n", entry->id, entry->instance); #endif } } @@ -517,15 +509,15 @@ static int configdata_delentries(void) ret = ioctl(g_fd, CFGDIOC_SETCONFIG, (unsigned long) &hdr); if (ret < 0) { - message("ERROR: Delete %d failed: %d\n", i+1, errno); - message(" Entry id: %04X\n", entry->id); - message(" Entry size: %d\n", entry->len); - message(" Entry index: %d\n", j); + printf("ERROR: Delete %d failed: %d\n", i+1, errno); + printf(" Entry id: %04X\n", entry->id); + printf(" Entry size: %d\n", entry->len); + printf(" Entry index: %d\n", j); } else { #if CONFIG_EXAMPLES_CONFIGDATA_VERBOSE != 0 - message(" Deleted entry %04X\n", entry->id); + printf(" Deleted entry %04X\n", entry->id); #endif entry->deleted = true; g_ndeleted++; @@ -597,8 +589,8 @@ static int configdata_cleardeleted(void) /* Move this entry to the deleted entry location */ #if CONFIG_EXAMPLES_CONFIGDATA_VERBOSE != 0 - message(" Overwrite entry %d, OLD=%04X NEW=%04X\n", - nextdeleted, g_entries[nextdeleted].id, g_entries[x].id); + printf(" Overwrite entry %d, OLD=%04X NEW=%04X\n", + nextdeleted, g_entries[nextdeleted].id, g_entries[x].id); #endif g_entries[nextdeleted] = g_entries[x]; @@ -644,28 +636,28 @@ int configdata_main(int argc, char *argv[]) mtd = configdata_archinitialize(); #else #if CONFIG_EXAMPLES_CONFIGDATA_VERBOSE != 0 - message("Creating %d byte RAM drive\n", EXAMPLES_CONFIGDATA_BUFSIZE); + printf("Creating %d byte RAM drive\n", EXAMPLES_CONFIGDATA_BUFSIZE); #endif mtd = rammtd_initialize(g_simflash, EXAMPLES_CONFIGDATA_BUFSIZE); #endif if (!mtd) { - message("ERROR: Failed to create RAM MTD instance\n"); - msgflush(); + printf("ERROR: Failed to create RAM MTD instance\n"); + fflush(stdout); exit(1); } /* Initialize to provide CONFIGDATA on an MTD interface */ #if CONFIG_EXAMPLES_CONFIGDATA_VERBOSE != 0 - message("Registering /dev/config device\n"); + printf("Registering /dev/config device\n"); #endif MTD_IOCTL(mtd, MTDIOC_BULKERASE, 0); ret = mtdconfig_register(mtd); if (ret < 0) { - message("ERROR: /dev/config registration failed: %d\n", -ret); - msgflush(); + printf("ERROR: /dev/config registration failed: %d\n", -ret); + fflush(stdout); exit(2); } @@ -678,8 +670,8 @@ int configdata_main(int argc, char *argv[]) g_fd = open("/dev/config", O_RDOK); if (g_fd == -1) { - message("ERROR: Failed to open /dev/config %d\n", -errno); - msgflush(); + printf("ERROR: Failed to open /dev/config %d\n", -errno); + fflush(stdout); exit(2); } @@ -710,12 +702,12 @@ int configdata_main(int argc, char *argv[]) */ #ifndef CONFIG_EXAMPLES_CONFIGDATA_SILENT - message("\n=== FILLING %u =============================\n", i); + printf("\n=== FILLING %u =============================\n", i); #endif (void)configdata_fillconfig(); #ifndef CONFIG_EXAMPLES_CONFIGDATA_SILENT - message("Filled /dev/config\n"); - message(" Number of entries: %d\n", g_nentries); + printf("Filled /dev/config\n"); + printf(" Number of entries: %d\n", g_nentries); #endif /* Verify all files entries to FLASH */ @@ -723,15 +715,15 @@ int configdata_main(int argc, char *argv[]) ret = configdata_verifyconfig(); if (ret < 0) { - message("ERROR: Failed to verify partition\n"); - message(" Number of entries: %d\n", g_nentries); + printf("ERROR: Failed to verify partition\n"); + printf(" Number of entries: %d\n", g_nentries); } else { #ifndef CONFIG_EXAMPLES_CONFIGDATA_SILENT #if CONFIG_EXAMPLES_CONFIGDATA_VERBOSE != 0 - message("Verified!\n"); - message(" Number of entries: %d\n", g_nentries); + printf("Verified!\n"); + printf(" Number of entries: %d\n", g_nentries); #endif #endif } @@ -739,21 +731,21 @@ int configdata_main(int argc, char *argv[]) /* Delete some entries */ #ifndef CONFIG_EXAMPLES_CONFIGDATA_SILENT - message("\n=== DELETING %u ============================\n", i); + printf("\n=== DELETING %u ============================\n", i); #endif ret = configdata_delentries(); if (ret < 0) { - message("ERROR: Failed to delete enries\n"); - message(" Number of entries: %d\n", g_nentries); - message(" Number deleted: %d\n", g_ndeleted); + printf("ERROR: Failed to delete enries\n"); + printf(" Number of entries: %d\n", g_nentries); + printf(" Number deleted: %d\n", g_ndeleted); } else { #ifndef CONFIG_EXAMPLES_CONFIGDATA_SILENT - message("Deleted some enries\n"); - message(" Number of entries: %d\n", g_nentries); - message(" Number deleted: %d\n", g_ndeleted); + printf("Deleted some enries\n"); + printf(" Number of entries: %d\n", g_nentries); + printf(" Number deleted: %d\n", g_ndeleted); #endif } @@ -762,17 +754,17 @@ int configdata_main(int argc, char *argv[]) ret = configdata_verifyconfig(); if (ret < 0) { - message("ERROR: Failed to verify partition\n"); - message(" Number of entries: %d\n", g_nentries); - message(" Number deleted: %d\n", g_ndeleted); + printf("ERROR: Failed to verify partition\n"); + printf(" Number of entries: %d\n", g_nentries); + printf(" Number deleted: %d\n", g_ndeleted); } else { #ifndef CONFIG_EXAMPLES_CONFIGDATA_SILENT #if CONFIG_EXAMPLES_CONFIGDATA_VERBOSE != 0 - message("Verified!\n"); - message(" Number of entries: %d\n", g_nentries); - message(" Number deleted: %d\n", g_ndeleted); + printf("Verified!\n"); + printf(" Number of entries: %d\n", g_nentries); + printf(" Number deleted: %d\n", g_ndeleted); #endif #endif } @@ -785,12 +777,12 @@ int configdata_main(int argc, char *argv[]) #ifndef CONFIG_EXAMPLES_CONFIGDATA_SILENT configdata_loopmemusage(); - msgflush(); + fflush(stdout); #else if ((i % EXAMPLES_CONFIGDATA_REPORT) == 0) { - message("%u\n", i); - msgflush(); + printf("%u\n", i); + fflush(stdout); } #endif } @@ -799,6 +791,6 @@ int configdata_main(int argc, char *argv[]) //configdata_delallfiles(); configdata_endmemusage(); - msgflush(); + fflush(stdout); return 0; } diff --git a/apps/examples/i2schar/i2schar.h b/apps/examples/i2schar/i2schar.h index 9596f7dc4..53ba1d9c5 100644 --- a/apps/examples/i2schar/i2schar.h +++ b/apps/examples/i2schar/i2schar.h @@ -89,26 +89,6 @@ # efine CONFIG_EXAMPLES_I2SCHAR_BUFSIZE 256 #endif -/* Debug ********************************************************************/ - -#ifdef CONFIG_CPP_HAVE_VARARGS -# ifdef CONFIG_DEBUG -# define message(...) syslog(__VA_ARGS__) -# define msgflush() -# else -# define message(...) printf(__VA_ARGS__) -# define msgflush() fflush(stdout) -# endif -#else -# ifdef CONFIG_DEBUG -# define message syslog -# define msgflush() -# else -# define message printf -# define msgflush() fflush(stdout) -# endif -#endif - /**************************************************************************** * Public Types ****************************************************************************/ diff --git a/apps/examples/i2schar/i2schar_main.c b/apps/examples/i2schar/i2schar_main.c index b86e5c4e6..fe98a4275 100644 --- a/apps/examples/i2schar/i2schar_main.c +++ b/apps/examples/i2schar/i2schar_main.c @@ -102,24 +102,24 @@ static void i2schar_devpath(FAR struct i2schar_state_s *i2schar, #ifdef CONFIG_NSH_BUILTIN_APPS static void i2schar_help(FAR struct i2schar_state_s *i2schar) { - message("Usage: i2schar [OPTIONS]\n"); - message("\nArguments are \"sticky\". For example, once the I2C character device is\n"); - message("specified, that device will be re-used until it is changed.\n"); - message("\n\"sticky\" OPTIONS include:\n"); - message(" [-p devpath] selects the I2C character device path. " + printf("Usage: i2schar [OPTIONS]\n"); + printf("\nArguments are \"sticky\". For example, once the I2C character device is\n"); + printf("specified, that device will be re-used until it is changed.\n"); + printf("\n\"sticky\" OPTIONS include:\n"); + printf(" [-p devpath] selects the I2C character device path. " "Default: %s Current: %s\n", CONFIG_EXAMPLES_I2SCHAR_DEVPATH, g_i2schar.devpath ? g_i2schar.devpath : "NONE"); #ifdef CONFIG_EXAMPLES_I2SCHAR_TX - message(" [-t count] selects the number of audio buffers to send. " + printf(" [-t count] selects the number of audio buffers to send. " "Default: %d Current: %d\n", CONFIG_EXAMPLES_I2SCHAR_TXBUFFERS, i2schar->txcount); #endif #ifdef CONFIG_EXAMPLES_I2SCHAR_TX - message(" [-r count] selects the number of audio buffers to receive. " + printf(" [-r count] selects the number of audio buffers to receive. " "Default: %d Current: %d\n", CONFIG_EXAMPLES_I2SCHAR_RXBUFFERS, i2schar->txcount); #endif - message(" [-h] shows this message and exits\n"); + printf(" [-h] shows this message and exits\n"); } #endif @@ -179,7 +179,7 @@ static void parse_args(FAR struct i2schar_state_s *i2schar, int argc, FAR char * ptr = argv[index]; if (ptr[0] != '-') { - message("Invalid options format: %s\n", ptr); + printf("Invalid options format: %s\n", ptr); exit(0); } @@ -195,7 +195,7 @@ static void parse_args(FAR struct i2schar_state_s *i2schar, int argc, FAR char * nargs = arg_decimal(&argv[index], &value); if (value < 0) { - message("Count must be non-negative: %ld\n", value); + printf("Count must be non-negative: %ld\n", value); exit(1); } @@ -207,7 +207,7 @@ static void parse_args(FAR struct i2schar_state_s *i2schar, int argc, FAR char * nargs = arg_decimal(&argv[index], &value); if (value < 0) { - message("Count must be non-negative: %ld\n", value); + printf("Count must be non-negative: %ld\n", value); exit(1); } @@ -220,7 +220,7 @@ static void parse_args(FAR struct i2schar_state_s *i2schar, int argc, FAR char * exit(0); default: - message("Unsupported option: %s\n", ptr); + printf("Unsupported option: %s\n", ptr); i2schar_help(i2schar); exit(1); } @@ -264,11 +264,11 @@ int i2schar_main(int argc, char *argv[]) * external to this test. */ - message("i2schar_main: Initializing external I2C character device\n"); + printf("i2schar_main: Initializing external I2C character device\n"); ret = i2schar_devinit(); if (ret != OK) { - message("i2schar_main: i2schar_devinit failed: %d\n", ret); + printf("i2schar_main: i2schar_devinit failed: %d\n", ret); return EXIT_FAILURE; } #endif @@ -296,7 +296,7 @@ int i2schar_main(int argc, char *argv[]) #ifdef CONFIG_EXAMPLES_I2SCHAR_RX /* Start the receiver thread */ - message("i2schar_main: Start receiver thread\n"); + printf("i2schar_main: Start receiver thread\n"); pthread_attr_init(&attr); #ifdef CONFIG_EXAMPLES_I2SCHAR_TX @@ -321,7 +321,7 @@ int i2schar_main(int argc, char *argv[]) if (ret != OK) { sched_unlock(); - message("i2schar_main: ERROR: failed to Start receiver thread: %d\n", ret); + printf("i2schar_main: ERROR: failed to Start receiver thread: %d\n", ret); return EXIT_FAILURE; } @@ -331,7 +331,7 @@ int i2schar_main(int argc, char *argv[]) #ifdef CONFIG_EXAMPLES_I2SCHAR_TX /* Start the transmitter thread */ - message("i2schar_main: Start transmitter thread\n"); + printf("i2schar_main: Start transmitter thread\n"); pthread_attr_init(&attr); /* Set the transmitter stack size */ @@ -344,9 +344,9 @@ int i2schar_main(int argc, char *argv[]) if (ret != OK) { sched_unlock(); - message("i2schar_main: ERROR: failed to Start transmitter thread: %d\n", ret); + printf("i2schar_main: ERROR: failed to Start transmitter thread: %d\n", ret); #ifdef CONFIG_EXAMPLES_I2SCHAR_RX - message("i2schar_main: Waiting for the receiver thread\n"); + printf("i2schar_main: Waiting for the receiver thread\n"); (void)pthread_join(receiver, &result); #endif return EXIT_FAILURE; @@ -357,20 +357,20 @@ int i2schar_main(int argc, char *argv[]) sched_unlock(); #ifdef CONFIG_EXAMPLES_I2SCHAR_TX - message("i2schar_main: Waiting for the transmitter thread\n"); + printf("i2schar_main: Waiting for the transmitter thread\n"); ret = pthread_join(transmitter, &result); if (ret != OK) { - message("i2schar_main: ERROR: pthread_join failed: %d\n", ret); + printf("i2schar_main: ERROR: pthread_join failed: %d\n", ret); } #endif #ifdef CONFIG_EXAMPLES_I2SCHAR_RX - message("i2schar_main: Waiting for the receiver thread\n"); + printf("i2schar_main: Waiting for the receiver thread\n"); ret = pthread_join(receiver, &result); if (ret != OK) { - message("i2schar_main: ERROR: pthread_join failed: %d\n", ret); + printf("i2schar_main: ERROR: pthread_join failed: %d\n", ret); } #endif diff --git a/apps/examples/i2schar/i2schar_receiver.c b/apps/examples/i2schar/i2schar_receiver.c index 4575fd109..a808e2a02 100644 --- a/apps/examples/i2schar/i2schar_receiver.c +++ b/apps/examples/i2schar/i2schar_receiver.c @@ -104,7 +104,7 @@ pthread_addr_t i2schar_receiver(pthread_addr_t arg) if (fd < 0) { int errcode = errno; - message("i2schar_receiver: ERROR: failed to open %s: %d\n", + printf("i2schar_receiver: ERROR: failed to open %s: %d\n", g_i2schar.devpath, errcode); pthread_exit(NULL); } @@ -121,7 +121,7 @@ pthread_addr_t i2schar_receiver(pthread_addr_t arg) ret = apb_alloc(&desc); if (ret < 0) { - message("i2schar_receiver: ERROR: failed to allocate buffer %d: %d\n", + printf("i2schar_receiver: ERROR: failed to allocate buffer %d: %d\n", i+1, ret); close(fd); pthread_exit(NULL); @@ -135,7 +135,7 @@ pthread_addr_t i2schar_receiver(pthread_addr_t arg) { /* Flush any output before reading */ - msgflush(); + fflush(stdout); /* Read the buffer to the I2S character driver */ @@ -145,7 +145,7 @@ pthread_addr_t i2schar_receiver(pthread_addr_t arg) int errcode = errno; if (errcode != EINTR) { - message("i2schar_receiver: ERROR: read failed: %d\n", + printf("i2schar_receiver: ERROR: read failed: %d\n", errcode); close(fd); pthread_exit(NULL); @@ -153,14 +153,14 @@ pthread_addr_t i2schar_receiver(pthread_addr_t arg) } else if (nread != bufsize) { - message("i2schar_receiver: ERROR: partial read: %d\n", + printf("i2schar_receiver: ERROR: partial read: %d\n", nread); close(fd); pthread_exit(NULL); } else { - message("i2schar_receiver: Received buffer %d\n", i+1); + printf("i2schar_receiver: Received buffer %d\n", i+1); } } while (nread != bufsize); diff --git a/apps/examples/i2schar/i2schar_transmitter.c b/apps/examples/i2schar/i2schar_transmitter.c index 8170c2956..31c17f488 100644 --- a/apps/examples/i2schar/i2schar_transmitter.c +++ b/apps/examples/i2schar/i2schar_transmitter.c @@ -107,7 +107,7 @@ pthread_addr_t i2schar_transmitter(pthread_addr_t arg) if (fd < 0) { int errcode = errno; - message("i2schar_transmitter: ERROR: failed to open %s: %d\n", + printf("i2schar_transmitter: ERROR: failed to open %s: %d\n", g_i2schar.devpath, errcode); pthread_exit(NULL); } @@ -124,7 +124,7 @@ pthread_addr_t i2schar_transmitter(pthread_addr_t arg) ret = apb_alloc(&desc); if (ret < 0) { - message("i2schar_transmitter: ERROR: failed to allocate buffer %d: %d\n", + printf("i2schar_transmitter: ERROR: failed to allocate buffer %d: %d\n", i+1, ret); close(fd); pthread_exit(NULL); @@ -147,7 +147,7 @@ pthread_addr_t i2schar_transmitter(pthread_addr_t arg) { /* Flush any output before writing */ - msgflush(); + fflush(stdout); /* Write the buffer to the I2S character driver */ @@ -157,7 +157,7 @@ pthread_addr_t i2schar_transmitter(pthread_addr_t arg) int errcode = errno; if (errcode != EINTR) { - message("i2schar_transmitter: ERROR: write failed: %d\n", + printf("i2schar_transmitter: ERROR: write failed: %d\n", errcode); close(fd); pthread_exit(NULL); @@ -165,14 +165,14 @@ pthread_addr_t i2schar_transmitter(pthread_addr_t arg) } else if (nwritten != bufsize) { - message("i2schar_transmitter: ERROR: partial write: %d\n", + printf("i2schar_transmitter: ERROR: partial write: %d\n", nwritten); close(fd); pthread_exit(NULL); } else { - message("i2schar_transmitter: Send buffer %d\n", i+1); + printf("i2schar_transmitter: Send buffer %d\n", i+1); } } while (nwritten != bufsize); diff --git a/apps/examples/igmp/igmp.c b/apps/examples/igmp/igmp.c index c8d7cdb87..32879f046 100644 --- a/apps/examples/igmp/igmp.c +++ b/apps/examples/igmp/igmp.c @@ -94,7 +94,7 @@ int igmp_main(int argc, char *argv[]) uint8_t mac[IFHWADDRLEN]; #endif - message("Configuring Ethernet...\n"); + printf("Configuring Ethernet...\n"); /* Many embedded network interfaces must have a software assigned MAC */ @@ -126,23 +126,23 @@ int igmp_main(int argc, char *argv[]) /* Not much of a test for now */ /* Join the group */ - message("Join group...\n"); + printf("Join group...\n"); addr.s_addr = HTONL(CONFIG_EXAMPLES_IGMP_GRPADDR); ipmsfilter("eth0", &addr, MCAST_INCLUDE); /* Wait a while */ - message("Wait for timeout...\n"); + printf("Wait for timeout...\n"); sleep(5); /* Leave the group */ - message("Leave group...\n"); + printf("Leave group...\n"); ipmsfilter("eth0", &addr, MCAST_EXCLUDE); /* Wait a while */ sleep(5); - message("Exiting...\n"); + printf("Exiting...\n"); return 0; } diff --git a/apps/examples/igmp/igmp.h b/apps/examples/igmp/igmp.h index 5e1fa8d95..284f5288c 100644 --- a/apps/examples/igmp/igmp.h +++ b/apps/examples/igmp/igmp.h @@ -43,17 +43,9 @@ #include <debug.h> /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ -/* Used syslog() so that there is no confusion from buffered IO */ - -#ifdef CONFIG_CPP_HAVE_VARARGS -# define message(...) syslog(__VA_ARGS__) -#else -# define message syslog -#endif - /**************************************************************************** * Public Function Prototypes ****************************************************************************/ diff --git a/apps/examples/mtdpart/mtdpart_main.c b/apps/examples/mtdpart/mtdpart_main.c index 48a56668f..620b3608b 100644 --- a/apps/examples/mtdpart/mtdpart_main.c +++ b/apps/examples/mtdpart/mtdpart_main.c @@ -98,15 +98,6 @@ # define CONFIG_EXAMPLES_MTDPART_NPARTITIONS 3 #endif -/* Debug ********************************************************************/ -#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_FS) -# define message syslog -# define msgflush() -#else -# define message printf -# define msgflush() fflush(stdout); -#endif - /**************************************************************************** * Private Types ****************************************************************************/ @@ -183,8 +174,8 @@ int mtdpart_main(int argc, char *argv[]) #endif if (!master) { - message("ERROR: Failed to create RAM MTD instance\n"); - msgflush(); + printf("ERROR: Failed to create RAM MTD instance\n"); + fflush(stdout); exit(1); } @@ -193,7 +184,7 @@ int mtdpart_main(int argc, char *argv[]) ret = master->ioctl(master, MTDIOC_BULKERASE, 0); if (ret < 0) { - message("ERROR: MTDIOC_BULKERASE ioctl failed: %d\n", ret); + printf("ERROR: MTDIOC_BULKERASE ioctl failed: %d\n", ret); } /* Initialize to provide an FTL block driver on the MTD FLASH interface. @@ -207,8 +198,8 @@ int mtdpart_main(int argc, char *argv[]) ret = ftl_initialize(0, master); if (ret < 0) { - message("ERROR: ftl_initialize /dev/mtdblock0 failed: %d\n", ret); - msgflush(); + printf("ERROR: ftl_initialize /dev/mtdblock0 failed: %d\n", ret); + fflush(stdout); exit(2); } @@ -217,8 +208,8 @@ int mtdpart_main(int argc, char *argv[]) ret = bchdev_register("/dev/mtdblock0", "/dev/mtd0", false); if (ret < 0) { - message("ERROR: bchdev_register /dev/mtd0 failed: %d\n", ret); - msgflush(); + printf("ERROR: bchdev_register /dev/mtd0 failed: %d\n", ret); + fflush(stdout); exit(3); } @@ -231,10 +222,10 @@ int mtdpart_main(int argc, char *argv[]) exit(3); } - message("Flash Geometry:\n"); - message(" blocksize: %lu\n", (unsigned long)geo.blocksize); - message(" erasesize: %lu\n", (unsigned long)geo.erasesize); - message(" neraseblocks: %lu\n", (unsigned long)geo.neraseblocks); + printf("Flash Geometry:\n"); + printf(" blocksize: %lu\n", (unsigned long)geo.blocksize); + printf(" erasesize: %lu\n", (unsigned long)geo.erasesize); + printf(" neraseblocks: %lu\n", (unsigned long)geo.neraseblocks); /* Determine the size of each partition. Make each partition an even * multiple of the erase block size (perhaps not using some space at the @@ -245,28 +236,28 @@ int mtdpart_main(int argc, char *argv[]) nblocks = (geo.neraseblocks / CONFIG_EXAMPLES_MTDPART_NPARTITIONS) * blkpererase; partsize = nblocks * geo.blocksize; - message(" No. partitions: %u\n", CONFIG_EXAMPLES_MTDPART_NPARTITIONS); - message(" Partition size: %lu Blocks (%lu bytes)\n", nblocks, partsize); + printf(" No. partitions: %u\n", CONFIG_EXAMPLES_MTDPART_NPARTITIONS); + printf(" Partition size: %lu Blocks (%lu bytes)\n", nblocks, partsize); /* Now create MTD FLASH partitions */ - message("Creating partitions\n"); + printf("Creating partitions\n"); for (offset = 0, i = 1; i <= CONFIG_EXAMPLES_MTDPART_NPARTITIONS; offset += nblocks, i++) { - message(" Partition %d. Block offset=%lu, size=%lu\n", - i, (unsigned long)offset, (unsigned long)nblocks); + printf(" Partition %d. Block offset=%lu, size=%lu\n", + i, (unsigned long)offset, (unsigned long)nblocks); /* Create the partition */ part[i] = mtd_partition(master, offset, nblocks); if (!part[i]) { - message("ERROR: mtd_partition failed. offset=%lu nblocks=%lu\n", - (unsigned long)offset, (unsigned long)nblocks); - msgflush(); + printf("ERROR: mtd_partition failed. offset=%lu nblocks=%lu\n", + (unsigned long)offset, (unsigned long)nblocks); + fflush(stdout); exit(4); } @@ -278,8 +269,8 @@ int mtdpart_main(int argc, char *argv[]) ret = ftl_initialize(i, part[i]); if (ret < 0) { - message("ERROR: ftl_initialize %s failed: %d\n", blockname, ret); - msgflush(); + printf("ERROR: ftl_initialize %s failed: %d\n", blockname, ret); + fflush(stdout); exit(5); } @@ -288,8 +279,8 @@ int mtdpart_main(int argc, char *argv[]) ret = bchdev_register(blockname, charname, false); if (ret < 0) { - message("ERROR: bchdev_register %s failed: %d\n", charname, ret); - msgflush(); + printf("ERROR: bchdev_register %s failed: %d\n", charname, ret); + fflush(stdout); exit(6); } } @@ -299,8 +290,8 @@ int mtdpart_main(int argc, char *argv[]) buffer = (FAR uint32_t *)malloc(geo.blocksize); if (!buffer) { - message("ERROR: failed to allocate a sector buffer\n"); - msgflush(); + printf("ERROR: failed to allocate a sector buffer\n"); + fflush(stdout); exit(7); } @@ -309,14 +300,14 @@ int mtdpart_main(int argc, char *argv[]) fd = open("/dev/mtd0", O_WRONLY); if (fd < 0) { - message("ERROR: open /dev/mtd0 failed: %d\n", errno); - msgflush(); + printf("ERROR: open /dev/mtd0 failed: %d\n", errno); + fflush(stdout); exit(8); } /* Now write the offset into every block */ - message("Initializing media:\n"); + printf("Initializing media:\n"); offset = 0; for (i = 0; i < geo.neraseblocks; i++) @@ -336,8 +327,8 @@ int mtdpart_main(int argc, char *argv[]) nbytes = write(fd, buffer, geo.blocksize); if (nbytes < 0) { - message("ERROR: write to /dev/mtd0 failed: %d\n", errno); - msgflush(); + printf("ERROR: write to /dev/mtd0 failed: %d\n", errno); + fflush(stdout); exit(9); } } @@ -347,14 +338,14 @@ int mtdpart_main(int argc, char *argv[]) /* Now read each partition */ - message("Checking partitions:\n"); + printf("Checking partitions:\n"); for (offset = 0, i = 1; i <= CONFIG_EXAMPLES_MTDPART_NPARTITIONS; offset += partsize, i++) { - message(" Partition %d. Byte offset=%lu, size=%lu\n", - i, (unsigned long)offset, (unsigned long)partsize); + printf(" Partition %d. Byte offset=%lu, size=%lu\n", + i, (unsigned long)offset, (unsigned long)partsize); /* Open the master MTD partition character driver for writing */ @@ -362,8 +353,8 @@ int mtdpart_main(int argc, char *argv[]) fd = open(charname, O_RDWR); if (fd < 0) { - message("ERROR: open %s failed: %d\n", charname, errno); - msgflush(); + printf("ERROR: open %s failed: %d\n", charname, errno); + fflush(stdout); exit(10); } @@ -375,16 +366,16 @@ int mtdpart_main(int argc, char *argv[]) for (j = 0; j < nblocks; j++) { #if 0 /* Too much */ - message(" block=%u offset=%lu\n", j, (unsigned long) check); + printf(" block=%u offset=%lu\n", j, (unsigned long) check); #endif /* Seek to the next read position */ seekpos = lseek(fd, sectoff, SEEK_SET); if (seekpos != sectoff) { - message("ERROR: lseek to offset %ld failed: %d\n", - (unsigned long)sectoff, errno); - msgflush(); + printf("ERROR: lseek to offset %ld failed: %d\n", + (unsigned long)sectoff, errno); + fflush(stdout); exit(11); } @@ -393,21 +384,21 @@ int mtdpart_main(int argc, char *argv[]) nbytes = read(fd, buffer, geo.blocksize); if (nbytes < 0) { - message("ERROR: read from %s failed: %d\n", charname, errno); - msgflush(); + printf("ERROR: read from %s failed: %d\n", charname, errno); + fflush(stdout); exit(12); } else if (nbytes == 0) { - message("ERROR: Unexpected end-of file in %s\n", charname); - msgflush(); + printf("ERROR: Unexpected end-of file in %s\n", charname); + fflush(stdout); exit(13); } else if (nbytes != geo.blocksize) { - message("ERROR: Unexpected read size from %s: %ld\n", - charname, (unsigned long)nbytes); - msgflush(); + printf("ERROR: Unexpected read size from %s: %ld\n", + charname, (unsigned long)nbytes); + fflush(stdout); exit(14); } @@ -418,8 +409,8 @@ int mtdpart_main(int argc, char *argv[]) else if (nbytes == 0) { - message("ERROR: Unexpected end of file on %s\n", charname); - msgflush(); + printf("ERROR: Unexpected end of file on %s\n", charname); + fflush(stdout); exit(15); } @@ -427,9 +418,9 @@ int mtdpart_main(int argc, char *argv[]) else if (nbytes != geo.blocksize) { - message("ERROR: Short read from %s failed: %lu\n", - charname, (unsigned long)nbytes); - msgflush(); + printf("ERROR: Short read from %s failed: %lu\n", + charname, (unsigned long)nbytes); + fflush(stdout); exit(16); } @@ -439,9 +430,9 @@ int mtdpart_main(int argc, char *argv[]) { if (buffer[k] != check) { - message("ERROR: Bad offset %lu, expected %lu\n", - (long)buffer[k], (long)check); - msgflush(); + printf("ERROR: Bad offset %lu, expected %lu\n", + (long)buffer[k], (long)check); + fflush(stdout); exit(17); } @@ -458,9 +449,9 @@ int mtdpart_main(int argc, char *argv[]) seekpos = lseek(fd, sectoff, SEEK_SET); if (seekpos != sectoff) { - message("ERROR: lseek to offset %ld failed: %d\n", - (unsigned long)sectoff, errno); - msgflush(); + printf("ERROR: lseek to offset %ld failed: %d\n", + (unsigned long)sectoff, errno); + fflush(stdout); exit(18); } @@ -469,15 +460,15 @@ int mtdpart_main(int argc, char *argv[]) nbytes = write(fd, buffer, geo.blocksize); if (nbytes < 0) { - message("ERROR: write to %s failed: %d\n", charname, errno); - msgflush(); + printf("ERROR: write to %s failed: %d\n", charname, errno); + fflush(stdout); exit(19); } else if (nbytes != geo.blocksize) { - message("ERROR: Unexpected write size to %s: %ld\n", - charname, (unsigned long)nbytes); - msgflush(); + printf("ERROR: Unexpected write size to %s: %ld\n", + charname, (unsigned long)nbytes); + fflush(stdout); exit(20); } @@ -491,9 +482,9 @@ int mtdpart_main(int argc, char *argv[]) nbytes = read(fd, buffer, geo.blocksize); if (nbytes != 0) { - message("ERROR: Expected end-of-file from %s failed: %d %d\n", - charname, nbytes, errno); - msgflush(); + printf("ERROR: Expected end-of-file from %s failed: %d %d\n", + charname, nbytes, errno); + fflush(stdout); exit(22); } @@ -504,13 +495,13 @@ int mtdpart_main(int argc, char *argv[]) * should on the device. */ - message("Verfying media:\n"); + printf("Verfying media:\n"); fd = open("/dev/mtd0", O_RDONLY); if (fd < 0) { - message("ERROR: open /dev/mtd0 failed: %d\n", errno); - msgflush(); + printf("ERROR: open /dev/mtd0 failed: %d\n", errno); + fflush(stdout); exit(23); } @@ -524,21 +515,21 @@ int mtdpart_main(int argc, char *argv[]) nbytes = read(fd, buffer, geo.blocksize); if (nbytes < 0) { - message("ERROR: read from %s failed: %d\n", charname, errno); - msgflush(); + printf("ERROR: read from %s failed: %d\n", charname, errno); + fflush(stdout); exit(24); } else if (nbytes == 0) { - message("ERROR: Unexpected end-of file in %s\n", charname); - msgflush(); + printf("ERROR: Unexpected end-of file in %s\n", charname); + fflush(stdout); exit(25); } else if (nbytes != geo.blocksize) { - message("ERROR: Unexpected read size from %s: %ld\n", - charname, (unsigned long)nbytes); - msgflush(); + printf("ERROR: Unexpected read size from %s: %ld\n", + charname, (unsigned long)nbytes); + fflush(stdout); exit(26); } @@ -548,9 +539,9 @@ int mtdpart_main(int argc, char *argv[]) { if (buffer[k] != ~check) { - message("ERROR: Bad value %lu, expected %lu\n", - (long)buffer[k], (long)(~check)); - msgflush(); + printf("ERROR: Bad value %lu, expected %lu\n", + (long)buffer[k], (long)(~check)); + fflush(stdout); exit(27); } @@ -562,8 +553,8 @@ int mtdpart_main(int argc, char *argv[]) /* And exit without bothering to clean up */ - message("PASS: Everything looks good\n"); - msgflush(); + printf("PASS: Everything looks good\n"); + fflush(stdout); return 0; } diff --git a/apps/examples/mtdrwb/mtdrwb_main.c b/apps/examples/mtdrwb/mtdrwb_main.c index 21cb91a0c..1980f6220 100644 --- a/apps/examples/mtdrwb/mtdrwb_main.c +++ b/apps/examples/mtdrwb/mtdrwb_main.c @@ -95,15 +95,6 @@ #endif -/* Debug ********************************************************************/ -#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_FS) -# define message syslog -# define msgflush() -#else -# define message printf -# define msgflush() fflush(stdout); -#endif - /**************************************************************************** * Private Types ****************************************************************************/ @@ -175,8 +166,8 @@ int mtdrwb_main(int argc, char *argv[]) #endif if (!mtdraw) { - message("ERROR: Failed to create RAM MTD instance\n"); - msgflush(); + printf("ERROR: Failed to create RAM MTD instance\n"); + fflush(stdout); exit(1); } @@ -185,7 +176,7 @@ int mtdrwb_main(int argc, char *argv[]) ret = mtdraw->ioctl(mtdraw, MTDIOC_BULKERASE, 0); if (ret < 0) { - message("ERROR: MTDIOC_BULKERASE ioctl failed: %d\n", ret); + printf("ERROR: MTDIOC_BULKERASE ioctl failed: %d\n", ret); } /* Initialize to support buffering on the MTD device */ @@ -193,8 +184,8 @@ int mtdrwb_main(int argc, char *argv[]) mtdrwb = mtd_rwb_initialize(mtdraw); if (!mtdrwb) { - message("ERROR: Failed to create RAM MTD R/W buffering\n"); - msgflush(); + printf("ERROR: Failed to create RAM MTD R/W buffering\n"); + fflush(stdout); exit(2); } @@ -209,8 +200,8 @@ int mtdrwb_main(int argc, char *argv[]) ret = ftl_initialize(0, mtdrwb); if (ret < 0) { - message("ERROR: ftl_initialize /dev/mtdblock0 failed: %d\n", ret); - msgflush(); + printf("ERROR: ftl_initialize /dev/mtdblock0 failed: %d\n", ret); + fflush(stdout); exit(3); } @@ -219,8 +210,8 @@ int mtdrwb_main(int argc, char *argv[]) ret = bchdev_register("/dev/mtdblock0", "/dev/mtd0", false); if (ret < 0) { - message("ERROR: bchdev_register /dev/mtd0 failed: %d\n", ret); - msgflush(); + printf("ERROR: bchdev_register /dev/mtd0 failed: %d\n", ret); + fflush(stdout); exit(4); } @@ -233,24 +224,24 @@ int mtdrwb_main(int argc, char *argv[]) exit(5); } - message("Flash Geometry:\n"); - message(" blocksize: %lu\n", (unsigned long)geo.blocksize); - message(" erasesize: %lu\n", (unsigned long)geo.erasesize); - message(" neraseblocks: %lu\n", (unsigned long)geo.neraseblocks); + printf("Flash Geometry:\n"); + printf(" blocksize: %lu\n", (unsigned long)geo.blocksize); + printf(" erasesize: %lu\n", (unsigned long)geo.erasesize); + printf(" neraseblocks: %lu\n", (unsigned long)geo.neraseblocks); blkpererase = geo.erasesize / geo.blocksize; - message(" blkpererase: %u\n", blkpererase); + printf(" blkpererase: %u\n", blkpererase); nblocks = geo.neraseblocks * blkpererase; - message(" nblocks: %lu\n", (unsigned long)nblocks); + printf(" nblocks: %lu\n", (unsigned long)nblocks); /* Allocate a buffer */ buffer = (FAR uint32_t *)malloc(geo.blocksize); if (!buffer) { - message("ERROR: failed to allocate a sector buffer\n"); - msgflush(); + printf("ERROR: failed to allocate a sector buffer\n"); + fflush(stdout); exit(6); } @@ -259,14 +250,14 @@ int mtdrwb_main(int argc, char *argv[]) fd = open("/dev/mtd0", O_WRONLY); if (fd < 0) { - message("ERROR: open /dev/mtd0 failed: %d\n", errno); - msgflush(); + printf("ERROR: open /dev/mtd0 failed: %d\n", errno); + fflush(stdout); exit(7); } /* Now write the offset into every block */ - message("Initializing media:\n"); + printf("Initializing media:\n"); offset = 0; for (i = 0; i < geo.neraseblocks; i++) @@ -286,8 +277,8 @@ int mtdrwb_main(int argc, char *argv[]) nbytes = write(fd, buffer, geo.blocksize); if (nbytes < 0) { - message("ERROR: write to /dev/mtd0 failed: %d\n", errno); - msgflush(); + printf("ERROR: write to /dev/mtd0 failed: %d\n", errno); + fflush(stdout); exit(8); } } @@ -300,8 +291,8 @@ int mtdrwb_main(int argc, char *argv[]) fd = open("/dev/mtd0", O_RDONLY); if (fd < 0) { - message("ERROR: open /dev/mtd0 failed: %d\n", errno); - msgflush(); + printf("ERROR: open /dev/mtd0 failed: %d\n", errno); + fflush(stdout); exit(9); } @@ -315,9 +306,9 @@ int mtdrwb_main(int argc, char *argv[]) seekpos = lseek(fd, offset, SEEK_SET); if (seekpos != offset) { - message("ERROR: lseek to offset %ld failed: %d\n", - (unsigned long)offset, errno); - msgflush(); + printf("ERROR: lseek to offset %ld failed: %d\n", + (unsigned long)offset, errno); + fflush(stdout); exit(10); } @@ -326,21 +317,21 @@ int mtdrwb_main(int argc, char *argv[]) nbytes = read(fd, buffer, geo.blocksize); if (nbytes < 0) { - message("ERROR: read from /dev/mtd0 failed: %d\n", errno); - msgflush(); + printf("ERROR: read from /dev/mtd0 failed: %d\n", errno); + fflush(stdout); exit(11); } else if (nbytes == 0) { - message("ERROR: Unexpected end-of file in /dev/mtd0\n"); - msgflush(); + printf("ERROR: Unexpected end-of file in /dev/mtd0\n"); + fflush(stdout); exit(12); } else if (nbytes != geo.blocksize) { - message("ERROR: Unexpected read size from /dev/mtd0 : %ld\n", - (unsigned long)nbytes); - msgflush(); + printf("ERROR: Unexpected read size from /dev/mtd0 : %ld\n", + (unsigned long)nbytes); + fflush(stdout); exit(13); } @@ -351,8 +342,8 @@ int mtdrwb_main(int argc, char *argv[]) else if (nbytes == 0) { - message("ERROR: Unexpected end of file on /dev/mtd0\n"); - msgflush(); + printf("ERROR: Unexpected end of file on /dev/mtd0\n"); + fflush(stdout); exit(14); } @@ -360,9 +351,9 @@ int mtdrwb_main(int argc, char *argv[]) else if (nbytes != geo.blocksize) { - message("ERROR: Short read from /dev/mtd0 failed: %lu\n", - (unsigned long)nbytes); - msgflush(); + printf("ERROR: Short read from /dev/mtd0 failed: %lu\n", + (unsigned long)nbytes); + fflush(stdout); exit(15); } @@ -372,9 +363,9 @@ int mtdrwb_main(int argc, char *argv[]) { if (buffer[k] != offset) { - message("ERROR: Bad offset %lu, expected %lu\n", - (long)buffer[k], (long)offset); - msgflush(); + printf("ERROR: Bad offset %lu, expected %lu\n", + (long)buffer[k], (long)offset); + fflush(stdout); exit(16); } @@ -387,9 +378,9 @@ int mtdrwb_main(int argc, char *argv[]) nbytes = read(fd, buffer, geo.blocksize); if (nbytes != 0) { - message("ERROR: Expected end-of-file from /dev/mtd0 failed: %d %d\n", - nbytes, errno); - msgflush(); + printf("ERROR: Expected end-of-file from /dev/mtd0 failed: %d %d\n", + nbytes, errno); + fflush(stdout); exit(20); } @@ -397,8 +388,8 @@ int mtdrwb_main(int argc, char *argv[]) /* And exit without bothering to clean up */ - message("PASS: Everything looks good\n"); - msgflush(); + printf("PASS: Everything looks good\n"); + fflush(stdout); return 0; } diff --git a/apps/examples/nettest/nettest.h b/apps/examples/nettest/nettest.h index c6ed3f1be..e571cb7ba 100644 --- a/apps/examples/nettest/nettest.h +++ b/apps/examples/nettest/nettest.h @@ -57,31 +57,16 @@ # define HTONS(a) htons(a) # define HTONL(a) htonl(a) - /* Used printf for debug output */ - -# ifdef CONFIG_CPP_HAVE_VARARGS -# define message(...) printf(__VA_ARGS__) -# else -# define message printf -# endif - /* Have SO_LINGER */ # define NETTEST_HAVE_SOLINGER 1 #else - - /* Used syslog() so that there is not confusion from buffered IO */ - -# ifdef CONFIG_CPP_HAVE_VARARGS -# define message(...) syslog(__VA_ARGS__) +# ifdef CONFIG_NET_SOLINGER +# define NETTEST_HAVE_SOLINGER 1 # else -# define message syslog +# undef NETTEST_HAVE_SOLINGER # endif - - /* At present, uIP does only abortive disconnects */ - -# undef NETTEST_HAVE_SOLINGER #endif #define PORTNO 5471 diff --git a/apps/examples/nettest/nettest_client.c b/apps/examples/nettest/nettest_client.c index 7686d0ac8..9b6b97f79 100644 --- a/apps/examples/nettest/nettest_client.c +++ b/apps/examples/nettest/nettest_client.c @@ -80,7 +80,7 @@ void send_client(void) if (!outbuf) #endif { - message("client: failed to allocate buffers\n"); + printf("client: failed to allocate buffers\n"); exit(1); } @@ -89,7 +89,7 @@ void send_client(void) sockfd = socket(PF_INET, SOCK_STREAM, 0); if (sockfd < 0) { - message("client socket failure %d\n", errno); + printf("client socket failure %d\n", errno); goto errout_with_buffers; } @@ -103,13 +103,13 @@ void send_client(void) myaddr.sin_addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_CLIENTIP); #endif - message("client: Connecting...\n"); + printf("client: Connecting...\n"); if (connect( sockfd, (struct sockaddr*)&myaddr, sizeof(struct sockaddr_in)) < 0) { - message("client: connect failure: %d\n", errno); + printf("client: connect failure: %d\n", errno); goto errout_with_socket; } - message("client: Connected\n"); + printf("client: Connected\n"); /* Initialize the buffer */ @@ -131,64 +131,64 @@ void send_client(void) nbytessent = send(sockfd, outbuf, SENDSIZE, 0); if (nbytessent < 0) { - message("client: send failed: %d\n", errno); + printf("client: send failed: %d\n", errno); goto errout_with_socket; } else if (nbytessent != SENDSIZE) { - message("client: Bad send length=%d: %d of \n", + printf("client: Bad send length=%d: %d of \n", nbytessent, SENDSIZE); goto errout_with_socket; } - message("Sent %d bytes\n", nbytessent); + printf("Sent %d bytes\n", nbytessent); } #else /* Then send and receive one message */ - message("client: Sending %d bytes\n", SENDSIZE); + printf("client: Sending %d bytes\n", SENDSIZE); nbytessent = send(sockfd, outbuf, SENDSIZE, 0); - message("client: Sent %d bytes\n", nbytessent); + printf("client: Sent %d bytes\n", nbytessent); if (nbytessent < 0) { - message("client: send failed: %d\n", errno); + printf("client: send failed: %d\n", errno); goto errout_with_socket; } else if (nbytessent != SENDSIZE) { - message("client: Bad send length: %d Expected: %d\n", nbytessent, SENDSIZE); + printf("client: Bad send length: %d Expected: %d\n", nbytessent, SENDSIZE); goto errout_with_socket; } totalbytesrecvd = 0; do { - message("client: Receiving...\n"); + printf("client: Receiving...\n"); nbytesrecvd = recv(sockfd, &inbuf[totalbytesrecvd], SENDSIZE - totalbytesrecvd, 0); if (nbytesrecvd < 0) { - message("client: recv failed: %d\n", errno); + printf("client: recv failed: %d\n", errno); goto errout_with_socket; } else if (nbytesrecvd == 0) { - message("client: The server closed the connection\n"); + printf("client: The server closed the connection\n"); goto errout_with_socket; } totalbytesrecvd += nbytesrecvd; - message("client: Received %d of %d bytes\n", totalbytesrecvd, SENDSIZE); + printf("client: Received %d of %d bytes\n", totalbytesrecvd, SENDSIZE); } while (totalbytesrecvd < SENDSIZE); if (totalbytesrecvd != SENDSIZE) { - message("client: Bad recv length: %d Expected: %d\n", totalbytesrecvd, SENDSIZE); + printf("client: Bad recv length: %d Expected: %d\n", totalbytesrecvd, SENDSIZE); goto errout_with_socket; } else if (memcmp(inbuf, outbuf, SENDSIZE) != 0) { - message("client: Received buffer does not match sent buffer\n"); + printf("client: Received buffer does not match sent buffer\n"); goto errout_with_socket; } diff --git a/apps/examples/nettest/nettest_server.c b/apps/examples/nettest/nettest_server.c index bdea83dc8..4b4a4e6db 100644 --- a/apps/examples/nettest/nettest_server.c +++ b/apps/examples/nettest/nettest_server.c @@ -78,7 +78,7 @@ void recv_server(void) buffer = (char*)malloc(2*SENDSIZE); if (!buffer) { - message("server: failed to allocate buffer\n"); + printf("server: failed to allocate buffer\n"); exit(1); } @@ -88,7 +88,7 @@ void recv_server(void) listensd = socket(PF_INET, SOCK_STREAM, 0); if (listensd < 0) { - message("server: socket failure: %d\n", errno); + printf("server: socket failure: %d\n", errno); goto errout_with_buffer; } @@ -97,7 +97,7 @@ void recv_server(void) optval = 1; if (setsockopt(listensd, SOL_SOCKET, SO_REUSEADDR, (void*)&optval, sizeof(int)) < 0) { - message("server: setsockopt SO_REUSEADDR failure: %d\n", errno); + printf("server: setsockopt SO_REUSEADDR failure: %d\n", errno); goto errout_with_listensd; } @@ -109,7 +109,7 @@ void recv_server(void) if (bind(listensd, (struct sockaddr*)&myaddr, sizeof(struct sockaddr_in)) < 0) { - message("server: bind failure: %d\n", errno); + printf("server: bind failure: %d\n", errno); goto errout_with_listensd; } @@ -117,21 +117,21 @@ void recv_server(void) if (listen(listensd, 5) < 0) { - message("server: listen failure %d\n", errno); + printf("server: listen failure %d\n", errno); goto errout_with_listensd; } /* Accept only one connection */ - message("server: Accepting connections on port %d\n", PORTNO); + printf("server: Accepting connections on port %d\n", PORTNO); addrlen = sizeof(struct sockaddr_in); acceptsd = accept(listensd, (struct sockaddr*)&myaddr, &addrlen); if (acceptsd < 0) { - message("server: accept failure: %d\n", errno); + printf("server: accept failure: %d\n", errno); goto errout_with_listensd; } - message("server: Connection accepted -- receiving\n"); + printf("server: Connection accepted -- receiving\n"); /* Configure to "linger" until all data is sent when the socket is closed */ @@ -141,7 +141,7 @@ void recv_server(void) if (setsockopt(acceptsd, SOL_SOCKET, SO_LINGER, &ling, sizeof(struct linger)) < 0) { - message("server: setsockopt SO_LINGER failure: %d\n", errno); + printf("server: setsockopt SO_LINGER failure: %d\n", errno); goto errout_with_acceptsd; } #endif @@ -154,15 +154,15 @@ void recv_server(void) nbytesread = recv(acceptsd, buffer, 2*SENDSIZE, 0); if (nbytesread < 0) { - message("server: recv failed: %d\n", errno); + printf("server: recv failed: %d\n", errno); goto errout_with_acceptsd; } else if (nbytesread == 0) { - message("server: The client broke the connection\n"); + printf("server: The client broke the connection\n"); goto errout_with_acceptsd; } - message("Received %d bytes\n", nbytesread); + printf("Received %d bytes\n", nbytesread); } #else /* Receive canned message */ @@ -170,28 +170,28 @@ void recv_server(void) totalbytesread = 0; while (totalbytesread < SENDSIZE) { - message("server: Reading...\n"); + printf("server: Reading...\n"); nbytesread = recv(acceptsd, &buffer[totalbytesread], 2*SENDSIZE - totalbytesread, 0); if (nbytesread < 0) { - message("server: recv failed: %d\n", errno); + printf("server: recv failed: %d\n", errno); goto errout_with_acceptsd; } else if (nbytesread == 0) { - message("server: The client broke the connection\n"); + printf("server: The client broke the connection\n"); goto errout_with_acceptsd; } totalbytesread += nbytesread; - message("server: Received %d of %d bytes\n", totalbytesread, SENDSIZE); + printf("server: Received %d of %d bytes\n", totalbytesread, SENDSIZE); } /* Verify the message */ if (totalbytesread != SENDSIZE) { - message("server: Received %d / Expected %d bytes\n", totalbytesread, SENDSIZE); + printf("server: Received %d / Expected %d bytes\n", totalbytesread, SENDSIZE); goto errout_with_acceptsd; } @@ -200,7 +200,7 @@ void recv_server(void) { if (buffer[i] != ch) { - message("server: Byte %d is %02x / Expected %02x\n", i, buffer[i], ch); + printf("server: Byte %d is %02x / Expected %02x\n", i, buffer[i], ch); goto errout_with_acceptsd; } @@ -212,21 +212,21 @@ void recv_server(void) /* Then send the same data back to the client */ - message("server: Sending %d bytes\n", totalbytesread); + printf("server: Sending %d bytes\n", totalbytesread); nbytessent = send(acceptsd, buffer, totalbytesread, 0); if (nbytessent <= 0) { - message("server: send failed: %d\n", errno); + printf("server: send failed: %d\n", errno); goto errout_with_acceptsd; } - message("server: Sent %d bytes\n", nbytessent); + printf("server: Sent %d bytes\n", nbytessent); /* If this platform only does abortive disconnects, then wait a bit to get the * client side a change to receive the data. */ #if 1 /* Do it for all platforms */ - message("server: Wait before closing\n"); + printf("server: Wait before closing\n"); sleep(60); #endif diff --git a/apps/examples/nx/nx_events.c b/apps/examples/nx/nx_events.c index 934d4491a..7d2213f32 100644 --- a/apps/examples/nx/nx_events.c +++ b/apps/examples/nx/nx_events.c @@ -139,13 +139,13 @@ static inline void nxeg_fillwindow(NXEGWINDOW hwnd, ret = nx_fill(hwnd, rect, st->color); if (ret < 0) { - message("nxeg_fillwindow: nx_fill failed: %d\n", errno); + printf("nxeg_fillwindow: nx_fill failed: %d\n", errno); } #else ret = nxtk_fillwindow(hwnd, rect, st->color); if (ret < 0) { - message("nxeg_fillwindow: nxtk_fillwindow failed: %d\n", errno); + printf("nxeg_fillwindow: nxtk_fillwindow failed: %d\n", errno); } #endif #ifdef CONFIG_NX_KBD @@ -167,7 +167,7 @@ static inline void nxeg_filltoolbar(NXTKWINDOW htb, ret = nxtk_filltoolbar(htb, rect, color); if (ret < 0) { - message("nxeg_filltoolbar: nxtk_filltoolbar failed: %d\n", errno); + printf("nxeg_filltoolbar: nxtk_filltoolbar failed: %d\n", errno); } } #endif @@ -180,10 +180,10 @@ static void nxeg_redraw(NXEGWINDOW hwnd, FAR const struct nxgl_rect_s *rect, bool more, FAR void *arg) { FAR struct nxeg_state_s *st = (FAR struct nxeg_state_s *)arg; - message("nxeg_redraw%d: hwnd=%p rect={(%d,%d),(%d,%d)} more=%s\n", - st->wnum, hwnd, - rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y, - more ? "true" : "false"); + printf("nxeg_redraw%d: hwnd=%p rect={(%d,%d),(%d,%d)} more=%s\n", + st->wnum, hwnd, + rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y, + more ? "true" : "false"); nxeg_fillwindow(hwnd, rect, st); } @@ -201,9 +201,9 @@ static void nxeg_position(NXEGWINDOW hwnd, FAR const struct nxgl_size_s *size, /* Report the position */ - message("nxeg_position%d: hwnd=%p size=(%d,%d) pos=(%d,%d) bounds={(%d,%d),(%d,%d)}\n", - st->wnum, hwnd, size->w, size->h, pos->x, pos->y, - bounds->pt1.x, bounds->pt1.y, bounds->pt2.x, bounds->pt2.y); + printf("nxeg_position%d: hwnd=%p size=(%d,%d) pos=(%d,%d) bounds={(%d,%d),(%d,%d)}\n", + st->wnum, hwnd, size->w, size->h, pos->x, pos->y, + bounds->pt1.x, bounds->pt1.y, bounds->pt2.x, bounds->pt2.y); /* Have we picked off the window bounds yet? */ @@ -216,7 +216,7 @@ static void nxeg_position(NXEGWINDOW hwnd, FAR const struct nxgl_size_s *size, b_haveresolution = true; sem_post(&g_semevent); - message("nxeg_position2: Have xres=%d yres=%d\n", g_xres, g_yres); + printf("nxeg_position2: Have xres=%d yres=%d\n", g_xres, g_yres); } } @@ -229,8 +229,8 @@ static void nxeg_mousein(NXEGWINDOW hwnd, FAR const struct nxgl_point_s *pos, uint8_t buttons, FAR void *arg) { FAR struct nxeg_state_s *st = (FAR struct nxeg_state_s *)arg; - message("nxeg_mousein%d: hwnd=%p pos=(%d,%d) button=%02x\n", - st->wnum, hwnd, pos->x, pos->y, buttons); + printf("nxeg_mousein%d: hwnd=%p pos=(%d,%d) button=%02x\n", + st->wnum, hwnd, pos->x, pos->y, buttons); } #endif @@ -243,10 +243,10 @@ static void nxeg_tbredraw(NXEGWINDOW hwnd, FAR const struct nxgl_rect_s *rect, bool more, FAR void *arg) { FAR struct nxeg_state_s *st = (FAR struct nxeg_state_s *)arg; - message("nxeg_tbredraw%d: hwnd=%p rect={(%d,%d),(%d,%d)} more=%s\n", - st->wnum, hwnd, - rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y, - more ? "true" : "false"); + printf("nxeg_tbredraw%d: hwnd=%p rect={(%d,%d),(%d,%d)} more=%s\n", + st->wnum, hwnd, + rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y, + more ? "true" : "false"); nxeg_filltoolbar(hwnd, rect, g_tbcolor); } #endif @@ -265,9 +265,9 @@ static void nxeg_tbposition(NXEGWINDOW hwnd, FAR const struct nxgl_size_s *size, /* Report the position */ - message("nxeg_ptbosition%d: hwnd=%p size=(%d,%d) pos=(%d,%d) bounds={(%d,%d),(%d,%d)}\n", - st->wnum, hwnd, size->w, size->h, pos->x, pos->y, - bounds->pt1.x, bounds->pt1.y, bounds->pt2.x, bounds->pt2.y); + printf("nxeg_ptbosition%d: hwnd=%p size=(%d,%d) pos=(%d,%d) bounds={(%d,%d),(%d,%d)}\n", + st->wnum, hwnd, size->w, size->h, pos->x, pos->y, + bounds->pt1.x, bounds->pt1.y, bounds->pt2.x, bounds->pt2.y); } #endif @@ -282,8 +282,8 @@ static void nxeg_tbmousein(NXEGWINDOW hwnd, FAR const struct nxgl_point_s *pos, { FAR struct nxeg_state_s *st = (FAR struct nxeg_state_s *)arg; - message("nxeg_tbmousein%d: hwnd=%p pos=(%d,%d) button=%02x\n", - st->wnum, hwnd, pos->x, pos->y, buttons); + printf("nxeg_tbmousein%d: hwnd=%p pos=(%d,%d) button=%02x\n", + st->wnum, hwnd, pos->x, pos->y, buttons); } #endif #endif @@ -320,7 +320,7 @@ FAR void *nx_listenerthread(FAR void *arg) * the server. */ - message("nx_listenerthread: Lost server connection: %d\n", errno); + printf("nx_listenerthread: Lost server connection: %d\n", errno); exit(NXEXIT_LOSTSERVERCONN); } @@ -330,7 +330,7 @@ FAR void *nx_listenerthread(FAR void *arg) { g_connected = true; sem_post(&g_semevent); - message("nx_listenerthread: Connected\n"); + printf("nx_listenerthread: Connected\n"); } } } diff --git a/apps/examples/nx/nx_internal.h b/apps/examples/nx/nx_internal.h index 53f1763b4..67504227a 100644 --- a/apps/examples/nx/nx_internal.h +++ b/apps/examples/nx/nx_internal.h @@ -164,26 +164,6 @@ #define NXTK_MAXKBDCHARS 16 -/* 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/examples/nx/nx_kbdin.c b/apps/examples/nx/nx_kbdin.c index df4a0faa1..67a90d03a 100644 --- a/apps/examples/nx/nx_kbdin.c +++ b/apps/examples/nx/nx_kbdin.c @@ -127,7 +127,7 @@ static void nxeg_fillchar(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, (unsigned int)bm->glyph->stride); if (ret < 0) { - message("nxeg_fillchar: nxtk_bitmapwindow failed: %d\n", errno); + printf("nxeg_fillchar: nxtk_bitmapwindow failed: %d\n", errno); } #else ret = nx_bitmap((NXWINDOW)hwnd, &intersection, &src, @@ -135,7 +135,7 @@ static void nxeg_fillchar(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, (unsigned int)bm->glyph->stride); if (ret < 0) { - message("nxeg_fillchar: nx_bitmapwindow failed: %d\n", errno); + printf("nxeg_fillchar: nx_bitmapwindow failed: %d\n", errno); } #endif } @@ -162,7 +162,7 @@ nxeg_renderglyph(FAR struct nxeg_state_s *st, /* Make sure that there is room for another glyph */ - message("nxeg_renderglyph: ch=%02x\n", ch); + printf("nxeg_renderglyph: ch=%02x\n", ch); if (st->nglyphs < NXTK_MAXKBDCHARS) { /* Allocate the glyph */ @@ -242,7 +242,7 @@ nxeg_renderglyph(FAR struct nxeg_state_s *st, { /* Actually, the RENDERER never returns a failure */ - message("nxeg_renderglyph: RENDERER failed\n"); + printf("nxeg_renderglyph: RENDERER failed\n"); free(glyph->bitmap); glyph->bitmap = NULL; glyph = NULL; @@ -428,7 +428,7 @@ void nxeg_kbdin(NXWINDOW hwnd, uint8_t nch, FAR const uint8_t *ch, FAR void *arg) { FAR struct nxeg_state_s *st = (FAR struct nxeg_state_s *)arg; - message("nxeg_kbdin%d: hwnd=%p nch=%d\n", st->wnum, hwnd, nch); + printf("nxeg_kbdin%d: hwnd=%p nch=%d\n", st->wnum, hwnd, nch); nxeg_addchars(hwnd, st, nch, ch); } @@ -440,8 +440,8 @@ void nxeg_kbdin(NXWINDOW hwnd, uint8_t nch, FAR const uint8_t *ch, void nxeg_tbkbdin(NXWINDOW hwnd, uint8_t nch, const uint8_t *ch, FAR void *arg) { FAR struct nxeg_state_s *st = (FAR struct nxeg_state_s *)arg; - message("nxeg_tbkbdin: ERROR -- toolbar should not received keyboard input\n"); - message("nxeg_tbkbdin%d: hwnd=%p nch=%d\n", st->wnum, hwnd, nch); + printf("nxeg_tbkbdin: ERROR -- toolbar should not received keyboard input\n"); + printf("nxeg_tbkbdin%d: hwnd=%p nch=%d\n", st->wnum, hwnd, nch); } #endif diff --git a/apps/examples/nx/nx_main.c b/apps/examples/nx/nx_main.c index 8fad0bee5..1111d4ee2 100644 --- a/apps/examples/nx/nx_main.c +++ b/apps/examples/nx/nx_main.c @@ -153,7 +153,7 @@ static void nxeg_drivemouse(void) { for (y = 0; y < g_yres; y += ystep) { - message("nxeg_drivemouse: Mouse left button at (%d,%d)\n", x, y); + printf("nxeg_drivemouse: Mouse left button at (%d,%d)\n", x, y); (void)nx_mousein(g_hnx, x, y, NX_MOUSE_LEFTBUTTON); } } @@ -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); if (!hwnd) { - message("nxeg_openwindow: nx_openwindow failed: %d\n", errno); + printf("nxeg_openwindow: nx_openwindow failed: %d\n", errno); g_exitcode = NXEXIT_NXOPENWINDOW; } 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); if (!hwnd) { - message("nxeg_openwindow: nxtk_openwindow failed: %d\n", errno); + printf("nxeg_openwindow: nxtk_openwindow failed: %d\n", errno); g_exitcode = NXEXIT_NXOPENWINDOW; } return hwnd; @@ -262,7 +262,7 @@ static inline int nxeg_closewindow(NXEGWINDOW hwnd, FAR struct nxeg_state_s *sta int ret = nx_closewindow(hwnd); if (ret < 0) { - message("nxeg_closewindow: nx_closewindow failed: %d\n", errno); + printf("nxeg_closewindow: nx_closewindow failed: %d\n", errno); g_exitcode = NXEXIT_NXCLOSEWINDOW; } return ret; @@ -273,7 +273,7 @@ static inline int nxeg_closewindow(NXEGWINDOW hwnd, FAR struct nxeg_state_s *sta int ret = nxtk_closewindow(hwnd); if (ret < 0) { - message("nxeg_closewindow: nxtk_closewindow failed: %d\n", errno); + printf("nxeg_closewindow: nxtk_closewindow failed: %d\n", errno); g_exitcode = NXEXIT_NXCLOSEWINDOW; } 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); if (ret < 0) { - message("nxeg_setsize: nx_setsize failed: %d\n", errno); + printf("nxeg_setsize: nx_setsize failed: %d\n", errno); g_exitcode = NXEXIT_NXSETSIZE; } 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); if (ret < 0) { - message("nxeg_setsize: nxtk_setsize failed: %d\n", errno); + printf("nxeg_setsize: nxtk_setsize failed: %d\n", errno); g_exitcode = NXEXIT_NXSETSIZE; } 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); if (ret < 0) { - message("nxeg_setposition: nx_setposition failed: %d\n", errno); + printf("nxeg_setposition: nx_setposition failed: %d\n", errno); g_exitcode = NXEXIT_NXSETPOSITION; } 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); if (ret < 0) { - message("nxeg_setposition: nxtk_setposition failed: %d\n", errno); + printf("nxeg_setposition: nxtk_setposition failed: %d\n", errno); g_exitcode = NXEXIT_NXSETPOSITION; } 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); if (ret < 0) { - message("nxeq_opentoolbar: nxtk_opentoolbar failed: %d\n", errno); + printf("nxeq_opentoolbar: nxtk_opentoolbar failed: %d\n", errno); g_exitcode = NXEXIT_NXOPENTOOLBAR; } return ret; @@ -367,7 +367,7 @@ static inline int nxeg_lower(NXEGWINDOW hwnd) int ret = nx_lower(hwnd); if (ret < 0) { - message("nxeg_lower: nx_lower failed: %d\n", errno); + printf("nxeg_lower: nx_lower failed: %d\n", errno); g_exitcode = NXEXIT_NXLOWER; } return ret; @@ -378,7 +378,7 @@ static inline int nxeg_lower(NXEGWINDOW hwnd) int ret = nxtk_lower(hwnd); if (ret < 0) { - message("nxeg_lower: nxtk_lower failed: %d\n", errno); + printf("nxeg_lower: nxtk_lower failed: %d\n", errno); g_exitcode = NXEXIT_NXLOWER; } return ret; @@ -395,7 +395,7 @@ static inline int nxeg_raise(NXEGWINDOW hwnd) int ret = nx_raise(hwnd); if (ret < 0) { - message("nxeg_raise: nx_raise failed: %d\n", errno); + printf("nxeg_raise: nx_raise failed: %d\n", errno); g_exitcode = NXEXIT_NXRAISE; } return ret; @@ -406,7 +406,7 @@ static inline int nxeg_raise(NXEGWINDOW hwnd) int ret = nxtk_raise(hwnd); if (ret < 0) { - message("nxeg_raise: nxtk_raise failed: %d\n", errno); + printf("nxeg_raise: nxtk_raise failed: %d\n", errno); g_exitcode = NXEXIT_NXRAISE; } return ret; @@ -425,11 +425,11 @@ static inline int nxeg_suinitialize(void) #if defined(CONFIG_EXAMPLES_NX_EXTERNINIT) /* Use external graphics driver initialization */ - message("nxeg_initialize: Initializing external graphics device\n"); + printf("nxeg_initialize: Initializing external graphics device\n"); dev = up_nxdrvinit(CONFIG_EXAMPLES_NX_DEVNO); if (!dev) { - message("nxeg_initialize: up_nxdrvinit failed, devno=%d\n", CONFIG_EXAMPLES_NX_DEVNO); + printf("nxeg_initialize: up_nxdrvinit failed, devno=%d\n", CONFIG_EXAMPLES_NX_DEVNO); g_exitcode = NXEXIT_EXTINITIALIZE; return ERROR; } @@ -439,11 +439,11 @@ static inline int nxeg_suinitialize(void) /* Initialize the LCD device */ - message("nxeg_initialize: Initializing LCD\n"); + printf("nxeg_initialize: Initializing LCD\n"); ret = up_lcdinitialize(); if (ret < 0) { - message("nxeg_initialize: up_lcdinitialize failed: %d\n", -ret); + printf("nxeg_initialize: up_lcdinitialize failed: %d\n", -ret); g_exitcode = NXEXIT_LCDINITIALIZE; return ERROR; } @@ -453,7 +453,7 @@ static inline int nxeg_suinitialize(void) dev = up_lcdgetdev(CONFIG_EXAMPLES_NX_DEVNO); if (!dev) { - message("nxeg_initialize: up_lcdgetdev failed, devno=%d\n", CONFIG_EXAMPLES_NX_DEVNO); + printf("nxeg_initialize: up_lcdgetdev failed, devno=%d\n", CONFIG_EXAMPLES_NX_DEVNO); g_exitcode = NXEXIT_LCDGETDEV; return ERROR; } @@ -466,11 +466,11 @@ static inline int nxeg_suinitialize(void) /* Initialize the frame buffer device */ - message("nxeg_initialize: Initializing framebuffer\n"); + printf("nxeg_initialize: Initializing framebuffer\n"); ret = up_fbinitialize(); if (ret < 0) { - message("nxeg_initialize: up_fbinitialize failed: %d\n", -ret); + printf("nxeg_initialize: up_fbinitialize failed: %d\n", -ret); g_exitcode = NXEXIT_FBINITIALIZE; return ERROR; } @@ -478,7 +478,7 @@ static inline int nxeg_suinitialize(void) dev = up_fbgetvplane(CONFIG_EXAMPLES_NX_VPLANE); if (!dev) { - message("nxeg_initialize: up_fbgetvplane failed, vplane=%d\n", CONFIG_EXAMPLES_NX_VPLANE); + printf("nxeg_initialize: up_fbgetvplane failed, vplane=%d\n", CONFIG_EXAMPLES_NX_VPLANE); g_exitcode = NXEXIT_FBGETVPLANE; return ERROR; } @@ -486,11 +486,11 @@ static inline int nxeg_suinitialize(void) /* Then open NX */ - message("nxeg_initialize: Open NX\n"); + printf("nxeg_initialize: Open NX\n"); g_hnx = nx_open(dev); if (!g_hnx) { - message("nxeg_suinitialize: nx_open failed: %d\n", errno); + printf("nxeg_suinitialize: nx_open failed: %d\n", errno); g_exitcode = NXEXIT_NXOPEN; return ERROR; } @@ -516,19 +516,19 @@ static inline int nxeg_muinitialize(void) ret = sched_setparam(0, ¶m); if (ret < 0) { - message("nxeg_initialize: sched_setparam failed: %d\n" , ret); + printf("nxeg_initialize: sched_setparam failed: %d\n" , ret); g_exitcode = NXEXIT_SCHEDSETPARAM; return ERROR; } /* Start the server task */ - message("nxeg_initialize: Starting nx_servertask task\n"); + printf("nxeg_initialize: Starting nx_servertask task\n"); servrid = task_create("NX Server", CONFIG_EXAMPLES_NX_SERVERPRIO, CONFIG_EXAMPLES_NX_STACKSIZE, nx_servertask, NULL); if (servrid < 0) { - message("nxeg_initialize: Failed to create nx_servertask task: %d\n", errno); + printf("nxeg_initialize: Failed to create nx_servertask task: %d\n", errno); g_exitcode = NXEXIT_TASKCREATE; return ERROR; } @@ -575,7 +575,7 @@ static inline int nxeg_muinitialize(void) } else { - message("nxeg_initialize: nx_connect failed: %d\n", errno); + printf("nxeg_initialize: nx_connect failed: %d\n", errno); g_exitcode = NXEXIT_NXCONNECT; return ERROR; } @@ -633,10 +633,10 @@ int nx_main(int argc, char *argv[]) /* Initialize */ ret = nxeg_initialize(); - message("nx_main: NX handle=%p\n", g_hnx); + printf("nx_main: NX handle=%p\n", g_hnx); if (!g_hnx || ret < 0) { - message("nx_main: Failed to get NX handle: %d\n", errno); + printf("nx_main: Failed to get NX handle: %d\n", errno); g_exitcode = NXEXIT_NXOPEN; goto errout; } @@ -646,29 +646,29 @@ int nx_main(int argc, char *argv[]) g_fonthandle = nxf_getfonthandle(CONFIG_EXAMPLES_NX_FONTID); if (!g_fonthandle) { - message("nx_main: Failed to get font handle: %d\n", errno); + printf("nx_main: Failed to get font handle: %d\n", errno); g_exitcode = NXEXIT_FONTOPEN; goto errout; } /* Set the background to the configured background color */ - message("nx_main: Set background color=%d\n", CONFIG_EXAMPLES_NX_BGCOLOR); + printf("nx_main: Set background color=%d\n", CONFIG_EXAMPLES_NX_BGCOLOR); color = CONFIG_EXAMPLES_NX_BGCOLOR; ret = nx_setbgcolor(g_hnx, &color); if (ret < 0) { - message("nx_main: nx_setbgcolor failed: %d\n", errno); + printf("nx_main: nx_setbgcolor failed: %d\n", errno); g_exitcode = NXEXIT_NXSETBGCOLOR; goto errout_with_nx; } /* Create window #1 */ - message("nx_main: Create window #1\n"); + printf("nx_main: Create window #1\n"); nxeg_initstate(&g_wstate[0], 1, CONFIG_EXAMPLES_NX_COLOR1); hwnd1 = nxeg_openwindow(&g_nxcb, &g_wstate[0]); - message("nx_main: hwnd1=%p\n", hwnd1); + printf("nx_main: hwnd1=%p\n", hwnd1); if (!hwnd1) { goto errout_with_nx; @@ -680,14 +680,14 @@ int nx_main(int argc, char *argv[]) { (void)sem_wait(&g_semevent); } - message("nx_main: Screen resolution (%d,%d)\n", g_xres, g_yres); + printf("nx_main: Screen resolution (%d,%d)\n", g_xres, g_yres); /* Set the size of the window 1 */ size.w = g_xres / 2; size.h = g_yres / 2; - message("nx_main: Set window #1 size to (%d,%d)\n", size.w, size.h); + printf("nx_main: Set window #1 size to (%d,%d)\n", size.w, size.h); ret = nxeg_setsize(hwnd1, &size); if (ret < 0) { @@ -699,7 +699,7 @@ int nx_main(int argc, char *argv[]) * actually do them! */ - message("nx_main: Sleeping\n\n"); + printf("nx_main: Sleeping\n\n"); sleep(1); /* Set the position of window #1 */ @@ -707,7 +707,7 @@ int nx_main(int argc, char *argv[]) pt.x = g_xres / 8; pt.y = g_yres / 8; - message("nx_main: Set window #1 position to (%d,%d)\n", pt.x, pt.y); + printf("nx_main: Set window #1 position to (%d,%d)\n", pt.x, pt.y); ret = nxeg_setposition(hwnd1, &pt); if (ret < 0) { @@ -716,13 +716,13 @@ int nx_main(int argc, char *argv[]) /* Sleep a bit */ - message("nx_main: Sleeping\n\n"); + printf("nx_main: Sleeping\n\n"); sleep(1); /* Open the toolbar */ #ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS - message("nx_main: Add toolbar to window #1\n"); + printf("nx_main: Add toolbar to window #1\n"); ret = nxeq_opentoolbar(hwnd1, CONFIG_EXAMPLES_NX_TOOLBAR_HEIGHT, &g_tbcb, &g_wstate[0]); if (ret < 0) { @@ -731,16 +731,16 @@ int nx_main(int argc, char *argv[]) /* Sleep a bit */ - message("nx_main: Sleeping\n\n"); + printf("nx_main: Sleeping\n\n"); sleep(1); #endif /* Create window #2 */ - message("nx_main: Create window #2\n"); + printf("nx_main: Create window #2\n"); nxeg_initstate(&g_wstate[1], 2, CONFIG_EXAMPLES_NX_COLOR2); hwnd2 = nxeg_openwindow(&g_nxcb, &g_wstate[1]); - message("nx_main: hwnd2=%p\n", hwnd2); + printf("nx_main: hwnd2=%p\n", hwnd2); if (!hwnd2) { goto errout_with_hwnd1; @@ -748,12 +748,12 @@ int nx_main(int argc, char *argv[]) /* Sleep a bit */ - message("nx_main: Sleeping\n\n"); + printf("nx_main: Sleeping\n\n"); sleep(1); /* Set the size of the window 2 == size of window 1*/ - message("nx_main: Set hwnd2 size to (%d,%d)\n", size.w, size.h); + printf("nx_main: Set hwnd2 size to (%d,%d)\n", size.w, size.h); ret = nxeg_setsize(hwnd2, &size); if (ret < 0) { @@ -762,7 +762,7 @@ int nx_main(int argc, char *argv[]) /* Sleep a bit */ - message("nx_main: Sleeping\n\n"); + printf("nx_main: Sleeping\n\n"); sleep(1); /* Set the position of window #2 */ @@ -770,7 +770,7 @@ int nx_main(int argc, char *argv[]) pt.x = g_xres - size.w - pt.x; pt.y = g_yres - size.h - pt.y; - message("nx_main: Set hwnd2 position to (%d,%d)\n", pt.x, pt.y); + printf("nx_main: Set hwnd2 position to (%d,%d)\n", pt.x, pt.y); ret = nxeg_setposition(hwnd2, &pt); if (ret < 0) { @@ -779,11 +779,11 @@ int nx_main(int argc, char *argv[]) /* Sleep a bit */ - message("nx_main: Sleeping\n\n"); + printf("nx_main: Sleeping\n\n"); sleep(1); #ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS - message("nx_main: Add toolbar to window #2\n"); + printf("nx_main: Add toolbar to window #2\n"); ret = nxeq_opentoolbar(hwnd2, CONFIG_EXAMPLES_NX_TOOLBAR_HEIGHT, &g_tbcb, &g_wstate[1]); if (ret < 0) { @@ -792,30 +792,30 @@ int nx_main(int argc, char *argv[]) /* Sleep a bit */ - message("nx_main: Sleeping\n\n"); + printf("nx_main: Sleeping\n\n"); sleep(1); #endif /* Give keyboard input to the top window -- should be window #2 */ #ifdef CONFIG_NX_KBD - message("nx_main: Send keyboard input: %s\n", g_kbdmsg1); + printf("nx_main: Send keyboard input: %s\n", g_kbdmsg1); ret = nx_kbdin(g_hnx, strlen((FAR const char *)g_kbdmsg1), g_kbdmsg1); if (ret < 0) { - message("nx_main: nx_kbdin failed: %d\n", errno); + printf("nx_main: nx_kbdin failed: %d\n", errno); goto errout_with_hwnd2; } /* Sleep a bit */ - message("nx_main: Sleeping\n\n"); + printf("nx_main: Sleeping\n\n"); sleep(1); #endif /* Lower window 2 */ - message("nx_main: Lower window #2\n"); + printf("nx_main: Lower window #2\n"); ret = nxeg_lower(hwnd2); if (ret < 0) { @@ -824,7 +824,7 @@ int nx_main(int argc, char *argv[]) /* Sleep a bit */ - message("nx_main: Sleeping\n\n"); + printf("nx_main: Sleeping\n\n"); sleep(1); /* Put mouse left-button clicks all over the screen and see who responds */ @@ -834,30 +834,30 @@ int nx_main(int argc, char *argv[]) /* Sleep a bit */ - message("nx_main: Sleeping\n\n"); + printf("nx_main: Sleeping\n\n"); sleep(1); #endif /* Give keyboard input to the top window -- should be window #1 */ #ifdef CONFIG_NX_KBD - message("nx_main: Send keyboard input: %s\n", g_kbdmsg2); + printf("nx_main: Send keyboard input: %s\n", g_kbdmsg2); ret = nx_kbdin(g_hnx, strlen((FAR const char *)g_kbdmsg2), g_kbdmsg2); if (ret < 0) { - message("nx_main: nx_kbdin failed: %d\n", errno); + printf("nx_main: nx_kbdin failed: %d\n", errno); goto errout_with_hwnd2; } /* Sleep a bit */ - message("nx_main: Sleeping\n\n"); + printf("nx_main: Sleeping\n\n"); sleep(1); #endif /* Raise window 2 */ - message("nx_main: Raise window #2\n"); + printf("nx_main: Raise window #2\n"); ret = nxeg_raise(hwnd2); if (ret < 0) { @@ -872,31 +872,31 @@ int nx_main(int argc, char *argv[]) /* Sleep a bit */ - message("nx_main: Sleeping\n\n"); + printf("nx_main: Sleeping\n\n"); sleep(2); /* Close the window 2 */ errout_with_hwnd2: - message("nx_main: Close window #2\n"); + printf("nx_main: Close window #2\n"); (void)nxeg_closewindow(hwnd2, &g_wstate[1]); /* Close the window1 */ errout_with_hwnd1: - message("nx_main: Close window #1\n"); + printf("nx_main: Close window #1\n"); (void)nxeg_closewindow(hwnd1, &g_wstate[0]); errout_with_nx: #ifdef CONFIG_NX_MULTIUSER /* Disconnect from the server */ - message("nx_main: Disconnect from the server\n"); + printf("nx_main: Disconnect from the server\n"); nx_disconnect(g_hnx); #else /* Close the server */ - message("nx_main: Close NX\n"); + printf("nx_main: Close NX\n"); nx_close(g_hnx); #endif errout: diff --git a/apps/examples/nx/nx_server.c b/apps/examples/nx/nx_server.c index 0cf3066de..5a4aa4096 100644 --- a/apps/examples/nx/nx_server.c +++ b/apps/examples/nx/nx_server.c @@ -91,11 +91,11 @@ int nx_servertask(int argc, char *argv[]) #if defined(CONFIG_EXAMPLES_NX_EXTERNINIT) /* Use external graphics driver initialization */ - message("nxeg_initialize: Initializing external graphics device\n"); + printf("nxeg_initialize: Initializing external graphics device\n"); dev = up_nxdrvinit(CONFIG_EXAMPLES_NX_DEVNO); if (!dev) { - message("nxeg_initialize: up_nxdrvinit failed, devno=%d\n", CONFIG_EXAMPLES_NX_DEVNO); + printf("nxeg_initialize: up_nxdrvinit failed, devno=%d\n", CONFIG_EXAMPLES_NX_DEVNO); g_exitcode = NXEXIT_EXTINITIALIZE; return ERROR; } @@ -103,11 +103,11 @@ int nx_servertask(int argc, char *argv[]) #elif defined(CONFIG_NX_LCDDRIVER) /* Initialize the LCD device */ - message("nx_servertask: Initializing LCD\n"); + printf("nx_servertask: Initializing LCD\n"); ret = up_lcdinitialize(); if (ret < 0) { - message("nx_servertask: up_lcdinitialize failed: %d\n", -ret); + printf("nx_servertask: up_lcdinitialize failed: %d\n", -ret); return 1; } @@ -116,7 +116,7 @@ int nx_servertask(int argc, char *argv[]) dev = up_lcdgetdev(CONFIG_EXAMPLES_NX_DEVNO); if (!dev) { - message("nx_servertask: up_lcdgetdev failed, devno=%d\n", CONFIG_EXAMPLES_NX_DEVNO); + printf("nx_servertask: up_lcdgetdev failed, devno=%d\n", CONFIG_EXAMPLES_NX_DEVNO); return 2; } @@ -126,18 +126,18 @@ int nx_servertask(int argc, char *argv[]) #else /* Initialize the frame buffer device */ - message("nx_servertask: Initializing framebuffer\n"); + printf("nx_servertask: Initializing framebuffer\n"); ret = up_fbinitialize(); if (ret < 0) { - message("nx_servertask: up_fbinitialize failed: %d\n", -ret); + printf("nx_servertask: up_fbinitialize failed: %d\n", -ret); return 1; } dev = up_fbgetvplane(CONFIG_EXAMPLES_NX_VPLANE); if (!dev) { - message("nx_servertask: up_fbgetvplane failed, vplane=%d\n", CONFIG_EXAMPLES_NX_VPLANE); + printf("nx_servertask: up_fbgetvplane failed, vplane=%d\n", CONFIG_EXAMPLES_NX_VPLANE); return 2; } #endif @@ -145,7 +145,7 @@ int nx_servertask(int argc, char *argv[]) /* Then start the server */ ret = nx_run(dev); - message("nx_servertask: nx_run returned: %d\n", errno); + printf("nx_servertask: nx_run returned: %d\n", errno); return 3; } diff --git a/apps/examples/nxffs/nxffs_main.c b/apps/examples/nxffs/nxffs_main.c index 13875d8e6..1aa563e17 100644 --- a/apps/examples/nxffs/nxffs_main.c +++ b/apps/examples/nxffs/nxffs_main.c @@ -114,14 +114,6 @@ # define CONFIG_EXAMPLES_NXFFS_VERBOSE 0 #endif -#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_FS) -# define message syslog -# define msgflush() -#else -# define message printf -# define msgflush() fflush(stdout); -#endif - /**************************************************************************** * Private Types ****************************************************************************/ @@ -172,13 +164,13 @@ extern FAR struct mtd_dev_s *nxffs_archinitialize(void); static void nxffs_showmemusage(struct mallinfo *mmbefore, struct mallinfo *mmafter) { - message("VARIABLE BEFORE AFTER\n"); - message("======== ======== ========\n"); - message("arena %8x %8x\n", mmbefore->arena, mmafter->arena); - message("ordblks %8d %8d\n", mmbefore->ordblks, mmafter->ordblks); - message("mxordblk %8x %8x\n", mmbefore->mxordblk, mmafter->mxordblk); - message("uordblks %8x %8x\n", mmbefore->uordblks, mmafter->uordblks); - message("fordblks %8x %8x\n", mmbefore->fordblks, mmafter->fordblks); + printf("VARIABLE BEFORE AFTER\n"); + printf("======== ======== ========\n"); + printf("arena %8x %8x\n", mmbefore->arena, mmafter->arena); + printf("ordblks %8d %8d\n", mmbefore->ordblks, mmafter->ordblks); + printf("mxordblk %8x %8x\n", mmbefore->mxordblk, mmafter->mxordblk); + printf("uordblks %8x %8x\n", mmbefore->uordblks, mmafter->uordblks); + printf("fordblks %8x %8x\n", mmbefore->fordblks, mmafter->fordblks); } /**************************************************************************** @@ -197,7 +189,7 @@ static void nxffs_loopmemusage(void) /* Show the change from the previous loop */ - message("\nEnd of loop memory usage:\n"); + printf("\nEnd of loop memory usage:\n"); nxffs_showmemusage(&g_mmprevious, &g_mmafter); /* Set up for the next test */ @@ -220,7 +212,7 @@ static void nxffs_endmemusage(void) #else (void)mallinfo(&g_mmafter); #endif - message("\nFinal memory usage:\n"); + printf("\nFinal memory usage:\n"); nxffs_showmemusage(&g_mmbefore, &g_mmafter); } @@ -269,8 +261,8 @@ static inline void nxffs_randname(FAR struct nxffs_filedesc_s *file) file->name = (FAR char*)malloc(alloclen + 1); if (!file->name) { - message("ERROR: Failed to allocate name, length=%d\n", namelen); - msgflush(); + printf("ERROR: Failed to allocate name, length=%d\n", namelen); + fflush(stdout); exit(5); } @@ -335,9 +327,9 @@ static inline int nxffs_wrfile(FAR struct nxffs_filedesc_s *file) if (errno != ENOSPC) { - message("ERROR: Failed to open file for writing: %d\n", errno); - message(" File name: %s\n", file->name); - message(" File size: %d\n", file->len); + printf("ERROR: Failed to open file for writing: %d\n", errno); + printf(" File name: %s\n", file->name); + printf(" File size: %d\n", file->len); } nxffs_freefile(file); return ERROR; @@ -367,11 +359,11 @@ static inline int nxffs_wrfile(FAR struct nxffs_filedesc_s *file) if (err != ENOSPC) { - message("ERROR: Failed to write file: %d\n", err); - message(" File name: %s\n", file->name); - message(" File size: %d\n", file->len); - message(" Write offset: %ld\n", (long)offset); - message(" Write size: %ld\n", (long)nbytestowrite); + printf("ERROR: Failed to write file: %d\n", err); + printf(" File name: %s\n", file->name); + printf(" File size: %d\n", file->len); + printf(" Write offset: %ld\n", (long)offset); + printf(" Write size: %ld\n", (long)nbytestowrite); ret = ERROR; } @@ -382,12 +374,12 @@ static inline int nxffs_wrfile(FAR struct nxffs_filedesc_s *file) ret = unlink(file->name); if (ret < 0) { - message(" Failed to remove partial file\n"); + printf(" Failed to remove partial file\n"); } else { #if CONFIG_EXAMPLES_NXFFS_VERBOSE != 0 - message(" Successfully removed partial file\n"); + printf(" Successfully removed partial file\n"); #endif } @@ -396,12 +388,12 @@ static inline int nxffs_wrfile(FAR struct nxffs_filedesc_s *file) } else if (nbyteswritten != nbytestowrite) { - message("ERROR: Partial write:\n"); - message(" File name: %s\n", file->name); - message(" File size: %d\n", file->len); - message(" Write offset: %ld\n", (long)offset); - message(" Write size: %ld\n", (long)nbytestowrite); - message(" Written: %ld\n", (long)nbyteswritten); + printf("ERROR: Partial write:\n"); + printf(" File name: %s\n", file->name); + printf(" File size: %d\n", file->len); + printf(" Write offset: %ld\n", (long)offset); + printf(" Write size: %ld\n", (long)nbytestowrite); + printf(" Written: %ld\n", (long)nbyteswritten); } offset += nbyteswritten; @@ -432,13 +424,13 @@ static int nxffs_fillfs(void) if (ret < 0) { #if CONFIG_EXAMPLES_NXFFS_VERBOSE != 0 - message("ERROR: Failed to write file %d\n", i); + printf("ERROR: Failed to write file %d\n", i); #endif return ERROR; } #if CONFIG_EXAMPLES_NXFFS_VERBOSE != 0 - message(" Created file %s\n", file->name); + printf(" Created file %s\n", file->name); #endif g_nfiles++; } @@ -465,32 +457,32 @@ static ssize_t nxffs_rdblock(int fd, FAR struct nxffs_filedesc_s *file, nbytesread = read(fd, &g_fileimage[offset], len); if (nbytesread < 0) { - message("ERROR: Failed to read file: %d\n", errno); - message(" File name: %s\n", file->name); - message(" File size: %d\n", file->len); - message(" Read offset: %ld\n", (long)offset); - message(" Read size: %ld\n", (long)len); + printf("ERROR: Failed to read file: %d\n", errno); + printf(" File name: %s\n", file->name); + printf(" File size: %d\n", file->len); + printf(" Read offset: %ld\n", (long)offset); + printf(" Read size: %ld\n", (long)len); return ERROR; } else if (nbytesread == 0) { #if 0 /* No... we do this on purpose sometimes */ - message("ERROR: Unexpected end-of-file:\n"); - message(" File name: %s\n", file->name); - message(" File size: %d\n", file->len); - message(" Read offset: %ld\n", (long)offset); - message(" Read size: %ld\n", (long)len); + printf("ERROR: Unexpected end-of-file:\n"); + printf(" File name: %s\n", file->name); + printf(" File size: %d\n", file->len); + printf(" Read offset: %ld\n", (long)offset); + printf(" Read size: %ld\n", (long)len); #endif return ERROR; } else if (nbytesread != len) { - message("ERROR: Partial read:\n"); - message(" File name: %s\n", file->name); - message(" File size: %d\n", file->len); - message(" Read offset: %ld\n", (long)offset); - message(" Read size: %ld\n", (long)len); - message(" Bytes read: %ld\n", (long)nbytesread); + printf("ERROR: Partial read:\n"); + printf(" File name: %s\n", file->name); + printf(" File size: %d\n", file->len); + printf(" Read offset: %ld\n", (long)offset); + printf(" Read size: %ld\n", (long)len); + printf(" Bytes read: %ld\n", (long)nbytesread); } return nbytesread; } @@ -513,9 +505,9 @@ static inline int nxffs_rdfile(FAR struct nxffs_filedesc_s *file) { if (!file->deleted) { - message("ERROR: Failed to open file for reading: %d\n", errno); - message(" File name: %s\n", file->name); - message(" File size: %d\n", file->len); + printf("ERROR: Failed to open file for reading: %d\n", errno); + printf(" File name: %s\n", file->name); + printf(" File size: %d\n", file->len); } return ERROR; } @@ -539,9 +531,9 @@ static inline int nxffs_rdfile(FAR struct nxffs_filedesc_s *file) crc = crc32(g_fileimage, file->len); if (crc != file->crc) { - message("ERROR: Bad CRC: %d vs %d\n", crc, file->crc); - message(" File name: %s\n", file->name); - message(" File size: %d\n", file->len); + printf("ERROR: Bad CRC: %d vs %d\n", crc, file->crc); + printf(" File name: %s\n", file->name); + printf(" File size: %d\n", file->len); close(fd); return ERROR; } @@ -551,10 +543,10 @@ static inline int nxffs_rdfile(FAR struct nxffs_filedesc_s *file) nbytesread = nxffs_rdblock(fd, file, ntotalread, 1024) ; if (nbytesread > 0) { - message("ERROR: Read past the end of file\n"); - message(" File name: %s\n", file->name); - message(" File size: %d\n", file->len); - message(" Bytes read: %d\n", nbytesread); + printf("ERROR: Read past the end of file\n"); + printf(" File name: %s\n", file->name); + printf(" File size: %d\n", file->len); + printf(" Bytes read: %d\n", nbytesread); close(fd); return ERROR; } @@ -586,7 +578,7 @@ static int nxffs_verifyfs(void) if (file->deleted) { #if CONFIG_EXAMPLES_NXFFS_VERBOSE != 0 - message("Deleted file %d OK\n", i); + printf("Deleted file %d OK\n", i); #endif nxffs_freefile(file); g_ndeleted--; @@ -594,9 +586,9 @@ static int nxffs_verifyfs(void) } else { - message("ERROR: Failed to read a file: %d\n", i); - message(" File name: %s\n", file->name); - message(" File size: %d\n", file->len); + printf("ERROR: Failed to read a file: %d\n", i); + printf(" File name: %s\n", file->name); + printf(" File size: %d\n", file->len); return ERROR; } } @@ -605,9 +597,9 @@ static int nxffs_verifyfs(void) if (file->deleted) { #if CONFIG_EXAMPLES_NXFFS_VERBOSE != 0 - message("Succesffully read a deleted file\n"); - message(" File name: %s\n", file->name); - message(" File size: %d\n", file->len); + printf("Succesffully read a deleted file\n"); + printf(" File name: %s\n", file->name); + printf(" File size: %d\n", file->len); #endif nxffs_freefile(file); g_ndeleted--; @@ -617,7 +609,7 @@ static int nxffs_verifyfs(void) else { #if CONFIG_EXAMPLES_NXFFS_VERBOSE != 0 - message(" Verifed file %s\n", file->name); + printf(" Verifed file %s\n", file->name); #endif } } @@ -669,15 +661,15 @@ static int nxffs_delfiles(void) ret = unlink(file->name); if (ret < 0) { - message("ERROR: Unlink %d failed: %d\n", i+1, errno); - message(" File name: %s\n", file->name); - message(" File size: %d\n", file->len); - message(" File index: %d\n", j); + printf("ERROR: Unlink %d failed: %d\n", i+1, errno); + printf(" File name: %s\n", file->name); + printf(" File size: %d\n", file->len); + printf(" File index: %d\n", j); } else { #if CONFIG_EXAMPLES_NXFFS_VERBOSE != 0 - message(" Deleted file %s\n", file->name); + printf(" Deleted file %s\n", file->name); #endif file->deleted = true; g_ndeleted++; @@ -716,15 +708,15 @@ static int nxffs_delallfiles(void) ret = unlink(file->name); if (ret < 0) { - message("ERROR: Unlink %d failed: %d\n", i+1, errno); - message(" File name: %s\n", file->name); - message(" File size: %d\n", file->len); - message(" File index: %d\n", i); + printf("ERROR: Unlink %d failed: %d\n", i+1, errno); + printf(" File name: %s\n", file->name); + printf(" File size: %d\n", file->len); + printf(" File index: %d\n", i); } else { #if CONFIG_EXAMPLES_NXFFS_VERBOSE != 0 - message(" Deleted file %s\n", file->name); + printf(" Deleted file %s\n", file->name); #endif nxffs_freefile(file); } @@ -754,24 +746,24 @@ static int nxffs_directory(void) { /* Failed to open the directory */ - message("ERROR: Failed to open directory '%s': %d\n", - CONFIG_EXAMPLES_NXFFS_MOUNTPT, errno); + printf("ERROR: Failed to open directory '%s': %d\n", + CONFIG_EXAMPLES_NXFFS_MOUNTPT, errno); return ERROR; } /* Read each directory entry */ - message("Directory:\n"); + printf("Directory:\n"); number = 1; do { entryp = readdir(dirp); if (entryp) { - message("%2d. Type[%d]: %s Name: %s\n", - number, entryp->d_type, - entryp->d_type == DTYPE_FILE ? "File " : "Error", - entryp->d_name); + printf("%2d. Type[%d]: %s Name: %s\n", + number, entryp->d_type, + entryp->d_type == DTYPE_FILE ? "File " : "Error", + entryp->d_name); } number++; } @@ -812,8 +804,8 @@ int nxffs_main(int argc, char *argv[]) #endif if (!mtd) { - message("ERROR: Failed to create RAM MTD instance\n"); - msgflush(); + printf("ERROR: Failed to create RAM MTD instance\n"); + fflush(stdout); exit(1); } @@ -822,8 +814,8 @@ int nxffs_main(int argc, char *argv[]) ret = nxffs_initialize(mtd); if (ret < 0) { - message("ERROR: NXFFS initialization failed: %d\n", -ret); - msgflush(); + printf("ERROR: NXFFS initialization failed: %d\n", -ret); + fflush(stdout); exit(2); } @@ -832,8 +824,8 @@ int nxffs_main(int argc, char *argv[]) ret = mount(NULL, CONFIG_EXAMPLES_NXFFS_MOUNTPT, "nxffs", 0, NULL); if (ret < 0) { - message("ERROR: Failed to mount the NXFFS volume: %d\n", errno); - msgflush(); + printf("ERROR: Failed to mount the NXFFS volume: %d\n", errno); + fflush(stdout); exit(3); } @@ -863,11 +855,11 @@ int nxffs_main(int argc, char *argv[]) * (hopefully that the file system is full) */ - message("\n=== FILLING %u =============================\n", i); + printf("\n=== FILLING %u =============================\n", i); (void)nxffs_fillfs(); - message("Filled file system\n"); - message(" Number of files: %d\n", g_nfiles); - message(" Number deleted: %d\n", g_ndeleted); + printf("Filled file system\n"); + printf(" Number of files: %d\n", g_nfiles); + printf(" Number deleted: %d\n", g_ndeleted); nxffs_dump(mtd, CONFIG_EXAMPLES_NXFFS_VERBOSE); /* Directory listing */ @@ -879,34 +871,34 @@ int nxffs_main(int argc, char *argv[]) ret = nxffs_verifyfs(); if (ret < 0) { - message("ERROR: Failed to verify files\n"); - message(" Number of files: %d\n", g_nfiles); - message(" Number deleted: %d\n", g_ndeleted); + printf("ERROR: Failed to verify files\n"); + printf(" Number of files: %d\n", g_nfiles); + printf(" Number deleted: %d\n", g_ndeleted); } else { #if CONFIG_EXAMPLES_NXFFS_VERBOSE != 0 - message("Verified!\n"); - message(" Number of files: %d\n", g_nfiles); - message(" Number deleted: %d\n", g_ndeleted); + printf("Verified!\n"); + printf(" Number of files: %d\n", g_nfiles); + printf(" Number deleted: %d\n", g_ndeleted); #endif } /* Delete some files */ - message("\n=== DELETING %u ============================\n", i); + printf("\n=== DELETING %u ============================\n", i); ret = nxffs_delfiles(); if (ret < 0) { - message("ERROR: Failed to delete files\n"); - message(" Number of files: %d\n", g_nfiles); - message(" Number deleted: %d\n", g_ndeleted); + printf("ERROR: Failed to delete files\n"); + printf(" Number of files: %d\n", g_nfiles); + printf(" Number deleted: %d\n", g_ndeleted); } else { - message("Deleted some files\n"); - message(" Number of files: %d\n", g_nfiles); - message(" Number deleted: %d\n", g_ndeleted); + printf("Deleted some files\n"); + printf(" Number of files: %d\n", g_nfiles); + printf(" Number deleted: %d\n", g_ndeleted); } nxffs_dump(mtd, CONFIG_EXAMPLES_NXFFS_VERBOSE); @@ -919,30 +911,30 @@ int nxffs_main(int argc, char *argv[]) ret = nxffs_verifyfs(); if (ret < 0) { - message("ERROR: Failed to verify files\n"); - message(" Number of files: %d\n", g_nfiles); - message(" Number deleted: %d\n", g_ndeleted); + printf("ERROR: Failed to verify files\n"); + printf(" Number of files: %d\n", g_nfiles); + printf(" Number deleted: %d\n", g_ndeleted); } else { #if CONFIG_EXAMPLES_NXFFS_VERBOSE != 0 - message("Verified!\n"); - message(" Number of files: %d\n", g_nfiles); - message(" Number deleted: %d\n", g_ndeleted); + printf("Verified!\n"); + printf(" Number of files: %d\n", g_nfiles); + printf(" Number deleted: %d\n", g_ndeleted); #endif } /* Show memory usage */ nxffs_loopmemusage(); - msgflush(); + fflush(stdout); } /* Delete all files then show memory usage again */ nxffs_delallfiles(); nxffs_endmemusage(); - msgflush(); + fflush(stdout); return 0; } diff --git a/apps/examples/nxhello/nxhello.h b/apps/examples/nxhello/nxhello.h index 39e63ee0d..010294149 100644 --- a/apps/examples/nxhello/nxhello.h +++ b/apps/examples/nxhello/nxhello.h @@ -96,26 +96,6 @@ # endif #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/examples/nxhello/nxhello_bkgd.c b/apps/examples/nxhello/nxhello_bkgd.c index 08be6d3a9..64d66b9cb 100644 --- a/apps/examples/nxhello/nxhello_bkgd.c +++ b/apps/examples/nxhello/nxhello_bkgd.c @@ -186,8 +186,8 @@ static void nxhello_position(NXWINDOW hwnd, FAR const struct nxgl_size_s *size, static void nxhello_mousein(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos, uint8_t buttons, FAR void *arg) { - message("nxhello_mousein: hwnd=%p pos=(%d,%d) button=%02x\n", - hwnd, pos->x, pos->y, buttons); + printf("nxhello_mousein: hwnd=%p pos=(%d,%d) button=%02x\n", + hwnd, pos->x, pos->y, buttons); } #endif @@ -205,7 +205,7 @@ static void nxhello_kbdin(NXWINDOW hwnd, uint8_t nch, FAR const uint8_t *ch, * expected. */ - message("nxhello_kbdin: Unexpected keyboard callback\n"); + printf("nxhello_kbdin: Unexpected keyboard callback\n"); } #endif @@ -371,7 +371,7 @@ void nxhello_hello(NXWINDOW hwnd) */ nxhello_center(&pos, fontset); - message("nxhello_hello: Position (%d,%d)\n", pos.x, pos.y); + printf("nxhello_hello: Position (%d,%d)\n", pos.x, pos.y); /* Now we can say "hello" in the center of the display. */ @@ -420,7 +420,7 @@ void nxhello_hello(NXWINDOW hwnd) ret = nx_bitmap((NXWINDOW)hwnd, &dest, src, &pos, fstride); if (ret < 0) { - message("nxhello_write: nx_bitmapwindow failed: %d\n", errno); + printf("nxhello_write: nx_bitmapwindow failed: %d\n", errno); } /* Skip to the right the width of the font */ diff --git a/apps/examples/nxhello/nxhello_main.c b/apps/examples/nxhello/nxhello_main.c index 96b6577ef..6c8f7b966 100644 --- a/apps/examples/nxhello/nxhello_main.c +++ b/apps/examples/nxhello/nxhello_main.c @@ -125,12 +125,12 @@ static inline int nxhello_initialize(void) #if defined(CONFIG_EXAMPLES_NXHELLO_EXTERNINIT) /* Use external graphics driver initialization */ - message("nxhello_initialize: Initializing external graphics device\n"); + printf("nxhello_initialize: Initializing external graphics device\n"); dev = up_nxdrvinit(CONFIG_EXAMPLES_NXHELLO_DEVNO); if (!dev) { - message("nxhello_initialize: up_nxdrvinit failed, devno=%d\n", - CONFIG_EXAMPLES_NXHELLO_DEVNO); + printf("nxhello_initialize: up_nxdrvinit failed, devno=%d\n", + CONFIG_EXAMPLES_NXHELLO_DEVNO); g_nxhello.code = NXEXIT_EXTINITIALIZE; return ERROR; } @@ -140,11 +140,11 @@ static inline int nxhello_initialize(void) /* Initialize the LCD device */ - message("nxhello_initialize: Initializing LCD\n"); + printf("nxhello_initialize: Initializing LCD\n"); ret = up_lcdinitialize(); if (ret < 0) { - message("nxhello_initialize: up_lcdinitialize failed: %d\n", -ret); + printf("nxhello_initialize: up_lcdinitialize failed: %d\n", -ret); g_nxhello.code = NXEXIT_LCDINITIALIZE; return ERROR; } @@ -154,7 +154,7 @@ static inline int nxhello_initialize(void) dev = up_lcdgetdev(CONFIG_EXAMPLES_NXHELLO_DEVNO); if (!dev) { - message("nxhello_initialize: up_lcdgetdev failed, devno=%d\n", CONFIG_EXAMPLES_NXHELLO_DEVNO); + printf("nxhello_initialize: up_lcdgetdev failed, devno=%d\n", CONFIG_EXAMPLES_NXHELLO_DEVNO); g_nxhello.code = NXEXIT_LCDGETDEV; return ERROR; } @@ -167,11 +167,11 @@ static inline int nxhello_initialize(void) /* Initialize the frame buffer device */ - message("nxhello_initialize: Initializing framebuffer\n"); + printf("nxhello_initialize: Initializing framebuffer\n"); ret = up_fbinitialize(); if (ret < 0) { - message("nxhello_initialize: up_fbinitialize failed: %d\n", -ret); + printf("nxhello_initialize: up_fbinitialize failed: %d\n", -ret); g_nxhello.code = NXEXIT_FBINITIALIZE; return ERROR; } @@ -179,7 +179,7 @@ static inline int nxhello_initialize(void) dev = up_fbgetvplane(CONFIG_EXAMPLES_NXHELLO_VPLANE); if (!dev) { - message("nxhello_initialize: up_fbgetvplane failed, vplane=%d\n", CONFIG_EXAMPLES_NXHELLO_VPLANE); + printf("nxhello_initialize: up_fbgetvplane failed, vplane=%d\n", CONFIG_EXAMPLES_NXHELLO_VPLANE); g_nxhello.code = NXEXIT_FBGETVPLANE; return ERROR; } @@ -187,11 +187,11 @@ static inline int nxhello_initialize(void) /* Then open NX */ - message("nxhello_initialize: Open NX\n"); + printf("nxhello_initialize: Open NX\n"); g_nxhello.hnx = nx_open(dev); if (!g_nxhello.hnx) { - message("nxhello_initialize: nx_open failed: %d\n", errno); + printf("nxhello_initialize: nx_open failed: %d\n", errno); g_nxhello.code = NXEXIT_NXOPEN; return ERROR; } @@ -218,10 +218,10 @@ int nxhello_main(int argc, char *argv[]) /* Initialize NX */ ret = nxhello_initialize(); - message("nxhello_main: NX handle=%p\n", g_nxhello.hnx); + printf("nxhello_main: NX handle=%p\n", g_nxhello.hnx); if (!g_nxhello.hnx || ret < 0) { - message("nxhello_main: Failed to get NX handle: %d\n", errno); + printf("nxhello_main: Failed to get NX handle: %d\n", errno); g_nxhello.code = NXEXIT_NXOPEN; goto errout; } @@ -231,21 +231,21 @@ int nxhello_main(int argc, char *argv[]) g_nxhello.hfont = nxf_getfonthandle(CONFIG_EXAMPLES_NXHELLO_FONTID); if (!g_nxhello.hfont) { - message("nxhello_main: Failed to get font handle: %d\n", errno); + printf("nxhello_main: Failed to get font handle: %d\n", errno); g_nxhello.code = NXEXIT_FONTOPEN; goto errout; } /* Set the background to the configured background color */ - message("nxhello_main: Set background color=%d\n", - CONFIG_EXAMPLES_NXHELLO_BGCOLOR); + printf("nxhello_main: Set background color=%d\n", + CONFIG_EXAMPLES_NXHELLO_BGCOLOR); color = CONFIG_EXAMPLES_NXHELLO_BGCOLOR; ret = nx_setbgcolor(g_nxhello.hnx, &color); if (ret < 0) { - message("nxhello_main: nx_setbgcolor failed: %d\n", errno); + printf("nxhello_main: nx_setbgcolor failed: %d\n", errno); g_nxhello.code = NXEXIT_NXSETBGCOLOR; goto errout_with_nx; } @@ -255,7 +255,7 @@ int nxhello_main(int argc, char *argv[]) ret = nx_requestbkgd(g_nxhello.hnx, &g_nxhellocb, NULL); if (ret < 0) { - message("nxhello_main: nx_setbgcolor failed: %d\n", errno); + printf("nxhello_main: nx_setbgcolor failed: %d\n", errno); g_nxhello.code = NXEXIT_NXREQUESTBKGD; goto errout_with_nx; } @@ -268,7 +268,7 @@ int nxhello_main(int argc, char *argv[]) { (void)sem_wait(&g_nxhello.sem); } - message("nxhello_main: Screen resolution (%d,%d)\n", g_nxhello.xres, g_nxhello.yres); + printf("nxhello_main: Screen resolution (%d,%d)\n", g_nxhello.xres, g_nxhello.yres); /* Now, say hello and exit, sleeping a little before each. */ @@ -283,7 +283,7 @@ int nxhello_main(int argc, char *argv[]) /* Close NX */ errout_with_nx: - message("nxhello_main: Close NX\n"); + printf("nxhello_main: Close NX\n"); nx_close(g_nxhello.hnx); errout: return g_nxhello.code; diff --git a/apps/examples/nximage/nximage.h b/apps/examples/nximage/nximage.h index ef475ca29..fc4fdcefd 100644 --- a/apps/examples/nximage/nximage.h +++ b/apps/examples/nximage/nximage.h @@ -107,26 +107,6 @@ # define CONFIG_EXAMPLES_NXIMAGE_YSCALE1p0 1 #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 - /* Image Information ********************************************************/ #define IMAGE_HEIGHT 160 /* Number of rows in the raw image */ diff --git a/apps/examples/nximage/nximage_bkgd.c b/apps/examples/nximage/nximage_bkgd.c index b20f777c1..c90e7c559 100644 --- a/apps/examples/nximage/nximage_bkgd.c +++ b/apps/examples/nximage/nximage_bkgd.c @@ -235,8 +235,8 @@ static void nximage_position(NXWINDOW hwnd, FAR const struct nxgl_size_s *size, static void nximage_mousein(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos, uint8_t buttons, FAR void *arg) { - message("nximage_mousein: hwnd=%p pos=(%d,%d) button=%02x\n", - hwnd, pos->x, pos->y, buttons); + printf("nximage_mousein: hwnd=%p pos=(%d,%d) button=%02x\n", + hwnd, pos->x, pos->y, buttons); } #endif @@ -258,7 +258,7 @@ static void nximage_kbdin(NXWINDOW hwnd, uint8_t nch, FAR const uint8_t *ch, * expected. */ - message("nximage_kbdin: Unexpected keyboard callback\n"); + printf("nximage_kbdin: Unexpected keyboard callback\n"); } #endif @@ -323,7 +323,7 @@ void nximage_image(NXWINDOW hwnd) ret = nx_bitmap((NXWINDOW)hwnd, &dest, src, &pos, SCALED_WIDTH*sizeof(nxgl_mxpixel_t)); if (ret < 0) { - message("nximage_image: nx_bitmapwindow failed: %d\n", errno); + printf("nximage_image: nx_bitmapwindow failed: %d\n", errno); } /* Increment the vertical position */ @@ -365,7 +365,7 @@ void nximage_image(NXWINDOW hwnd) ret = nx_bitmap((NXWINDOW)hwnd, &dest, src, &pos, SCALED_WIDTH*sizeof(nxgl_mxpixel_t)); if (ret < 0) { - message("nximage_image: nx_bitmapwindow failed: %d\n", errno); + printf("nximage_image: nx_bitmapwindow failed: %d\n", errno); } /* Increment the vertical position */ @@ -386,7 +386,7 @@ void nximage_image(NXWINDOW hwnd) ret = nx_bitmap((NXWINDOW)hwnd, &dest, src, &pos, SCALED_WIDTH*sizeof(nxgl_mxpixel_t)); if (ret < 0) { - message("nximage_image: nx_bitmapwindow failed: %d\n", errno); + printf("nximage_image: nx_bitmapwindow failed: %d\n", errno); } /* Increment the vertical position */ diff --git a/apps/examples/nximage/nximage_main.c b/apps/examples/nximage/nximage_main.c index 359e51023..0c3340a46 100644 --- a/apps/examples/nximage/nximage_main.c +++ b/apps/examples/nximage/nximage_main.c @@ -129,12 +129,12 @@ static inline int nximage_initialize(void) #if defined(CONFIG_EXAMPLES_NXIMAGE_EXTERNINIT) /* Use external graphics driver initialization */ - message("nximage_initialize: Initializing external graphics device\n"); + printf("nximage_initialize: Initializing external graphics device\n"); dev = up_nxdrvinit(CONFIG_EXAMPLES_NXIMAGE_DEVNO); if (!dev) { - message("nximage_initialize: up_nxdrvinit failed, devno=%d\n", - CONFIG_EXAMPLES_NXIMAGE_DEVNO); + printf("nximage_initialize: up_nxdrvinit failed, devno=%d\n", + CONFIG_EXAMPLES_NXIMAGE_DEVNO); g_nximage.code = NXEXIT_EXTINITIALIZE; return ERROR; } @@ -144,11 +144,11 @@ static inline int nximage_initialize(void) /* Initialize the LCD device */ - message("nximage_initialize: Initializing LCD\n"); + printf("nximage_initialize: Initializing LCD\n"); ret = up_lcdinitialize(); if (ret < 0) { - message("nximage_initialize: up_lcdinitialize failed: %d\n", -ret); + printf("nximage_initialize: up_lcdinitialize failed: %d\n", -ret); g_nximage.code = NXEXIT_LCDINITIALIZE; return ERROR; } @@ -158,7 +158,7 @@ static inline int nximage_initialize(void) dev = up_lcdgetdev(CONFIG_EXAMPLES_NXIMAGE_DEVNO); if (!dev) { - message("nximage_initialize: up_lcdgetdev failed, devno=%d\n", CONFIG_EXAMPLES_NXIMAGE_DEVNO); + printf("nximage_initialize: up_lcdgetdev failed, devno=%d\n", CONFIG_EXAMPLES_NXIMAGE_DEVNO); g_nximage.code = NXEXIT_LCDGETDEV; return ERROR; } @@ -171,11 +171,11 @@ static inline int nximage_initialize(void) /* Initialize the frame buffer device */ - message("nximage_initialize: Initializing framebuffer\n"); + printf("nximage_initialize: Initializing framebuffer\n"); ret = up_fbinitialize(); if (ret < 0) { - message("nximage_initialize: up_fbinitialize failed: %d\n", -ret); + printf("nximage_initialize: up_fbinitialize failed: %d\n", -ret); g_nximage.code = NXEXIT_FBINITIALIZE; return ERROR; } @@ -183,7 +183,7 @@ static inline int nximage_initialize(void) dev = up_fbgetvplane(CONFIG_EXAMPLES_NXIMAGE_VPLANE); if (!dev) { - message("nximage_initialize: up_fbgetvplane failed, vplane=%d\n", CONFIG_EXAMPLES_NXIMAGE_VPLANE); + printf("nximage_initialize: up_fbgetvplane failed, vplane=%d\n", CONFIG_EXAMPLES_NXIMAGE_VPLANE); g_nximage.code = NXEXIT_FBGETVPLANE; return ERROR; } @@ -191,11 +191,11 @@ static inline int nximage_initialize(void) /* Then open NX */ - message("nximage_initialize: Open NX\n"); + printf("nximage_initialize: Open NX\n"); g_nximage.hnx = nx_open(dev); if (!g_nximage.hnx) { - message("nximage_initialize: nx_open failed: %d\n", errno); + printf("nximage_initialize: nx_open failed: %d\n", errno); g_nximage.code = NXEXIT_NXOPEN; return ERROR; } @@ -226,10 +226,10 @@ int nximage_main(int argc, char *argv[]) /* Initialize NX */ ret = nximage_initialize(); - message("nximage_main: NX handle=%p\n", g_nximage.hnx); + printf("nximage_main: NX handle=%p\n", g_nximage.hnx); if (!g_nximage.hnx || ret < 0) { - message("nximage_main: Failed to get NX handle: %d\n", errno); + printf("nximage_main: Failed to get NX handle: %d\n", errno); g_nximage.code = NXEXIT_NXOPEN; goto errout; } @@ -237,12 +237,12 @@ int nximage_main(int argc, char *argv[]) /* Set the background to the configured background color */ color = nximage_bgcolor(); - message("nximage_main: Set background color=%d\n", color); + printf("nximage_main: Set background color=%d\n", color); ret = nx_setbgcolor(g_nximage.hnx, &color); if (ret < 0) { - message("nximage_main: nx_setbgcolor failed: %d\n", errno); + printf("nximage_main: nx_setbgcolor failed: %d\n", errno); g_nximage.code = NXEXIT_NXSETBGCOLOR; goto errout_with_nx; } @@ -252,7 +252,7 @@ int nximage_main(int argc, char *argv[]) ret = nx_requestbkgd(g_nximage.hnx, &g_nximagecb, NULL); if (ret < 0) { - message("nximage_main: nx_setbgcolor failed: %d\n", errno); + printf("nximage_main: nx_setbgcolor failed: %d\n", errno); g_nximage.code = NXEXIT_NXREQUESTBKGD; goto errout_with_nx; } @@ -265,7 +265,7 @@ int nximage_main(int argc, char *argv[]) { (void)sem_wait(&g_nximage.sem); } - message("nximage_main: Screen resolution (%d,%d)\n", g_nximage.xres, g_nximage.yres); + printf("nximage_main: Screen resolution (%d,%d)\n", g_nximage.xres, g_nximage.yres); /* Now, put up the NuttX logo and wait a bit so that it visible. */ @@ -279,7 +279,7 @@ int nximage_main(int argc, char *argv[]) /* Close NX */ errout_with_nx: - message("nximage_main: Close NX\n"); + printf("nximage_main: Close NX\n"); nx_close(g_nximage.hnx); errout: return g_nximage.code; diff --git a/apps/examples/nxlines/nxlines.h b/apps/examples/nxlines/nxlines.h index 19e809c8b..6a54e8f09 100644 --- a/apps/examples/nxlines/nxlines.h +++ b/apps/examples/nxlines/nxlines.h @@ -116,26 +116,6 @@ # endif #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/examples/nxlines/nxlines_bkgd.c b/apps/examples/nxlines/nxlines_bkgd.c index b9383fd1d..dcf2a10bd 100644 --- a/apps/examples/nxlines/nxlines_bkgd.c +++ b/apps/examples/nxlines/nxlines_bkgd.c @@ -164,9 +164,9 @@ static void nxlines_position(NXWINDOW hwnd, FAR const struct nxgl_size_s *size, static void nxlines_mousein(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos, uint8_t buttons, FAR void *arg) { - message("nxlines_mousein: hwnd=%p pos=(%d,%d) button=%02x\n", - hwnd, pos->x, pos->y, buttons); -} + printf("nxlines_mousein: hwnd=%p pos=(%d,%d) button=%02x\n", + hwnd, pos->x, pos->y, buttons); + #endif /**************************************************************************** @@ -183,7 +183,7 @@ static void nxlines_kbdin(NXWINDOW hwnd, uint8_t nch, FAR const uint8_t *ch, * expected. */ - message("nxlines_kbdin: Unexpected keyboard callback\n"); + printf("nxlines_kbdin: Unexpected keyboard callback\n"); } #endif @@ -225,7 +225,7 @@ void nxlines_test(NXWINDOW hwnd) ret = nx_fillcircle((NXWINDOW)hwnd, ¢er, radius, color); if (ret < 0) { - message("nxlines_test: nx_fillcircle failed: %d\n", ret); + printf("nxlines_test: nx_fillcircle failed: %d\n", ret); } /* Draw the circular border */ @@ -235,7 +235,7 @@ void nxlines_test(NXWINDOW hwnd) CONFIG_EXAMPLES_NXLINES_BORDERWIDTH, color); if (ret < 0) { - message("nxlines_test: nx_fillcircle failed: %d\n", ret); + printf("nxlines_test: nx_fillcircle failed: %d\n", ret); } /* Back off the radius to account for the thickness of border line @@ -287,8 +287,8 @@ void nxlines_test(NXWINDOW hwnd) vector.pt2.x = center.x - halfx; vector.pt2.y = center.y - halfy; - message("Angle: %08x vector: (%d,%d)->(%d,%d)\n", - angle, vector.pt1.x, vector.pt1.y, vector.pt2.x, vector.pt2.y); + printf("Angle: %08x vector: (%d,%d)->(%d,%d)\n", + angle, vector.pt1.x, vector.pt1.y, vector.pt2.x, vector.pt2.y); /* Clear the previous line by overwriting it with the circle color */ @@ -296,7 +296,7 @@ void nxlines_test(NXWINDOW hwnd) ret = nx_drawline((NXWINDOW)hwnd, &previous, CONFIG_EXAMPLES_NXLINES_LINEWIDTH, color); if (ret < 0) { - message("nxlines_test: nx_drawline failed clearing: %d\n", ret); + printf("nxlines_test: nx_drawline failed clearing: %d\n", ret); } /* Draw the new line */ @@ -305,7 +305,7 @@ void nxlines_test(NXWINDOW hwnd) ret = nx_drawline((NXWINDOW)hwnd, &vector, CONFIG_EXAMPLES_NXLINES_LINEWIDTH, color); if (ret < 0) { - message("nxlines_test: nx_drawline failed clearing: %d\n", ret); + printf("nxlines_test: nx_drawline failed clearing: %d\n", ret); } /* Set up for the next time through the loop then sleep for a bit. */ diff --git a/apps/examples/nxlines/nxlines_main.c b/apps/examples/nxlines/nxlines_main.c index 78f3439c4..21798b7d1 100644 --- a/apps/examples/nxlines/nxlines_main.c +++ b/apps/examples/nxlines/nxlines_main.c @@ -121,12 +121,12 @@ static inline int nxlines_initialize(void) #if defined(CONFIG_EXAMPLES_NXLINES_EXTERNINIT) /* Use external graphics driver initialization */ - message("nxlines_initialize: Initializing external graphics device\n"); + printf("nxlines_initialize: Initializing external graphics device\n"); dev = up_nxdrvinit(CONFIG_EXAMPLES_NXLINES_DEVNO); if (!dev) { - message("nxlines_initialize: up_nxdrvinit failed, devno=%d\n", - CONFIG_EXAMPLES_NXLINES_DEVNO); + printf("nxlines_initialize: up_nxdrvinit failed, devno=%d\n", + CONFIG_EXAMPLES_NXLINES_DEVNO); g_nxlines.code = NXEXIT_EXTINITIALIZE; return ERROR; } @@ -136,11 +136,11 @@ static inline int nxlines_initialize(void) /* Initialize the LCD device */ - message("nxlines_initialize: Initializing LCD\n"); + printf("nxlines_initialize: Initializing LCD\n"); ret = up_lcdinitialize(); if (ret < 0) { - message("nxlines_initialize: up_lcdinitialize failed: %d\n", -ret); + printf("nxlines_initialize: up_lcdinitialize failed: %d\n", -ret); g_nxlines.code = NXEXIT_LCDINITIALIZE; return ERROR; } @@ -150,7 +150,7 @@ static inline int nxlines_initialize(void) dev = up_lcdgetdev(CONFIG_EXAMPLES_NXLINES_DEVNO); if (!dev) { - message("nxlines_initialize: up_lcdgetdev failed, devno=%d\n", CONFIG_EXAMPLES_NXLINES_DEVNO); + printf("nxlines_initialize: up_lcdgetdev failed, devno=%d\n", CONFIG_EXAMPLES_NXLINES_DEVNO); g_nxlines.code = NXEXIT_LCDGETDEV; return ERROR; } @@ -163,11 +163,11 @@ static inline int nxlines_initialize(void) /* Initialize the frame buffer device */ - message("nxlines_initialize: Initializing framebuffer\n"); + printf("nxlines_initialize: Initializing framebuffer\n"); ret = up_fbinitialize(); if (ret < 0) { - message("nxlines_initialize: up_fbinitialize failed: %d\n", -ret); + printf("nxlines_initialize: up_fbinitialize failed: %d\n", -ret); g_nxlines.code = NXEXIT_FBINITIALIZE; return ERROR; } @@ -175,7 +175,7 @@ static inline int nxlines_initialize(void) dev = up_fbgetvplane(CONFIG_EXAMPLES_NXLINES_VPLANE); if (!dev) { - message("nxlines_initialize: up_fbgetvplane failed, vplane=%d\n", CONFIG_EXAMPLES_NXLINES_VPLANE); + printf("nxlines_initialize: up_fbgetvplane failed, vplane=%d\n", CONFIG_EXAMPLES_NXLINES_VPLANE); g_nxlines.code = NXEXIT_FBGETVPLANE; return ERROR; } @@ -183,11 +183,11 @@ static inline int nxlines_initialize(void) /* Then open NX */ - message("nxlines_initialize: Open NX\n"); + printf("nxlines_initialize: Open NX\n"); g_nxlines.hnx = nx_open(dev); if (!g_nxlines.hnx) { - message("nxlines_initialize: nx_open failed: %d\n", errno); + printf("nxlines_initialize: nx_open failed: %d\n", errno); g_nxlines.code = NXEXIT_NXOPEN; return ERROR; } @@ -215,24 +215,24 @@ int nxlines_main(int argc, char *argv[]) /* Initialize NX */ ret = nxlines_initialize(); - message("nxlines_main: NX handle=%p\n", g_nxlines.hnx); + printf("nxlines_main: NX handle=%p\n", g_nxlines.hnx); if (!g_nxlines.hnx || ret < 0) { - message("nxlines_main: Failed to get NX handle: %d\n", errno); + printf("nxlines_main: Failed to get NX handle: %d\n", errno); g_nxlines.code = NXEXIT_NXOPEN; goto errout; } /* Set the background to the configured background color */ - message("nxlines_main: Set background color=%d\n", - CONFIG_EXAMPLES_NXLINES_BGCOLOR); + printf("nxlines_main: Set background color=%d\n", + CONFIG_EXAMPLES_NXLINES_BGCOLOR); color = CONFIG_EXAMPLES_NXLINES_BGCOLOR; ret = nx_setbgcolor(g_nxlines.hnx, &color); if (ret < 0) { - message("nxlines_main: nx_setbgcolor failed: %d\n", errno); + printf("nxlines_main: nx_setbgcolor failed: %d\n", errno); g_nxlines.code = NXEXIT_NXSETBGCOLOR; goto errout_with_nx; } @@ -242,7 +242,7 @@ int nxlines_main(int argc, char *argv[]) ret = nx_requestbkgd(g_nxlines.hnx, &g_nxlinescb, NULL); if (ret < 0) { - message("nxlines_main: nx_setbgcolor failed: %d\n", errno); + printf("nxlines_main: nx_setbgcolor failed: %d\n", errno); g_nxlines.code = NXEXIT_NXREQUESTBKGD; goto errout_with_nx; } @@ -255,7 +255,7 @@ int nxlines_main(int argc, char *argv[]) { (void)sem_wait(&g_nxlines.sem); } - message("nxlines_main: Screen resolution (%d,%d)\n", g_nxlines.xres, g_nxlines.yres); + printf("nxlines_main: Screen resolution (%d,%d)\n", g_nxlines.xres, g_nxlines.yres); /* Now, say perform the lines (these test does not return so the remaining * logic is cosmetic). @@ -270,7 +270,7 @@ int nxlines_main(int argc, char *argv[]) /* Close NX */ errout_with_nx: - message("nxlines_main: Close NX\n"); + printf("nxlines_main: Close NX\n"); nx_close(g_nxlines.hnx); errout: return g_nxlines.code; diff --git a/apps/examples/nxterm/nxterm_internal.h b/apps/examples/nxterm/nxterm_internal.h index 49a070118..29a196f0e 100644 --- a/apps/examples/nxterm/nxterm_internal.h +++ b/apps/examples/nxterm/nxterm_internal.h @@ -235,26 +235,6 @@ # define CONFIG_EXAMPLES_NXTERM_STACKSIZE 2048 #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/examples/nxterm/nxterm_main.c b/apps/examples/nxterm/nxterm_main.c index ee17e0796..c44f5fd9a 100644 --- a/apps/examples/nxterm/nxterm_main.c +++ b/apps/examples/nxterm/nxterm_main.c @@ -114,18 +114,18 @@ static int nxterm_initialize(void) ret = sched_setparam(0, ¶m); if (ret < 0) { - message("nxterm_initialize: sched_setparam failed: %d\n" , ret); + printf("nxterm_initialize: sched_setparam failed: %d\n" , ret); return ERROR; } /* Start the server task */ - message("nxterm_initialize: Starting nxterm_server task\n"); + printf("nxterm_initialize: Starting nxterm_server task\n"); servrid = task_create("NX Server", CONFIG_EXAMPLES_NXCON_SERVERPRIO, CONFIG_EXAMPLES_NXCON_STACKSIZE, nxterm_server, NULL); if (servrid < 0) { - message("nxterm_initialize: Failed to create nxterm_server task: %d\n", errno); + printf("nxterm_initialize: Failed to create nxterm_server task: %d\n", errno); return ERROR; } @@ -170,7 +170,7 @@ static int nxterm_initialize(void) } else { - message("nxterm_initialize: nx_connect failed: %d\n", errno); + printf("nxterm_initialize: nx_connect failed: %d\n", errno); return ERROR; } return OK; @@ -223,7 +223,7 @@ int nxterm_main(int argc, char **argv) /* General Initialization *************************************************/ /* Reset all global data */ - message("nxterm_main: Started\n"); + printf("nxterm_main: Started\n"); memset(&g_nxterm_vars, 0, sizeof(struct nxterm_state_s)); /* Call all C++ static constructors */ @@ -235,7 +235,7 @@ int nxterm_main(int argc, char **argv) /* NSH Initialization *****************************************************/ /* Initialize the NSH library */ - message("nxterm_main: Initialize NSH\n"); + printf("nxterm_main: Initialize NSH\n"); nsh_initialize(); /* If the Telnet console is selected as a front-end, then start the @@ -256,37 +256,37 @@ int nxterm_main(int argc, char **argv) /* NX Initialization ******************************************************/ /* Initialize NX */ - message("nxterm_main: Initialize NX\n"); + printf("nxterm_main: Initialize NX\n"); ret = nxterm_initialize(); - message("nxterm_main: NX handle=%p\n", g_nxterm_vars.hnx); + printf("nxterm_main: NX handle=%p\n", g_nxterm_vars.hnx); if (!g_nxterm_vars.hnx || ret < 0) { - message("nxterm_main: Failed to get NX handle: %d\n", errno); + printf("nxterm_main: Failed to get NX handle: %d\n", errno); goto errout; } /* Set the background to the configured background color */ - message("nxterm_main: Set background color=%d\n", CONFIG_EXAMPLES_NXCON_BGCOLOR); + printf("nxterm_main: Set background color=%d\n", CONFIG_EXAMPLES_NXCON_BGCOLOR); color = CONFIG_EXAMPLES_NXCON_BGCOLOR; ret = nx_setbgcolor(g_nxterm_vars.hnx, &color); if (ret < 0) { - message("nxterm_main: nx_setbgcolor failed: %d\n", errno); + printf("nxterm_main: nx_setbgcolor failed: %d\n", errno); goto errout_with_nx; } /* Window Configuration ***************************************************/ /* Create a window */ - message("nxterm_main: Create window\n"); + printf("nxterm_main: Create window\n"); g_nxterm_vars.hwnd = nxtk_openwindow(g_nxterm_vars.hnx, &g_nxtermcb, NULL); if (!g_nxterm_vars.hwnd) { - message("nxterm_main: nxtk_openwindow failed: %d\n", errno); + printf("nxterm_main: nxtk_openwindow failed: %d\n", errno); goto errout_with_nx; } - message("nxterm_main: hwnd=%p\n", g_nxterm_vars.hwnd); + printf("nxterm_main: hwnd=%p\n", g_nxterm_vars.hwnd); /* Wait until we have the screen resolution. We'll have this immediately * unless we are dealing with the NX server. @@ -296,7 +296,7 @@ int nxterm_main(int argc, char **argv) { (void)sem_wait(&g_nxterm_vars.eventsem); } - message("nxterm_main: Screen resolution (%d,%d)\n", g_nxterm_vars.xres, g_nxterm_vars.yres); + printf("nxterm_main: Screen resolution (%d,%d)\n", g_nxterm_vars.xres, g_nxterm_vars.yres); /* Determine the size and position of the window */ @@ -308,35 +308,35 @@ int nxterm_main(int argc, char **argv) /* Set the window position */ - message("nxterm_main: Set window position to (%d,%d)\n", - g_nxterm_vars.wpos.x, g_nxterm_vars.wpos.y); + printf("nxterm_main: Set window position to (%d,%d)\n", + g_nxterm_vars.wpos.x, g_nxterm_vars.wpos.y); ret = nxtk_setposition(g_nxterm_vars.hwnd, &g_nxterm_vars.wpos); if (ret < 0) { - message("nxterm_main: nxtk_setposition failed: %d\n", errno); + printf("nxterm_main: nxtk_setposition failed: %d\n", errno); goto errout_with_hwnd; } /* Set the window size */ - message("nxterm_main: Set window size to (%d,%d)\n", - g_nxterm_vars.wndo.wsize.w, g_nxterm_vars.wndo.wsize.h); + printf("nxterm_main: Set window size to (%d,%d)\n", + g_nxterm_vars.wndo.wsize.w, g_nxterm_vars.wndo.wsize.h); ret = nxtk_setsize(g_nxterm_vars.hwnd, &g_nxterm_vars.wndo.wsize); if (ret < 0) { - message("nxterm_main: nxtk_setsize failed: %d\n", errno); + printf("nxterm_main: nxtk_setsize failed: %d\n", errno); goto errout_with_hwnd; } /* Open the toolbar */ - message("nxterm_main: Add toolbar to window\n"); + printf("nxterm_main: Add toolbar to window\n"); ret = nxtk_opentoolbar(g_nxterm_vars.hwnd, CONFIG_EXAMPLES_NXCON_TOOLBAR_HEIGHT, &g_nxtoolcb, NULL); if (ret < 0) { - message("nxterm_main: nxtk_opentoolbar failed: %d\n", errno); + printf("nxterm_main: nxtk_opentoolbar failed: %d\n", errno); goto errout_with_hwnd; } @@ -354,7 +354,7 @@ int nxterm_main(int argc, char **argv) g_nxterm_vars.hdrvr = nxtk_register(g_nxterm_vars.hwnd, &g_nxterm_vars.wndo, CONFIG_EXAMPLES_NXCON_MINOR); if (!g_nxterm_vars.hdrvr) { - message("nxterm_main: nxtk_register failed: %d\n", errno); + printf("nxterm_main: nxtk_register failed: %d\n", errno); goto errout_with_hwnd; } @@ -363,8 +363,8 @@ int nxterm_main(int argc, char **argv) fd = open(CONFIG_EXAMPLES_NXCON_DEVNAME, O_WRONLY); if (fd < 0) { - message("nxterm_main: open %s read-only failed: %d\n", - CONFIG_EXAMPLES_NXCON_DEVNAME, errno); + printf("nxterm_main: open %s read-only failed: %d\n", + CONFIG_EXAMPLES_NXCON_DEVNAME, errno); goto errout_with_driver; } @@ -373,8 +373,8 @@ int nxterm_main(int argc, char **argv) * Note that stdin is retained (file descriptor 0, probably the the serial console). */ - message("nxterm_main: Starting the console task\n"); - msgflush(); + printf("nxterm_main: Starting the console task\n"); + fflush(stdout); (void)fflush(stdout); (void)fflush(stderr); diff --git a/apps/examples/nxterm/nxterm_server.c b/apps/examples/nxterm/nxterm_server.c index 6cf226e79..7e30a11fe 100644 --- a/apps/examples/nxterm/nxterm_server.c +++ b/apps/examples/nxterm/nxterm_server.c @@ -89,22 +89,22 @@ int nxterm_server(int argc, char *argv[]) #if defined(CONFIG_EXAMPLES_NXCON_EXTERNINIT) /* Use external graphics driver initialization */ - message("nxterm_server: Initializing external graphics device\n"); + printf("nxterm_server: Initializing external graphics device\n"); dev = up_nxdrvinit(CONFIG_EXAMPLES_NXCON_DEVNO); if (!dev) { - message("nxterm_server: up_nxdrvinit failed, devno=%d\n", CONFIG_EXAMPLES_NXCON_DEVNO); + printf("nxterm_server: up_nxdrvinit failed, devno=%d\n", CONFIG_EXAMPLES_NXCON_DEVNO); return ERROR; } #elif defined(CONFIG_NX_LCDDRIVER) /* Initialize the LCD device */ - message("nxterm_server: Initializing LCD\n"); + printf("nxterm_server: Initializing LCD\n"); ret = up_lcdinitialize(); if (ret < 0) { - message("nxterm_server: up_lcdinitialize failed: %d\n", -ret); + printf("nxterm_server: up_lcdinitialize failed: %d\n", -ret); return 1; } @@ -113,7 +113,7 @@ int nxterm_server(int argc, char *argv[]) dev = up_lcdgetdev(CONFIG_EXAMPLES_NXCON_DEVNO); if (!dev) { - message("nxterm_server: up_lcdgetdev failed, devno=%d\n", CONFIG_EXAMPLES_NXCON_DEVNO); + printf("nxterm_server: up_lcdgetdev failed, devno=%d\n", CONFIG_EXAMPLES_NXCON_DEVNO); return 2; } @@ -123,18 +123,18 @@ int nxterm_server(int argc, char *argv[]) #else /* Initialize the frame buffer device */ - message("nxterm_server: Initializing framebuffer\n"); + printf("nxterm_server: Initializing framebuffer\n"); ret = up_fbinitialize(); if (ret < 0) { - message("nxterm_server: up_fbinitialize failed: %d\n", -ret); + printf("nxterm_server: up_fbinitialize failed: %d\n", -ret); return 1; } dev = up_fbgetvplane(CONFIG_EXAMPLES_NXCON_VPLANE); if (!dev) { - message("nxterm_server: up_fbgetvplane failed, vplane=%d\n", CONFIG_EXAMPLES_NXCON_VPLANE); + printf("nxterm_server: up_fbgetvplane failed, vplane=%d\n", CONFIG_EXAMPLES_NXCON_VPLANE); return 2; } #endif @@ -173,7 +173,7 @@ FAR void *nxterm_listener(FAR void *arg) * the server. */ - message("nxterm_listener: Lost server connection: %d\n", errno); + printf("nxterm_listener: Lost server connection: %d\n", errno); exit(EXIT_FAILURE); } @@ -183,7 +183,7 @@ FAR void *nxterm_listener(FAR void *arg) { g_nxterm_vars.connected = true; sem_post(&g_nxterm_vars.eventsem); - message("nxterm_listener: Connected\n"); + printf("nxterm_listener: Connected\n"); } } } diff --git a/apps/examples/nxtext/nxtext_bkgd.c b/apps/examples/nxtext/nxtext_bkgd.c index e91ad0a91..1dc74d075 100644 --- a/apps/examples/nxtext/nxtext_bkgd.c +++ b/apps/examples/nxtext/nxtext_bkgd.c @@ -127,7 +127,7 @@ static void nxbg_redrawrect(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect) ret = nx_fill(hwnd, rect, g_bgstate.wcolor); if (ret < 0) { - message("nxbg_redrawrect: nx_fill failed: %d\n", errno); + printf("nxbg_redrawrect: nx_fill failed: %d\n", errno); } /* Fill each character on the display (Only the characters within rect @@ -203,8 +203,8 @@ static void nxbg_position(NXWINDOW hwnd, FAR const struct nxgl_size_s *size, static void nxbg_mousein(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos, uint8_t buttons, FAR void *arg) { - message("nxbg_mousein: hwnd=%p pos=(%d,%d) button=%02x\n", - hwnd, pos->x, pos->y, buttons); + printf("nxbg_mousein: hwnd=%p pos=(%d,%d) button=%02x\n", + hwnd, pos->x, pos->y, buttons); } #endif @@ -260,7 +260,7 @@ static inline void nxbg_movedisplay(NXWINDOW hwnd, int bottom, int lineheight) ret = nx_fill(hwnd, &rect, g_bgstate.wcolor); if (ret < 0) { - message("nxbg_movedisplay: nx_fill failed: %d\n", errno); + printf("nxbg_movedisplay: nx_fill failed: %d\n", errno); } /* Fill each character that might lie within in the bounding box */ @@ -283,7 +283,7 @@ static inline void nxbg_movedisplay(NXWINDOW hwnd, int bottom, int lineheight) ret = nx_fill(hwnd, &rect, g_bgstate.wcolor); if (ret < 0) { - message("nxbg_movedisplay: nx_fill failed: %d\n", errno); + printf("nxbg_movedisplay: nx_fill failed: %d\n", errno); } } diff --git a/apps/examples/nxtext/nxtext_internal.h b/apps/examples/nxtext/nxtext_internal.h index 445809607..9c29315c0 100644 --- a/apps/examples/nxtext/nxtext_internal.h +++ b/apps/examples/nxtext/nxtext_internal.h @@ -190,26 +190,6 @@ # endif #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 - /* Bitmap flags */ #define BMFLAGS_NOGLYPH (1 << 0) /* No glyph available, use space */ diff --git a/apps/examples/nxtext/nxtext_main.c b/apps/examples/nxtext/nxtext_main.c index ae1c26155..bee9e90db 100644 --- a/apps/examples/nxtext/nxtext_main.c +++ b/apps/examples/nxtext/nxtext_main.c @@ -167,11 +167,11 @@ static inline int nxtext_suinitialize(void) #if defined(CONFIG_EXAMPLES_NXTEXT_EXTERNINIT) /* Use external graphics driver initialization */ - message("nxtext_initialize: Initializing external graphics device\n"); + printf("nxtext_initialize: Initializing external graphics device\n"); dev = up_nxdrvinit(CONFIG_EXAMPLES_NXTEXT_DEVNO); if (!dev) { - message("nxtext_initialize: up_nxdrvinit failed, devno=%d\n", CONFIG_EXAMPLES_NXTEXT_DEVNO); + printf("nxtext_initialize: up_nxdrvinit failed, devno=%d\n", CONFIG_EXAMPLES_NXTEXT_DEVNO); g_exitcode = NXEXIT_EXTINITIALIZE; return ERROR; } @@ -181,11 +181,11 @@ static inline int nxtext_suinitialize(void) /* Initialize the LCD device */ - message("nxtext_initialize: Initializing LCD\n"); + printf("nxtext_initialize: Initializing LCD\n"); ret = up_lcdinitialize(); if (ret < 0) { - message("nxtext_initialize: up_lcdinitialize failed: %d\n", -ret); + printf("nxtext_initialize: up_lcdinitialize failed: %d\n", -ret); g_exitcode = NXEXIT_LCDINITIALIZE; return ERROR; } @@ -195,7 +195,7 @@ static inline int nxtext_suinitialize(void) dev = up_lcdgetdev(CONFIG_EXAMPLES_NXTEXT_DEVNO); if (!dev) { - message("nxtext_initialize: up_lcdgetdev failed, devno=%d\n", CONFIG_EXAMPLES_NXTEXT_DEVNO); + printf("nxtext_initialize: up_lcdgetdev failed, devno=%d\n", CONFIG_EXAMPLES_NXTEXT_DEVNO); g_exitcode = NXEXIT_LCDGETDEV; return ERROR; } @@ -208,11 +208,11 @@ static inline int nxtext_suinitialize(void) /* Initialize the frame buffer device */ - message("nxtext_initialize: Initializing framebuffer\n"); + printf("nxtext_initialize: Initializing framebuffer\n"); ret = up_fbinitialize(); if (ret < 0) { - message("nxtext_initialize: up_fbinitialize failed: %d\n", -ret); + printf("nxtext_initialize: up_fbinitialize failed: %d\n", -ret); g_exitcode = NXEXIT_FBINITIALIZE; return ERROR; } @@ -220,7 +220,7 @@ static inline int nxtext_suinitialize(void) dev = up_fbgetvplane(CONFIG_EXAMPLES_NXTEXT_VPLANE); if (!dev) { - message("nxtext_initialize: up_fbgetvplane failed, vplane=%d\n", CONFIG_EXAMPLES_NXTEXT_VPLANE); + printf("nxtext_initialize: up_fbgetvplane failed, vplane=%d\n", CONFIG_EXAMPLES_NXTEXT_VPLANE); g_exitcode = NXEXIT_FBGETVPLANE; return ERROR; } @@ -228,11 +228,11 @@ static inline int nxtext_suinitialize(void) /* Then open NX */ - message("nxtext_initialize: Open NX\n"); + printf("nxtext_initialize: Open NX\n"); g_hnx = nx_open(dev); if (!g_hnx) { - message("nxtext_initialize: nx_open failed: %d\n", errno); + printf("nxtext_initialize: nx_open failed: %d\n", errno); g_exitcode = NXEXIT_NXOPEN; return ERROR; } @@ -258,19 +258,19 @@ static inline int nxtext_muinitialize(void) ret = sched_setparam(0, ¶m); if (ret < 0) { - message("nxtext_initialize: sched_setparam failed: %d\n" , ret); + printf("nxtext_initialize: sched_setparam failed: %d\n" , ret); g_exitcode = NXEXIT_SCHEDSETPARAM; return ERROR; } /* Start the server task */ - message("nxtext_initialize: Starting nxtext_server task\n"); + printf("nxtext_initialize: Starting nxtext_server task\n"); servrid = task_create("NX Server", CONFIG_EXAMPLES_NXTEXT_SERVERPRIO, CONFIG_EXAMPLES_NXTEXT_STACKSIZE, nxtext_server, NULL); if (servrid < 0) { - message("nxtext_initialize: Failed to create nxtext_server task: %d\n", errno); + printf("nxtext_initialize: Failed to create nxtext_server task: %d\n", errno); g_exitcode = NXEXIT_TASKCREATE; return ERROR; } @@ -317,7 +317,7 @@ static inline int nxtext_muinitialize(void) } else { - message("nxtext_initialize: nx_connect failed: %d\n", errno); + printf("nxtext_initialize: nx_connect failed: %d\n", errno); g_exitcode = NXEXIT_NXCONNECT; return ERROR; } @@ -362,10 +362,10 @@ int nxtext_main(int argc, char **argv) /* Initialize NX */ ret = nxtext_initialize(); - message("nxtext_main: NX handle=%p\n", g_hnx); + printf("nxtext_main: NX handle=%p\n", g_hnx); if (!g_hnx || ret < 0) { - message("nxtext_main: Failed to get NX handle: %d\n", errno); + printf("nxtext_main: Failed to get NX handle: %d\n", errno); g_exitcode = NXEXIT_NXOPEN; goto errout; } @@ -375,7 +375,7 @@ int nxtext_main(int argc, char **argv) g_bghfont = nxf_getfonthandle(CONFIG_EXAMPLES_NXTEXT_BGFONTID); if (!g_bghfont) { - message("nxtext_main: Failed to get background font handle: %d\n", errno); + printf("nxtext_main: Failed to get background font handle: %d\n", errno); g_exitcode = NXEXIT_FONTOPEN; goto errout; } @@ -383,19 +383,19 @@ int nxtext_main(int argc, char **argv) g_puhfont = nxf_getfonthandle(CONFIG_EXAMPLES_NXTEXT_PUFONTID); if (!g_puhfont) { - message("nxtext_main: Failed to get pop-up font handle: %d\n", errno); + printf("nxtext_main: Failed to get pop-up font handle: %d\n", errno); g_exitcode = NXEXIT_FONTOPEN; goto errout; } /* Set the background to the configured background color */ - message("nxtext_main: Set background color=%d\n", CONFIG_EXAMPLES_NXTEXT_BGCOLOR); + printf("nxtext_main: Set background color=%d\n", CONFIG_EXAMPLES_NXTEXT_BGCOLOR); color = CONFIG_EXAMPLES_NXTEXT_BGCOLOR; ret = nx_setbgcolor(g_hnx, &color); if (ret < 0) { - message("nxtext_main: nx_setbgcolor failed: %d\n", errno); + printf("nxtext_main: nx_setbgcolor failed: %d\n", errno); g_exitcode = NXEXIT_NXSETBGCOLOR; goto errout_with_nx; } @@ -406,7 +406,7 @@ int nxtext_main(int argc, char **argv) ret = nx_requestbkgd(g_hnx, &g_nxtextcb, bgstate); if (ret < 0) { - message("nxtext_main: nx_setbgcolor failed: %d\n", errno); + printf("nxtext_main: nx_setbgcolor failed: %d\n", errno); g_exitcode = NXEXIT_NXREQUESTBKGD; goto errout_with_nx; } @@ -419,7 +419,7 @@ int nxtext_main(int argc, char **argv) { (void)sem_wait(&g_semevent); } - message("nxtext_main: Screen resolution (%d,%d)\n", g_xres, g_yres); + printf("nxtext_main: Screen resolution (%d,%d)\n", g_xres, g_yres); /* Now loop, adding text to the background and periodically presenting * a pop-up window. @@ -447,11 +447,11 @@ int nxtext_main(int argc, char **argv) /* Give keyboard input to the top window (which should be the pop-up) */ #ifdef CONFIG_NX_KBD - message("nxtext_main: Send keyboard input: %s\n", g_pumsg); + printf("nxtext_main: Send keyboard input: %s\n", g_pumsg); ret = nx_kbdin(g_hnx, strlen((FAR const char *)g_pumsg), g_pumsg); if (ret < 0) { - message("nxtext_main: nx_kbdin failed: %d\n", errno); + printf("nxtext_main: nx_kbdin failed: %d\n", errno); goto errout_with_hwnd; } #endif @@ -460,7 +460,7 @@ int nxtext_main(int argc, char **argv) { /* Destroy the pop-up window and restart the sequence */ - message("nxtext_main: Close pop-up\n"); + printf("nxtext_main: Close pop-up\n"); (void)nxpu_close(hwnd); popcnt = 0; } @@ -482,7 +482,7 @@ int nxtext_main(int argc, char **argv) errout_with_hwnd: if (popcnt >= 3) { - message("nxtext_main: Close pop-up\n"); + printf("nxtext_main: Close pop-up\n"); (void)nxpu_close(hwnd); } @@ -493,12 +493,12 @@ errout_with_nx: #ifdef CONFIG_NX_MULTIUSER /* Disconnect from the server */ - message("nxtext_main: Disconnect from the server\n"); + printf("nxtext_main: Disconnect from the server\n"); nx_disconnect(g_hnx); #else /* Close the server */ - message("nxtext_main: Close NX\n"); + printf("nxtext_main: Close NX\n"); nx_close(g_hnx); #endif errout: diff --git a/apps/examples/nxtext/nxtext_popup.c b/apps/examples/nxtext/nxtext_popup.c index 25c86b460..252ad3358 100644 --- a/apps/examples/nxtext/nxtext_popup.c +++ b/apps/examples/nxtext/nxtext_popup.c @@ -150,7 +150,7 @@ static inline int nxpu_setsize(NXWINDOW hwnd, FAR struct nxgl_size_s *size) int ret = nx_setsize(hwnd, size); if (ret < 0) { - message("nxpu_setsize: nx_setsize failed: %d\n", errno); + printf("nxpu_setsize: nx_setsize failed: %d\n", errno); g_exitcode = NXEXIT_NXSETSIZE; } return ret; @@ -165,7 +165,7 @@ static inline int nxpu_setposition(NXWINDOW hwnd, FAR struct nxgl_point_s *pos) int ret = nx_setposition(hwnd, pos); if (ret < 0) { - message("nxpu_setposition: nx_setposition failed: %d\n", errno); + printf("nxpu_setposition: nx_setposition failed: %d\n", errno); g_exitcode = NXEXIT_NXSETPOSITION; } return ret; @@ -185,7 +185,7 @@ static inline void nxpu_fillwindow(NXWINDOW hwnd, ret = nx_fill(hwnd, rect, st->wcolor); if (ret < 0) { - message("nxpu_fillwindow: nx_fill failed: %d\n", errno); + printf("nxpu_fillwindow: nx_fill failed: %d\n", errno); } /* Fill each character on the display (Only the characters within rect @@ -250,8 +250,8 @@ static void nxpu_position(NXWINDOW hwnd, FAR const struct nxgl_size_s *size, static void nxpu_mousein(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos, uint8_t buttons, FAR void *arg) { - message("nxpu_mousein: hwnd=%p pos=(%d,%d) button=%02x\n", - hwnd, pos->x, pos->y, buttons); + printf("nxpu_mousein: hwnd=%p pos=(%d,%d) button=%02x\n", + hwnd, pos->x, pos->y, buttons); } #endif @@ -339,7 +339,7 @@ NXWINDOW nxpu_open(void) /* Create a pop-up window */ - message("nxpu_open: Create pop-up\n"); + printf("nxpu_open: Create pop-up\n"); nxpu_initstate(); hwnd = nx_openwindow(g_hnx, &g_pucb, (FAR void *)&g_pustate); @@ -347,7 +347,7 @@ NXWINDOW nxpu_open(void) if (!hwnd) { - message("nxpu_open: nx_openwindow failed: %d\n", errno); + printf("nxpu_open: nx_openwindow failed: %d\n", errno); g_exitcode = NXEXIT_NXOPENWINDOW; goto errout_with_state; } @@ -364,7 +364,7 @@ NXWINDOW nxpu_open(void) /* Set the position for the pop-up window */ - message("nxpu_open: Set pop-up position to (%d,%d)\n", pt.x, pt.y); + printf("nxpu_open: Set pop-up position to (%d,%d)\n", pt.x, pt.y); ret = nxpu_setposition(hwnd, &pt); if (ret < 0) { @@ -400,7 +400,7 @@ int nxpu_close(NXWINDOW hwnd) ret = nx_closewindow(hwnd); if (ret < 0) { - message("nxpu_close: nx_closewindow failed: %d\n", errno); + printf("nxpu_close: nx_closewindow failed: %d\n", errno); g_exitcode = NXEXIT_NXCLOSEWINDOW; return ret; } diff --git a/apps/examples/nxtext/nxtext_putc.c b/apps/examples/nxtext/nxtext_putc.c index 9bfc28f2c..fddd98a80 100644 --- a/apps/examples/nxtext/nxtext_putc.c +++ b/apps/examples/nxtext/nxtext_putc.c @@ -313,7 +313,7 @@ nxtext_renderglyph(FAR struct nxtext_state_s *st, { /* Actually, the RENDERER never returns a failure */ - message("nxtext_renderglyph: RENDERER failed\n"); + printf("nxtext_renderglyph: RENDERER failed\n"); nxtext_freeglyph(glyph); glyph = NULL; } @@ -591,7 +591,7 @@ void nxtext_fillchar(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, &bm->pos, (unsigned int)glyph->stride); if (ret < 0) { - message("nxtext_fillchar: nx_bitmapwindow failed: %d\n", errno); + printf("nxtext_fillchar: nx_bitmapwindow failed: %d\n", errno); } } } diff --git a/apps/examples/nxtext/nxtext_server.c b/apps/examples/nxtext/nxtext_server.c index 119c1a412..6b5f7145d 100644 --- a/apps/examples/nxtext/nxtext_server.c +++ b/apps/examples/nxtext/nxtext_server.c @@ -91,11 +91,11 @@ int nxtext_server(int argc, char *argv[]) #if defined(CONFIG_EXAMPLES_NXTEXT_EXTERNINIT) /* Use external graphics driver initialization */ - message("nxtext_server: Initializing external graphics device\n"); + printf("nxtext_server: Initializing external graphics device\n"); dev = up_nxdrvinit(CONFIG_EXAMPLES_NXTEXT_DEVNO); if (!dev) { - message("nxtext_server: up_nxdrvinit failed, devno=%d\n", CONFIG_EXAMPLES_NXTEXT_DEVNO); + printf("nxtext_server: up_nxdrvinit failed, devno=%d\n", CONFIG_EXAMPLES_NXTEXT_DEVNO); g_exitcode = NXEXIT_EXTINITIALIZE; return ERROR; } @@ -103,11 +103,11 @@ int nxtext_server(int argc, char *argv[]) #elif defined(CONFIG_NX_LCDDRIVER) /* Initialize the LCD device */ - message("nxtext_server: Initializing LCD\n"); + printf("nxtext_server: Initializing LCD\n"); ret = up_lcdinitialize(); if (ret < 0) { - message("nxtext_server: up_lcdinitialize failed: %d\n", -ret); + printf("nxtext_server: up_lcdinitialize failed: %d\n", -ret); return 1; } @@ -116,7 +116,7 @@ int nxtext_server(int argc, char *argv[]) dev = up_lcdgetdev(CONFIG_EXAMPLES_NXTEXT_DEVNO); if (!dev) { - message("nxtext_server: up_lcdgetdev failed, devno=%d\n", CONFIG_EXAMPLES_NXTEXT_DEVNO); + printf("nxtext_server: up_lcdgetdev failed, devno=%d\n", CONFIG_EXAMPLES_NXTEXT_DEVNO); return 2; } @@ -126,18 +126,18 @@ int nxtext_server(int argc, char *argv[]) #else /* Initialize the frame buffer device */ - message("nxtext_server: Initializing framebuffer\n"); + printf("nxtext_server: Initializing framebuffer\n"); ret = up_fbinitialize(); if (ret < 0) { - message("nxtext_server: up_fbinitialize failed: %d\n", -ret); + printf("nxtext_server: up_fbinitialize failed: %d\n", -ret); return 1; } dev = up_fbgetvplane(CONFIG_EXAMPLES_NXTEXT_VPLANE); if (!dev) { - message("nxtext_server: up_fbgetvplane failed, vplane=%d\n", CONFIG_EXAMPLES_NXTEXT_VPLANE); + printf("nxtext_server: up_fbgetvplane failed, vplane=%d\n", CONFIG_EXAMPLES_NXTEXT_VPLANE); return 2; } #endif @@ -176,7 +176,7 @@ FAR void *nxtext_listener(FAR void *arg) * the server. */ - message("nxtext_listener: Lost server connection: %d\n", errno); + printf("nxtext_listener: Lost server connection: %d\n", errno); exit(NXEXIT_LOSTSERVERCONN); } @@ -186,7 +186,7 @@ FAR void *nxtext_listener(FAR void *arg) { g_connected = true; sem_post(&g_semevent); - message("nxtext_listener: Connected\n"); + printf("nxtext_listener: Connected\n"); } } } diff --git a/apps/examples/poll/host.c b/apps/examples/poll/host.c index 302cceb0f..3cd4095e2 100644 --- a/apps/examples/poll/host.c +++ b/apps/examples/poll/host.c @@ -89,7 +89,7 @@ int main(int argc, char **argv, char **envp) sockfd = socket(PF_INET, SOCK_STREAM, 0); if (sockfd < 0) { - message("client socket failure %d\n", errno); + printf("client socket failure %d\n", errno); goto errout_with_outbufs; } @@ -99,13 +99,13 @@ int main(int argc, char **argv, char **envp) myaddr.sin_port = htons(LISTENER_PORT); myaddr.sin_addr.s_addr = inet_addr(TARGETIP); - message("client: Connecting to %s...\n", TARGETIP); + printf("client: Connecting to %s...\n", TARGETIP); if (connect( sockfd, (struct sockaddr*)&myaddr, sizeof(struct sockaddr_in)) < 0) { - message("client: connect failure: %d\n", errno); + printf("client: connect failure: %d\n", errno); goto errout_with_socket; } - message("client: Connected\n"); + printf("client: Connected\n"); /* Then send and receive messages */ @@ -114,50 +114,50 @@ int main(int argc, char **argv, char **envp) sprintf(outbuf, "Remote message %d", i); len = strlen(outbuf); - message("client: Sending '%s' (%d bytes)\n", outbuf, len); + printf("client: Sending '%s' (%d bytes)\n", outbuf, len); nbytessent = send(sockfd, outbuf, len, 0); - message("client: Sent %d bytes\n", nbytessent); + printf("client: Sent %d bytes\n", nbytessent); if (nbytessent < 0) { - message("client: send failed: %d\n", errno); + printf("client: send failed: %d\n", errno); goto errout_with_socket; } else if (nbytessent != len) { - message("client: Bad send length: %d Expected: %d\n", nbytessent, len); + printf("client: Bad send length: %d Expected: %d\n", nbytessent, len); goto errout_with_socket; } - message("client: Receiving...\n"); + printf("client: Receiving...\n"); nbytesrecvd = recv(sockfd, inbuf, IOBUFFER_SIZE, 0); if (nbytesrecvd < 0) { - message("client: recv failed: %d\n", errno); + printf("client: recv failed: %d\n", errno); goto errout_with_socket; } else if (nbytesrecvd == 0) { - message("client: The server broke the connections\n"); + printf("client: The server broke the connections\n"); goto errout_with_socket; } inbuf[nbytesrecvd] = '\0'; - message("client: Received '%s' (%d bytes)\n", inbuf, nbytesrecvd); + printf("client: Received '%s' (%d bytes)\n", inbuf, nbytesrecvd); if (nbytesrecvd != len) { - message("client: Bad recv length: %d Expected: %d\n", nbytesrecvd, len); + printf("client: Bad recv length: %d Expected: %d\n", nbytesrecvd, len); goto errout_with_socket; } else if (memcmp(inbuf, outbuf, len) != 0) { - message("client: Received outbuf does not match sent outbuf\n"); + printf("client: Received outbuf does not match sent outbuf\n"); goto errout_with_socket; } - message("client: Sleeping\n"); + printf("client: Sleeping\n"); sleep(8); } diff --git a/apps/examples/poll/net_listener.c b/apps/examples/poll/net_listener.c index 841d7d95c..996e63c3b 100644 --- a/apps/examples/poll/net_listener.c +++ b/apps/examples/poll/net_listener.c @@ -94,7 +94,7 @@ struct net_listener_s static bool net_closeclient(struct net_listener_s *nls, int sd) { - message("net_listener: Closing host side connection sd=%d\n", sd); + printf("net_listener: Closing host side connection sd=%d\n", sd); close(sd); FD_CLR(sd, &nls->master); @@ -123,13 +123,13 @@ static inline bool net_incomingdata(struct net_listener_s *nls, int sd) for (;;) #endif { - message("net_listener: Read data from sd=%d\n", sd); + printf("net_listener: Read data from sd=%d\n", sd); ret = recv(sd, nls->buffer, IOBUFFER_SIZE, 0); if (ret < 0) { if (errno != EINTR) { - message("net_listener: recv failed sd=%d: %d\n", sd, errno); + printf("net_listener: recv failed sd=%d: %d\n", sd, errno); if (errno != EAGAIN) { net_closeclient(nls, sd); @@ -139,14 +139,14 @@ static inline bool net_incomingdata(struct net_listener_s *nls, int sd) } else if (ret == 0) { - message("net_listener: Client connection lost sd=%d\n", sd); + printf("net_listener: Client connection lost sd=%d\n", sd); net_closeclient(nls, sd); return false; } else { nls->buffer[ret]='\0'; - message("poll_listener: Read '%s' (%d bytes)\n", nls->buffer, ret); + printf("poll_listener: Read '%s' (%d bytes)\n", nls->buffer, ret); /* Echo the data back to the client */ @@ -157,7 +157,7 @@ static inline bool net_incomingdata(struct net_listener_s *nls, int sd) { if (errno != EINTR) { - message("net_listener: Send failed sd=%d: %d\n", sd, errno); + printf("net_listener: Send failed sd=%d: %d\n", sd, errno); net_closeclient(nls, sd); return false; } @@ -187,12 +187,12 @@ static inline bool net_connection(struct net_listener_s *nls) for (;;) #endif { - message("net_listener: Accepting new connection on sd=%d\n", nls->listensd); + printf("net_listener: Accepting new connection on sd=%d\n", nls->listensd); sd = accept(nls->listensd, NULL, NULL); if (sd < 0) { - message("net_listener: accept failed: %d\n", errno); + printf("net_listener: accept failed: %d\n", errno); if (errno != EINTR) { @@ -203,7 +203,7 @@ static inline bool net_connection(struct net_listener_s *nls) { /* Add the new connection to the master set */ - message("net_listener: Connection accepted for sd=%d\n", sd); + printf("net_listener: Connection accepted for sd=%d\n", sd); FD_SET(sd, &nls->master); if (sd > nls->mxsd) @@ -227,11 +227,11 @@ static inline bool net_mksocket(struct net_listener_s *nls) /* Create a listening socket */ - message("net_listener: Initializing listener socket\n"); + printf("net_listener: Initializing listener socket\n"); nls->listensd = socket(AF_INET, SOCK_STREAM, 0); if (nls->listensd < 0) { - message("net_listener: socket failed: %d\n", errno); + printf("net_listener: socket failed: %d\n", errno); return false; } @@ -241,7 +241,7 @@ static inline bool net_mksocket(struct net_listener_s *nls) ret = setsockopt(nls->listensd, SOL_SOCKET, SO_REUSEADDR, (char*)&value, sizeof(int)); if (ret < 0) { - message("net_listener: setsockopt failed: %d\n", errno); + printf("net_listener: setsockopt failed: %d\n", errno); close(nls->listensd); return false; } @@ -252,7 +252,7 @@ static inline bool net_mksocket(struct net_listener_s *nls) ret = ioctl(nls->listensd, FIONBIO, (char *)&value); if (ret < 0) { - message("net_listener: ioctl failed: %d\n", errno); + printf("net_listener: ioctl failed: %d\n", errno); close(nls->listensd); return false; } @@ -267,7 +267,7 @@ static inline bool net_mksocket(struct net_listener_s *nls) ret = bind(nls->listensd, (struct sockaddr *)&nls->addr, sizeof(struct sockaddr_in)); if (ret < 0) { - message("net_listener: bind failed: %d\n", errno); + printf("net_listener: bind failed: %d\n", errno); close(nls->listensd); return false; } @@ -277,7 +277,7 @@ static inline bool net_mksocket(struct net_listener_s *nls) ret = listen(nls->listensd, 32); if (ret < 0) { - message("net_listener: bind failed: %d\n", errno); + printf("net_listener: bind failed: %d\n", errno); close(nls->listensd); return false; } @@ -372,12 +372,12 @@ void *net_listener(pthread_addr_t pvarg) { /* Wait on select */ - message("net_listener: Calling select(), listener sd=%d\n", nls.listensd); + printf("net_listener: Calling select(), listener sd=%d\n", nls.listensd); memcpy(&nls.working, &nls.master, sizeof(fd_set)); ret = select(nls.mxsd + 1, (FAR fd_set*)&nls.working, (FAR fd_set*)NULL, (FAR fd_set*)NULL, &timeout); if (ret < 0) { - message("net_listener: select failed: %d\n", errno); + printf("net_listener: select failed: %d\n", errno); break; } @@ -385,7 +385,7 @@ void *net_listener(pthread_addr_t pvarg) if (ret == 0) { - message("net_listener: Timeout\n"); + printf("net_listener: Timeout\n"); continue; } @@ -400,7 +400,7 @@ void *net_listener(pthread_addr_t pvarg) { /* Yes, is it our listener? */ - message("net_listener: Activity on sd=%d\n", i); + printf("net_listener: Activity on sd=%d\n", i); nsds--; if (i == nls.listensd) diff --git a/apps/examples/poll/net_reader.c b/apps/examples/poll/net_reader.c index beecee275..d50181bf7 100644 --- a/apps/examples/poll/net_reader.c +++ b/apps/examples/poll/net_reader.c @@ -155,23 +155,23 @@ static void net_receive(int sd) if (ret < 0) { - message("net_reader: select failed: %d\n", errno); + printf("net_reader: select failed: %d\n", errno); return; } else if (ret == 0) { - message("net_reader: Timeout\n"); + printf("net_reader: Timeout\n"); } else { - message("net_reader: Read data from sd=%d\n", sd); + printf("net_reader: Read data from sd=%d\n", sd); memset(buffer, '?', IOBUFFER_SIZE); /* Just to make sure we really receive something */ ret = recv(sd, buffer, IOBUFFER_SIZE, 0); if (ret < 0) { if (errno != EINTR) { - message("net_reader: recv failed sd=%d: %d\n", sd, errno); + printf("net_reader: recv failed sd=%d: %d\n", sd, errno); if (errno != EAGAIN) { return; @@ -180,13 +180,13 @@ static void net_receive(int sd) } else if (ret == 0) { - message("net_reader: Client connection lost sd=%d\n", sd); + printf("net_reader: Client connection lost sd=%d\n", sd); return; } else { buffer[ret]='\0'; - message("net_reader: Read '%s' (%d bytes)\n", buffer, ret); + printf("net_reader: Read '%s' (%d bytes)\n", buffer, ret); /* Echo the data back to the client */ @@ -197,7 +197,7 @@ static void net_receive(int sd) { if (errno != EINTR) { - message("net_reader: Send failed sd=%d: %d\n", sd, errno); + printf("net_reader: Send failed sd=%d: %d\n", sd, errno); return; } } @@ -240,7 +240,7 @@ void *net_reader(pthread_addr_t pvarg) listensd = socket(PF_INET, SOCK_STREAM, 0); if (listensd < 0) { - message("net_reader: socket failure: %d\n", errno); + printf("net_reader: socket failure: %d\n", errno); goto errout; } @@ -249,7 +249,7 @@ void *net_reader(pthread_addr_t pvarg) optval = 1; if (setsockopt(listensd, SOL_SOCKET, SO_REUSEADDR, (void*)&optval, sizeof(int)) < 0) { - message("net_reader: setsockopt SO_REUSEADDR failure: %d\n", errno); + printf("net_reader: setsockopt SO_REUSEADDR failure: %d\n", errno); goto errout_with_listensd; } @@ -261,7 +261,7 @@ void *net_reader(pthread_addr_t pvarg) if (bind(listensd, (struct sockaddr*)&addr, sizeof(struct sockaddr_in)) < 0) { - message("net_reader: bind failure: %d\n", errno); + printf("net_reader: bind failure: %d\n", errno); goto errout_with_listensd; } @@ -269,7 +269,7 @@ void *net_reader(pthread_addr_t pvarg) if (listen(listensd, 5) < 0) { - message("net_reader: listen failure %d\n", errno); + printf("net_reader: listen failure %d\n", errno); goto errout_with_listensd; } @@ -279,15 +279,15 @@ void *net_reader(pthread_addr_t pvarg) { /* Accept only one connection */ - message("net_reader: Accepting new connections on port %d\n", LISTENER_PORT); + printf("net_reader: Accepting new connections on port %d\n", LISTENER_PORT); addrlen = sizeof(struct sockaddr_in); acceptsd = accept(listensd, (struct sockaddr*)&addr, &addrlen); if (acceptsd < 0) { - message("net_reader: accept failure: %d\n", errno); + printf("net_reader: accept failure: %d\n", errno); continue; } - message("net_reader: Connection accepted on sd=%d\n", acceptsd); + printf("net_reader: Connection accepted on sd=%d\n", acceptsd); /* Configure to "linger" until all data is sent when the socket is closed */ @@ -296,7 +296,7 @@ void *net_reader(pthread_addr_t pvarg) ling.l_linger = 30; /* timeout is seconds */ if (setsockopt(acceptsd, SOL_SOCKET, SO_LINGER, &ling, sizeof(struct linger)) < 0) { - message("net_reader: setsockopt SO_LINGER failure: %d\n", errno); + printf("net_reader: setsockopt SO_LINGER failure: %d\n", errno); goto errout_with_acceptsd; } #endif @@ -305,7 +305,7 @@ void *net_reader(pthread_addr_t pvarg) net_receive(acceptsd); - message("net_reader: Closing sd=%d\n", acceptsd); + printf("net_reader: Closing sd=%d\n", acceptsd); close(acceptsd); } diff --git a/apps/examples/poll/poll_internal.h b/apps/examples/poll/poll_internal.h index b621531b3..534a6e2ec 100644 --- a/apps/examples/poll/poll_internal.h +++ b/apps/examples/poll/poll_internal.h @@ -71,31 +71,6 @@ # undef HAVE_NETPOLL #endif -/* If debug is enabled, then use syslog so that OS debug output and - * the test output are synchronized. - * - * These macros will differ depending upon if the toolchain supports - * macros with a variable number of arguments or not. - */ - -#ifdef CONFIG_CPP_HAVE_VARARGS -# ifdef CONFIG_DEBUG -# define message(...) syslog(__VA_ARGS__) -# define msgflush() -# else -# define message(...) printf(__VA_ARGS__) -# define msgflush() fflush(stdout) -# endif -#else -# ifdef CONFIG_DEBUG -# define message syslog -# define msgflush() -# else -# define message printf -# define msgflush() fflush(stdout) -# endif -#endif - #define FIFO_PATH1 "/dev/fifo0" #define FIFO_PATH2 "/dev/fifo1" diff --git a/apps/examples/poll/poll_listener.c b/apps/examples/poll/poll_listener.c index e253d59ff..23272d0a5 100644 --- a/apps/examples/poll/poll_listener.c +++ b/apps/examples/poll/poll_listener.c @@ -104,12 +104,12 @@ void *poll_listener(pthread_addr_t pvarg) /* Open the FIFO for non-blocking read */ - message("poll_listener: Opening %s for non-blocking read\n", FIFO_PATH1); + printf("poll_listener: Opening %s for non-blocking read\n", FIFO_PATH1); fd = open(FIFO_PATH1, O_RDONLY|O_NONBLOCK); if (fd < 0) { - message("poll_listener: ERROR Failed to open FIFO %s: %d\n", - FIFO_PATH1, errno); + printf("poll_listener: ERROR Failed to open FIFO %s: %d\n", + FIFO_PATH1, errno); (void)close(fd); return (void*)-1; } @@ -118,7 +118,7 @@ void *poll_listener(pthread_addr_t pvarg) for (;;) { - message("poll_listener: Calling poll()\n"); + printf("poll_listener: Calling poll()\n"); memset(fds, 0, sizeof(struct pollfd)*NPOLLFDS); #ifdef HAVE_CONSOLE @@ -135,19 +135,19 @@ void *poll_listener(pthread_addr_t pvarg) ret = poll(fds, NPOLLFDS, POLL_LISTENER_DELAY); - message("\npoll_listener: poll returned: %d\n", ret); + printf("\npoll_listener: poll returned: %d\n", ret); if (ret < 0) { - message("poll_listener: ERROR poll failed: %d\n", errno); + printf("poll_listener: ERROR poll failed: %d\n", errno); } else if (ret == 0) { - message("poll_listener: Timeout\n"); + printf("poll_listener: Timeout\n"); timeout = true; } else if (ret > NPOLLFDS) { - message("poll_listener: ERROR poll reported: %d\n", errno); + printf("poll_listener: ERROR poll reported: %d\n", errno); } else { @@ -157,13 +157,13 @@ void *poll_listener(pthread_addr_t pvarg) nevents = 0; for (i = 0; i < NPOLLFDS; i++) { - message("poll_listener: FIFO revents[%d]=%02x\n", i, fds[i].revents); + printf("poll_listener: FIFO revents[%d]=%02x\n", i, fds[i].revents); if (timeout) { if (fds[i].revents != 0) { - message("poll_listener: ERROR? expected revents=00, received revents[%d]=%02x\n", - fds[i].revents, i); + printf("poll_listener: ERROR? expected revents=00, received revents[%d]=%02x\n", + fds[i].revents, i); } } else if (pollin) @@ -174,15 +174,15 @@ void *poll_listener(pthread_addr_t pvarg) } else if (fds[i].revents != 0) { - message("poll_listener: ERROR unexpected revents[%d]=%02x\n", - i, fds[i].revents); + printf("poll_listener: ERROR unexpected revents[%d]=%02x\n", + i, fds[i].revents); } } } if (pollin && nevents != ret) { - message("poll_listener: ERROR found %d events, poll reported %d\n", nevents, ret); + printf("poll_listener: ERROR found %d events, poll reported %d\n", nevents, ret); } /* In any event, read until the pipe/serial is empty */ @@ -224,12 +224,12 @@ void *poll_listener(pthread_addr_t pvarg) { if ((fds[i].revents & POLLIN) != 0) { - message("poll_listener: ERROR no read data[%d]\n", i); + printf("poll_listener: ERROR no read data[%d]\n", i); } } else if (errno != EINTR) { - message("poll_listener: read[%d] failed: %d\n", i, errno); + printf("poll_listener: read[%d] failed: %d\n", i, errno); } nbytes = 0; } @@ -237,12 +237,12 @@ void *poll_listener(pthread_addr_t pvarg) { if (timeout) { - message("poll_listener: ERROR? Poll timeout, but data read[%d]\n", i); - message(" (might just be a race condition)\n"); + printf("poll_listener: ERROR? Poll timeout, but data read[%d]\n", i); + printf(" (might just be a race condition)\n"); } buffer[nbytes] = '\0'; - message("poll_listener: Read[%d] '%s' (%d bytes)\n", i, buffer, nbytes); + printf("poll_listener: Read[%d] '%s' (%d bytes)\n", i, buffer, nbytes); } /* Suppress error report if no read data on the next time through */ @@ -254,7 +254,7 @@ void *poll_listener(pthread_addr_t pvarg) /* Make sure that everything is displayed */ - msgflush(); + fflush(stdout); } /* Won't get here */ diff --git a/apps/examples/poll/poll_main.c b/apps/examples/poll/poll_main.c index 5aa62805f..11479e1a3 100644 --- a/apps/examples/poll/poll_main.c +++ b/apps/examples/poll/poll_main.c @@ -98,20 +98,20 @@ int poll_main(int argc, char *argv[]) /* Open FIFOs */ - message("\npoll_main: Creating FIFO %s\n", FIFO_PATH1); + printf("\npoll_main: Creating FIFO %s\n", FIFO_PATH1); ret = mkfifo(FIFO_PATH1, 0666); if (ret < 0) { - message("poll_main: mkfifo failed: %d\n", errno); + printf("poll_main: mkfifo failed: %d\n", errno); exitcode = 1; goto errout; } - message("\npoll_main: Creating FIFO %s\n", FIFO_PATH2); + printf("\npoll_main: Creating FIFO %s\n", FIFO_PATH2); ret = mkfifo(FIFO_PATH2, 0666); if (ret < 0) { - message("poll_main: mkfifo failed: %d\n", errno); + printf("poll_main: mkfifo failed: %d\n", errno); exitcode = 2; goto errout; } @@ -121,8 +121,8 @@ int poll_main(int argc, char *argv[]) fd1 = open(FIFO_PATH1, O_WRONLY); if (fd1 < 0) { - message("poll_main: Failed to open FIFO %s for writing, errno=%d\n", - FIFO_PATH1, errno); + printf("poll_main: Failed to open FIFO %s for writing, errno=%d\n", + FIFO_PATH1, errno); exitcode = 3; goto errout; } @@ -130,47 +130,47 @@ int poll_main(int argc, char *argv[]) fd2 = open(FIFO_PATH2, O_WRONLY); if (fd2 < 0) { - message("poll_main: Failed to open FIFO %s for writing, errno=%d\n", - FIFO_PATH2, errno); + printf("poll_main: Failed to open FIFO %s for writing, errno=%d\n", + FIFO_PATH2, errno); exitcode = 4; goto errout; } /* Start the listeners */ - message("poll_main: Starting poll_listener thread\n"); + printf("poll_main: Starting poll_listener thread\n"); ret = pthread_create(&tid1, NULL, poll_listener, NULL); if (ret != 0) { - message("poll_main: Failed to create poll_listener thread: %d\n", ret); + printf("poll_main: Failed to create poll_listener thread: %d\n", ret); exitcode = 5; goto errout; } - message("poll_main: Starting select_listener thread\n"); + printf("poll_main: Starting select_listener thread\n"); ret = pthread_create(&tid2, NULL, select_listener, NULL); if (ret != 0) { - message("poll_main: Failed to create select_listener thread: %d\n", ret); + printf("poll_main: Failed to create select_listener thread: %d\n", ret); exitcode = 6; goto errout; } #ifdef HAVE_NETPOLL #ifdef CONFIG_NET_TCPBACKLOG - message("poll_main: Starting net_listener thread\n"); + printf("poll_main: Starting net_listener thread\n"); ret = pthread_create(&tid3, NULL, net_listener, NULL); #else - message("poll_main: Starting net_reader thread\n"); + printf("poll_main: Starting net_reader thread\n"); ret = pthread_create(&tid3, NULL, net_reader, NULL); #endif if (ret != 0) { - message("poll_main: Failed to create net_listener thread: %d\n", ret); + printf("poll_main: Failed to create net_listener thread: %d\n", ret); } #endif @@ -186,7 +186,7 @@ int poll_main(int argc, char *argv[]) nbytes = write(fd1, buffer, strlen(buffer)); if (nbytes < 0) { - message("poll_main: Write to fd1 failed: %d\n", errno); + printf("poll_main: Write to fd1 failed: %d\n", errno); exitcode = 7; goto errout; } @@ -194,13 +194,13 @@ int poll_main(int argc, char *argv[]) nbytes = write(fd2, buffer, strlen(buffer)); if (nbytes < 0) { - message("poll_main: Write fd2 failed: %d\n", errno); + printf("poll_main: Write fd2 failed: %d\n", errno); exitcode = 8; goto errout; } - message("\npoll_main: Sent '%s' (%d bytes)\n", buffer, nbytes); - msgflush(); + printf("\npoll_main: Sent '%s' (%d bytes)\n", buffer, nbytes); + fflush(stdout); /* Wait awhile. This delay should be long enough that the * listener will timeout. diff --git a/apps/examples/poll/select_listener.c b/apps/examples/poll/select_listener.c index 12c4e4453..9e35f0864 100644 --- a/apps/examples/poll/select_listener.c +++ b/apps/examples/poll/select_listener.c @@ -90,12 +90,12 @@ void *select_listener(pthread_addr_t pvarg) /* Open the FIFO for non-blocking read */ - message("select_listener: Opening %s for non-blocking read\n", FIFO_PATH2); + printf("select_listener: Opening %s for non-blocking read\n", FIFO_PATH2); fd = open(FIFO_PATH2, O_RDONLY|O_NONBLOCK); if (fd < 0) { - message("select_listener: ERROR Failed to open FIFO %s: %d\n", - FIFO_PATH2, errno); + printf("select_listener: ERROR Failed to open FIFO %s: %d\n", + FIFO_PATH2, errno); (void)close(fd); return (void*)-1; } @@ -104,7 +104,7 @@ void *select_listener(pthread_addr_t pvarg) for (;;) { - message("select_listener: Calling select()\n"); + printf("select_listener: Calling select()\n"); FD_ZERO(&rfds); FD_SET(fd, &rfds); @@ -116,22 +116,22 @@ void *select_listener(pthread_addr_t pvarg) ready = false; ret = select(fd+1, (FAR fd_set*)&rfds, (FAR fd_set*)NULL, (FAR fd_set*)NULL, &tv); - message("\nselect_listener: select returned: %d\n", ret); + printf("\nselect_listener: select returned: %d\n", ret); if (ret < 0) { - message("select_listener: ERROR select failed: %d\n", errno); + printf("select_listener: ERROR select failed: %d\n", errno); } else if (ret == 0) { - message("select_listener: Timeout\n"); + printf("select_listener: Timeout\n"); timeout = true; } else { if (ret != 1) { - message("select_listener: ERROR poll reported: %d\n", ret); + printf("select_listener: ERROR poll reported: %d\n", ret); } else { @@ -140,7 +140,7 @@ void *select_listener(pthread_addr_t pvarg) if (!FD_ISSET(fd, rfds)) { - message("select_listener: ERROR fd=%d not in fd_set\n", fd); + printf("select_listener: ERROR fd=%d not in fd_set\n", fd); } } @@ -155,12 +155,12 @@ void *select_listener(pthread_addr_t pvarg) { if (ready) { - message("select_listener: ERROR no read data\n"); + printf("select_listener: ERROR no read data\n"); } } else if (errno != EINTR) { - message("select_listener: read failed: %d\n", errno); + printf("select_listener: read failed: %d\n", errno); } nbytes = 0; } @@ -168,12 +168,12 @@ void *select_listener(pthread_addr_t pvarg) { if (timeout) { - message("select_listener: ERROR? Poll timeout, but data read\n"); - message(" (might just be a race condition)\n"); + printf("select_listener: ERROR? Poll timeout, but data read\n"); + printf(" (might just be a race condition)\n"); } buffer[nbytes] = '\0'; - message("select_listener: Read '%s' (%d bytes)\n", buffer, nbytes); + printf("select_listener: Read '%s' (%d bytes)\n", buffer, nbytes); } timeout = false; @@ -183,7 +183,7 @@ void *select_listener(pthread_addr_t pvarg) /* Make sure that everything is displayed */ - msgflush(); + fflush(stdout); } /* Won't get here */ diff --git a/apps/examples/pwm/pwm.h b/apps/examples/pwm/pwm.h index db59bb051..c1c6820e8 100644 --- a/apps/examples/pwm/pwm.h +++ b/apps/examples/pwm/pwm.h @@ -88,26 +88,6 @@ # define CONFIG_EXAMPLES_PWM_PULSECOUNT 0 #endif -/* Debug ********************************************************************/ - -#ifdef CONFIG_CPP_HAVE_VARARGS -# ifdef CONFIG_DEBUG -# define message(...) syslog(__VA_ARGS__) -# define msgflush() -# else -# define message(...) printf(__VA_ARGS__) -# define msgflush() fflush(stdout) -# endif -#else -# ifdef CONFIG_DEBUG -# define message syslog -# define msgflush() -# else -# define message printf -# define msgflush() fflush(stdout) -# endif -#endif - /**************************************************************************** * Public Types ****************************************************************************/ diff --git a/apps/examples/pwm/pwm_main.c b/apps/examples/pwm/pwm_main.c index 683ed355a..e9a6cc50e 100644 --- a/apps/examples/pwm/pwm_main.c +++ b/apps/examples/pwm/pwm_main.c @@ -116,28 +116,28 @@ static void pwm_devpath(FAR struct pwm_state_s *pwm, FAR const char *devpath) static void pwm_help(FAR struct pwm_state_s *pwm) { - message("Usage: pwm [OPTIONS]\n"); - message("\nArguments are \"sticky\". For example, once the PWM frequency is\n"); - message("specified, that frequency will be re-used until it is changed.\n"); - message("\n\"sticky\" OPTIONS include:\n"); - message(" [-p devpath] selects the PWM device. " - "Default: %s Current: %s\n", - CONFIG_EXAMPLES_PWM_DEVPATH, pwm->devpath ? pwm->devpath : "NONE"); - message(" [-f frequency] selects the pulse frequency. " - "Default: %d Hz Current: %d Hz\n", - CONFIG_EXAMPLES_PWM_FREQUENCY, pwm->freq); - message(" [-d duty] selects the pulse duty as a percentage. " - "Default: %d %% Current: %d %%\n", - CONFIG_EXAMPLES_PWM_DUTYPCT, pwm->duty); + printf("Usage: pwm [OPTIONS]\n"); + printf("\nArguments are \"sticky\". For example, once the PWM frequency is\n"); + printf("specified, that frequency will be re-used until it is changed.\n"); + printf("\n\"sticky\" OPTIONS include:\n"); + printf(" [-p devpath] selects the PWM device. " + "Default: %s Current: %s\n", + CONFIG_EXAMPLES_PWM_DEVPATH, pwm->devpath ? pwm->devpath : "NONE"); + printf(" [-f frequency] selects the pulse frequency. " + "Default: %d Hz Current: %d Hz\n", + CONFIG_EXAMPLES_PWM_FREQUENCY, pwm->freq); + printf(" [-d duty] selects the pulse duty as a percentage. " + "Default: %d %% Current: %d %%\n", + CONFIG_EXAMPLES_PWM_DUTYPCT, pwm->duty); #ifdef CONFIG_PWM_PULSECOUNT - message(" [-n count] selects the pulse count. " - "Default: %d Current: %d\n", - CONFIG_EXAMPLES_PWM_PULSECOUNT, pwm->count); + printf(" [-n count] selects the pulse count. " + "Default: %d Current: %d\n", + CONFIG_EXAMPLES_PWM_PULSECOUNT, pwm->count); #endif - message(" [-t duration] is the duration of the pulse train in seconds. " - "Default: %d Current: %d\n", - CONFIG_EXAMPLES_PWM_DURATION, pwm->duration); - message(" [-h] shows this message and exits\n"); + printf(" [-t duration] is the duration of the pulse train in seconds. " + "Default: %d Current: %d\n", + CONFIG_EXAMPLES_PWM_DURATION, pwm->duration); + printf(" [-h] shows this message and exits\n"); } /**************************************************************************** @@ -191,7 +191,7 @@ static void parse_args(FAR struct pwm_state_s *pwm, int argc, FAR char **argv) ptr = argv[index]; if (ptr[0] != '-') { - message("Invalid options format: %s\n", ptr); + printf("Invalid options format: %s\n", ptr); exit(0); } @@ -201,7 +201,7 @@ static void parse_args(FAR struct pwm_state_s *pwm, int argc, FAR char **argv) nargs = arg_decimal(&argv[index], &value); if (value < 1) { - message("Frequency out of range: %ld\n", value); + printf("Frequency out of range: %ld\n", value); exit(1); } @@ -213,7 +213,7 @@ static void parse_args(FAR struct pwm_state_s *pwm, int argc, FAR char **argv) nargs = arg_decimal(&argv[index], &value); if (value < 1 || value > 99) { - message("Duty out of range: %ld\n", value); + printf("Duty out of range: %ld\n", value); exit(1); } @@ -226,7 +226,7 @@ static void parse_args(FAR struct pwm_state_s *pwm, int argc, FAR char **argv) nargs = arg_decimal(&argv[index], &value); if (value < 0) { - message("Count must be non-negative: %ld\n", value); + printf("Count must be non-negative: %ld\n", value); exit(1); } @@ -245,7 +245,7 @@ static void parse_args(FAR struct pwm_state_s *pwm, int argc, FAR char **argv) nargs = arg_decimal(&argv[index], &value); if (value < 1 || value > INT_MAX) { - message("Duration out of range: %ld\n", value); + printf("Duration out of range: %ld\n", value); exit(1); } @@ -258,7 +258,7 @@ static void parse_args(FAR struct pwm_state_s *pwm, int argc, FAR char **argv) exit(0); default: - message("Unsupported option: %s\n", ptr); + printf("Unsupported option: %s\n", ptr); pwm_help(pwm); exit(1); } @@ -316,7 +316,7 @@ int pwm_main(int argc, char *argv[]) ret = pwm_devinit(); if (ret != OK) { - message("pwm_main: pwm_devinit failed: %d\n", ret); + printf("pwm_main: pwm_devinit failed: %d\n", ret); goto errout; } @@ -325,7 +325,7 @@ int pwm_main(int argc, char *argv[]) fd = open(g_pwmstate.devpath, O_RDONLY); if (fd < 0) { - message("pwm_main: open %s failed: %d\n", g_pwmstate.devpath, errno); + printf("pwm_main: open %s failed: %d\n", g_pwmstate.devpath, errno); goto errout; } @@ -336,19 +336,19 @@ int pwm_main(int argc, char *argv[]) #ifdef CONFIG_PWM_PULSECOUNT info.count = g_pwmstate.count; - message("pwm_main: starting output with frequency: %d duty: %08x count: %d\n", - info.frequency, info.duty, info.count); + printf("pwm_main: starting output with frequency: %d duty: %08x count: %d\n", + info.frequency, info.duty, info.count); #else - message("pwm_main: starting output with frequency: %d duty: %08x\n", - info.frequency, info.duty); + printf("pwm_main: starting output with frequency: %d duty: %08x\n", + info.frequency, info.duty); #endif ret = ioctl(fd, PWMIOC_SETCHARACTERISTICS, (unsigned long)((uintptr_t)&info)); if (ret < 0) { - message("pwm_main: ioctl(PWMIOC_SETCHARACTERISTICS) failed: %d\n", errno); + printf("pwm_main: ioctl(PWMIOC_SETCHARACTERISTICS) failed: %d\n", errno); goto errout_with_dev; } @@ -359,7 +359,7 @@ int pwm_main(int argc, char *argv[]) ret = ioctl(fd, PWMIOC_START, 0); if (ret < 0) { - message("pwm_main: ioctl(PWMIOC_START) failed: %d\n", errno); + printf("pwm_main: ioctl(PWMIOC_START) failed: %d\n", errno); goto errout_with_dev; } @@ -377,23 +377,23 @@ int pwm_main(int argc, char *argv[]) /* Then stop the pulse train */ - message("pwm_main: stopping output\n"); + printf("pwm_main: stopping output\n"); ret = ioctl(fd, PWMIOC_STOP, 0); if (ret < 0) { - message("pwm_main: ioctl(PWMIOC_STOP) failed: %d\n", errno); + printf("pwm_main: ioctl(PWMIOC_STOP) failed: %d\n", errno); goto errout_with_dev; } } close(fd); - msgflush(); + fflush(stdout); return OK; errout_with_dev: close(fd); errout: - msgflush(); + fflush(stdout); return ERROR; } diff --git a/apps/examples/qencoder/qe.h b/apps/examples/qencoder/qe.h index 3c20511ca..1fd09d2ea 100644 --- a/apps/examples/qencoder/qe.h +++ b/apps/examples/qencoder/qe.h @@ -73,26 +73,6 @@ # define CONFIG_EXAMPLES_QENCODER_DELAY 100 #endif -/* Debug ********************************************************************/ - -#ifdef CONFIG_CPP_HAVE_VARARGS -# ifdef CONFIG_DEBUG -# define message(...) syslog(__VA_ARGS__) -# define msgflush() -# else -# define message(...) printf(__VA_ARGS__) -# define msgflush() fflush(stdout) -# endif -#else -# ifdef CONFIG_DEBUG -# define message syslog -# define msgflush() -# else -# define message printf -# define msgflush() fflush(stdout) -# endif -#endif - /**************************************************************************** * Public Types ****************************************************************************/ diff --git a/apps/examples/qencoder/qe_main.c b/apps/examples/qencoder/qe_main.c index 0bcf56763..5085c7197 100644 --- a/apps/examples/qencoder/qe_main.c +++ b/apps/examples/qencoder/qe_main.c @@ -108,13 +108,13 @@ static void qe_devpath(FAR const char *devpath) #ifdef CONFIG_NSH_BUILTIN_APPS static void qe_help(void) { - message("\nUsage: qe [OPTIONS]\n\n"); - message("OPTIONS include:\n"); - message(" [-p devpath] QE device path\n"); - message(" [-n samples] Number of samples\n"); - message(" [-t msec] Delay between samples (msec)\n"); - message(" [-r] Reset the position to zero\n"); - message(" [-h] Shows this message and exits\n\n"); + printf("\nUsage: qe [OPTIONS]\n\n"); + printf("OPTIONS include:\n"); + printf(" [-p devpath] QE device path\n"); + printf(" [-n samples] Number of samples\n"); + printf(" [-t msec] Delay between samples (msec)\n"); + printf(" [-r] Reset the position to zero\n"); + printf(" [-h] Shows this message and exits\n\n"); } #endif @@ -178,7 +178,7 @@ static void parse_args(int argc, FAR char **argv) ptr = argv[index]; if (ptr[0] != '-') { - message("Invalid options format: %s\n", ptr); + printf("Invalid options format: %s\n", ptr); exit(0); } @@ -188,7 +188,7 @@ static void parse_args(int argc, FAR char **argv) nargs = arg_decimal(&argv[index], &value); if (value < 0 || value > INT_MAX) { - message("Sample count out of range: %ld\n", value); + printf("Sample count out of range: %ld\n", value); exit(1); } @@ -206,7 +206,7 @@ static void parse_args(int argc, FAR char **argv) nargs = arg_decimal(&argv[index], &value); if (value < 0 || value > INT_MAX) { - message("Sample delay out of range: %ld\n", value); + printf("Sample delay out of range: %ld\n", value); exit(1); } @@ -224,7 +224,7 @@ static void parse_args(int argc, FAR char **argv) exit(EXIT_SUCCESS); default: - message("Unsupported option: %s\n", ptr); + printf("Unsupported option: %s\n", ptr); qe_help(); exit(EXIT_FAILURE); } @@ -262,11 +262,11 @@ int qe_main(int argc, char *argv[]) * this test. */ - message("qe_main: Initializing external encoder(s)\n"); + printf("qe_main: Initializing external encoder(s)\n"); ret = qe_devinit(); if (ret != OK) { - message("qe_main: qe_devinit failed: %d\n", ret); + printf("qe_main: qe_devinit failed: %d\n", ret); exitval = EXIT_FAILURE; goto errout; } @@ -285,13 +285,13 @@ int qe_main(int argc, char *argv[]) /* Open the encoder device for reading */ - message("qe_main: Hardware initialized. Opening the encoder device: %s\n", + printf("qe_main: Hardware initialized. Opening the encoder device: %s\n", g_qeexample.devpath); fd = open(g_qeexample.devpath, O_RDONLY); if (fd < 0) { - message("qe_main: open %s failed: %d\n", g_qeexample.devpath, errno); + printf("qe_main: open %s failed: %d\n", g_qeexample.devpath, errno); exitval = EXIT_FAILURE; goto errout_with_dev; } @@ -300,11 +300,11 @@ int qe_main(int argc, char *argv[]) if (g_qeexample.reset) { - message("qe_main: Resetting the count...\n"); + printf("qe_main: Resetting the count...\n"); ret = ioctl(fd, QEIOC_RESET, 0); if (ret < 0) { - message("qe_main: ioctl(QEIOC_RESET) failed: %d\n", errno); + printf("qe_main: ioctl(QEIOC_RESET) failed: %d\n", errno); exitval = EXIT_FAILURE; goto errout_with_dev; } @@ -315,10 +315,10 @@ int qe_main(int argc, char *argv[]) */ #if defined(CONFIG_NSH_BUILTIN_APPS) - message("qe_main: Number of samples: %d\n", g_qeexample.nloops); + printf("qe_main: Number of samples: %d\n", g_qeexample.nloops); for (nloops = 0; nloops < g_qeexample.nloops; nloops++) #elif defined(CONFIG_EXAMPLES_QENCODER_NSAMPLES) - message("qe_main: Number of samples: %d\n", CONFIG_EXAMPLES_QENCODER_NSAMPLES); + printf("qe_main: Number of samples: %d\n", CONFIG_EXAMPLES_QENCODER_NSAMPLES); for (nloops = 0; nloops < CONFIG_EXAMPLES_QENCODER_NSAMPLES; nloops++) #else for (;;) @@ -328,14 +328,14 @@ int qe_main(int argc, char *argv[]) * through the loop. */ - msgflush(); + fflush(stdout); /* Get the positions data using the ioctl */ ret = ioctl(fd, QEIOC_POSITION, (unsigned long)((uintptr_t)&position)); if (ret < 0) { - message("qe_main: ioctl(QEIOC_POSITION) failed: %d\n", errno); + printf("qe_main: ioctl(QEIOC_POSITION) failed: %d\n", errno); exitval = EXIT_FAILURE; goto errout_with_dev; } @@ -344,7 +344,7 @@ int qe_main(int argc, char *argv[]) else { - message("qe_main: %3d. %d\n", nloops+1, position); + printf("qe_main: %3d. %d\n", nloops+1, position); } /* Delay a little bit */ @@ -360,7 +360,7 @@ errout_with_dev: close(fd); errout: - message("Terminating!\n"); - msgflush(); + printf("Terminating!\n"); + fflush(stdout); return exitval; } diff --git a/apps/examples/smart/smart_main.c b/apps/examples/smart/smart_main.c index 2d5bba472..83585cba4 100644 --- a/apps/examples/smart/smart_main.c +++ b/apps/examples/smart/smart_main.c @@ -116,14 +116,6 @@ # define CONFIG_EXAMPLES_SMART_VERBOSE 0 #endif -#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_FS) -# define message syslog -# define msgflush() -#else -# define message printf -# define msgflush() fflush(stdout); -#endif - /**************************************************************************** * Private Types ****************************************************************************/ @@ -174,13 +166,13 @@ extern FAR struct mtd_dev_s *smart_archinitialize(void); static void smart_showmemusage(struct mallinfo *mmbefore, struct mallinfo *mmafter) { - message("VARIABLE BEFORE AFTER\n"); - message("======== ======== ========\n"); - message("arena %8x %8x\n", mmbefore->arena, mmafter->arena); - message("ordblks %8d %8d\n", mmbefore->ordblks, mmafter->ordblks); - message("mxordblk %8x %8x\n", mmbefore->mxordblk, mmafter->mxordblk); - message("uordblks %8x %8x\n", mmbefore->uordblks, mmafter->uordblks); - message("fordblks %8x %8x\n", mmbefore->fordblks, mmafter->fordblks); + printf("VARIABLE BEFORE AFTER\n"); + printf("======== ======== ========\n"); + printf("arena %8x %8x\n", mmbefore->arena, mmafter->arena); + printf("ordblks %8d %8d\n", mmbefore->ordblks, mmafter->ordblks); + printf("mxordblk %8x %8x\n", mmbefore->mxordblk, mmafter->mxordblk); + printf("uordblks %8x %8x\n", mmbefore->uordblks, mmafter->uordblks); + printf("fordblks %8x %8x\n", mmbefore->fordblks, mmafter->fordblks); } /**************************************************************************** @@ -199,7 +191,7 @@ static void smart_loopmemusage(void) /* Show the change from the previous loop */ - message("\nEnd of loop memory usage:\n"); + printf("\nEnd of loop memory usage:\n"); smart_showmemusage(&g_mmprevious, &g_mmafter); /* Set up for the next test */ @@ -222,7 +214,7 @@ static void smart_endmemusage(void) #else (void)mallinfo(&g_mmafter); #endif - message("\nFinal memory usage:\n"); + printf("\nFinal memory usage:\n"); smart_showmemusage(&g_mmbefore, &g_mmafter); } @@ -271,8 +263,8 @@ static inline void smart_randname(FAR struct smart_filedesc_s *file) file->name = (FAR char*)malloc(alloclen + 1); if (!file->name) { - message("ERROR: Failed to allocate name, length=%d\n", namelen); - msgflush(); + printf("ERROR: Failed to allocate name, length=%d\n", namelen); + fflush(stdout); exit(5); } @@ -339,9 +331,9 @@ static inline int smart_wrfile(FAR struct smart_filedesc_s *file) if (errno != ENOSPC) { - message("ERROR: Failed to open file for writing: %d\n", errno); - message(" File name: %s\n", file->name); - message(" File size: %d\n", file->len); + printf("ERROR: Failed to open file for writing: %d\n", errno); + printf(" File name: %s\n", file->name); + printf(" File size: %d\n", file->len); } smart_freefile(file); @@ -372,11 +364,11 @@ static inline int smart_wrfile(FAR struct smart_filedesc_s *file) if (err != ENOSPC) { - message("ERROR: Failed to write file: %d\n", err); - message(" File name: %s\n", file->name); - message(" File size: %d\n", file->len); - message(" Write offset: %ld\n", (long)offset); - message(" Write size: %ld\n", (long)nbytestowrite); + printf("ERROR: Failed to write file: %d\n", err); + printf(" File name: %s\n", file->name); + printf(" File size: %d\n", file->len); + printf(" Write offset: %ld\n", (long)offset); + printf(" Write size: %ld\n", (long)nbytestowrite); ret = ERROR; } close(fd); @@ -386,12 +378,12 @@ static inline int smart_wrfile(FAR struct smart_filedesc_s *file) ret = unlink(file->name); if (ret < 0) { - message(" Failed to remove partial file\n"); + printf(" Failed to remove partial file\n"); } else { #if CONFIG_EXAMPLES_SMART_VERBOSE != 0 - message(" Successfully removed partial file\n"); + printf(" Successfully removed partial file\n"); #endif } @@ -400,12 +392,12 @@ static inline int smart_wrfile(FAR struct smart_filedesc_s *file) } else if (nbyteswritten != nbytestowrite) { - message("ERROR: Partial write:\n"); - message(" File name: %s\n", file->name); - message(" File size: %d\n", file->len); - message(" Write offset: %ld\n", (long)offset); - message(" Write size: %ld\n", (long)nbytestowrite); - message(" Written: %ld\n", (long)nbyteswritten); + printf("ERROR: Partial write:\n"); + printf(" File name: %s\n", file->name); + printf(" File size: %d\n", file->len); + printf(" Write offset: %ld\n", (long)offset); + printf(" Write size: %ld\n", (long)nbytestowrite); + printf(" Written: %ld\n", (long)nbyteswritten); } offset += nbyteswritten; @@ -436,13 +428,13 @@ static int smart_fillfs(void) if (ret < 0) { #if CONFIG_EXAMPLES_SMART_VERBOSE != 0 - message("ERROR: Failed to write file %d\n", i); + printf("ERROR: Failed to write file %d\n", i); #endif return ERROR; } #if CONFIG_EXAMPLES_SMART_VERBOSE != 0 - message(" Created file %s\n", file->name); + printf(" Created file %s\n", file->name); #endif g_nfiles++; } @@ -469,32 +461,32 @@ static ssize_t smart_rdblock(int fd, FAR struct smart_filedesc_s *file, nbytesread = read(fd, &g_fileimage[offset], len); if (nbytesread < 0) { - message("ERROR: Failed to read file: %d\n", errno); - message(" File name: %s\n", file->name); - message(" File size: %d\n", file->len); - message(" Read offset: %ld\n", (long)offset); - message(" Read size: %ld\n", (long)len); + printf("ERROR: Failed to read file: %d\n", errno); + printf(" File name: %s\n", file->name); + printf(" File size: %d\n", file->len); + printf(" Read offset: %ld\n", (long)offset); + printf(" Read size: %ld\n", (long)len); return ERROR; } else if (nbytesread == 0) { #if 0 /* No... we do this on purpose sometimes */ - message("ERROR: Unexpected end-of-file:\n"); - message(" File name: %s\n", file->name); - message(" File size: %d\n", file->len); - message(" Read offset: %ld\n", (long)offset); - message(" Read size: %ld\n", (long)len); + printf("ERROR: Unexpected end-of-file:\n"); + printf(" File name: %s\n", file->name); + printf(" File size: %d\n", file->len); + printf(" Read offset: %ld\n", (long)offset); + printf(" Read size: %ld\n", (long)len); #endif return ERROR; } else if (nbytesread != len) { - message("ERROR: Partial read:\n"); - message(" File name: %s\n", file->name); - message(" File size: %d\n", file->len); - message(" Read offset: %ld\n", (long)offset); - message(" Read size: %ld\n", (long)len); - message(" Bytes read: %ld\n", (long)nbytesread); + printf("ERROR: Partial read:\n"); + printf(" File name: %s\n", file->name); + printf(" File size: %d\n", file->len); + printf(" Read offset: %ld\n", (long)offset); + printf(" Read size: %ld\n", (long)len); + printf(" Bytes read: %ld\n", (long)nbytesread); } return nbytesread; @@ -518,9 +510,9 @@ static inline int smart_rdfile(FAR struct smart_filedesc_s *file) { if (!file->deleted) { - message("ERROR: Failed to open file for reading: %d\n", errno); - message(" File name: %s\n", file->name); - message(" File size: %d\n", file->len); + printf("ERROR: Failed to open file for reading: %d\n", errno); + printf(" File name: %s\n", file->name); + printf(" File size: %d\n", file->len); } return ERROR; @@ -545,9 +537,9 @@ static inline int smart_rdfile(FAR struct smart_filedesc_s *file) crc = crc32(g_fileimage, file->len); if (crc != file->crc) { - message("ERROR: Bad CRC: %d vs %d\n", crc, file->crc); - message(" File name: %s\n", file->name); - message(" File size: %d\n", file->len); + printf("ERROR: Bad CRC: %d vs %d\n", crc, file->crc); + printf(" File name: %s\n", file->name); + printf(" File size: %d\n", file->len); close(fd); return ERROR; } @@ -557,10 +549,10 @@ static inline int smart_rdfile(FAR struct smart_filedesc_s *file) nbytesread = smart_rdblock(fd, file, ntotalread, 1024) ; if (nbytesread > 0) { - message("ERROR: Read past the end of file\n"); - message(" File name: %s\n", file->name); - message(" File size: %d\n", file->len); - message(" Bytes read: %d\n", nbytesread); + printf("ERROR: Read past the end of file\n"); + printf(" File name: %s\n", file->name); + printf(" File size: %d\n", file->len); + printf(" Bytes read: %d\n", nbytesread); close(fd); return ERROR; } @@ -592,7 +584,7 @@ static int smart_verifyfs(void) if (file->deleted) { #if CONFIG_EXAMPLES_SMART_VERBOSE != 0 - message("Deleted file %d OK\n", i); + printf("Deleted file %d OK\n", i); #endif smart_freefile(file); g_ndeleted--; @@ -600,9 +592,9 @@ static int smart_verifyfs(void) } else { - message("ERROR: Failed to read a file: %d\n", i); - message(" File name: %s\n", file->name); - message(" File size: %d\n", file->len); + printf("ERROR: Failed to read a file: %d\n", i); + printf(" File name: %s\n", file->name); + printf(" File size: %d\n", file->len); return ERROR; } } @@ -611,9 +603,9 @@ static int smart_verifyfs(void) if (file->deleted) { #if CONFIG_EXAMPLES_SMART_VERBOSE != 0 - message("Succesffully read a deleted file\n"); - message(" File name: %s\n", file->name); - message(" File size: %d\n", file->len); + printf("Succesffully read a deleted file\n"); + printf(" File name: %s\n", file->name); + printf(" File size: %d\n", file->len); #endif smart_freefile(file); g_ndeleted--; @@ -623,7 +615,7 @@ static int smart_verifyfs(void) else { #if CONFIG_EXAMPLES_SMART_VERBOSE != 0 - message(" Verifed file %s\n", file->name); + printf(" Verifed file %s\n", file->name); #endif } } @@ -675,15 +667,15 @@ static int smart_delfiles(void) ret = unlink(file->name); if (ret < 0) { - message("ERROR: Unlink %d failed: %d\n", i+1, errno); - message(" File name: %s\n", file->name); - message(" File size: %d\n", file->len); - message(" File index: %d\n", j); + printf("ERROR: Unlink %d failed: %d\n", i+1, errno); + printf(" File name: %s\n", file->name); + printf(" File size: %d\n", file->len); + printf(" File index: %d\n", j); } else { #if CONFIG_EXAMPLES_SMART_VERBOSE != 0 - message(" Deleted file %s\n", file->name); + printf(" Deleted file %s\n", file->name); #endif file->deleted = true; g_ndeleted++; @@ -722,15 +714,15 @@ static int smart_delallfiles(void) ret = unlink(file->name); if (ret < 0) { - message("ERROR: Unlink %d failed: %d\n", i+1, errno); - message(" File name: %s\n", file->name); - message(" File size: %d\n", file->len); - message(" File index: %d\n", i); + printf("ERROR: Unlink %d failed: %d\n", i+1, errno); + printf(" File name: %s\n", file->name); + printf(" File size: %d\n", file->len); + printf(" File index: %d\n", i); } else { #if CONFIG_EXAMPLES_SMART_VERBOSE != 0 - message(" Deleted file %s\n", file->name); + printf(" Deleted file %s\n", file->name); #endif smart_freefile(file); } @@ -760,24 +752,24 @@ static int smart_directory(void) { /* Failed to open the directory */ - message("ERROR: Failed to open directory '%s': %d\n", - CONFIG_EXAMPLES_SMART_MOUNTPT, errno); + printf("ERROR: Failed to open directory '%s': %d\n", + CONFIG_EXAMPLES_SMART_MOUNTPT, errno); return ERROR; } /* Read each directory entry */ - message("Directory:\n"); + printf("Directory:\n"); number = 1; do { entryp = readdir(dirp); if (entryp) { - message("%2d. Type[%d]: %s Name: %s\n", - number, entryp->d_type, - entryp->d_type == DTYPE_FILE ? "File " : "Error", - entryp->d_name); + printf("%2d. Type[%d]: %s Name: %s\n", + number, entryp->d_type, + entryp->d_type == DTYPE_FILE ? "File " : "Error", + entryp->d_name); } number++; @@ -819,8 +811,8 @@ int smart_main(int argc, char *argv[]) #endif if (!mtd) { - message("ERROR: Failed to create RAM MTD instance\n"); - msgflush(); + printf("ERROR: Failed to create RAM MTD instance\n"); + fflush(stdout); exit(1); } @@ -830,8 +822,8 @@ int smart_main(int argc, char *argv[]) ret = smart_initialize(1, mtd); if (ret < 0) { - message("ERROR: SMART initialization failed: %d\n", -ret); - msgflush(); + printf("ERROR: SMART initialization failed: %d\n", -ret); + fflush(stdout); exit(2); } @@ -844,8 +836,8 @@ int smart_main(int argc, char *argv[]) ret = mount("/dev/smart1", CONFIG_EXAMPLES_SMART_MOUNTPT, "smartfs", 0, NULL); if (ret < 0) { - message("ERROR: Failed to mount the SMART volume: %d\n", errno); - msgflush(); + printf("ERROR: Failed to mount the SMART volume: %d\n", errno); + fflush(stdout); exit(3); } @@ -875,11 +867,11 @@ int smart_main(int argc, char *argv[]) * (hopefully that the file system is full) */ - message("\n=== FILLING %u =============================\n", i); + printf("\n=== FILLING %u =============================\n", i); (void)smart_fillfs(); - message("Filled file system\n"); - message(" Number of files: %d\n", g_nfiles); - message(" Number deleted: %d\n", g_ndeleted); + printf("Filled file system\n"); + printf(" Number of files: %d\n", g_nfiles); + printf(" Number deleted: %d\n", g_ndeleted); /* Directory listing */ @@ -890,34 +882,34 @@ int smart_main(int argc, char *argv[]) ret = smart_verifyfs(); if (ret < 0) { - message("ERROR: Failed to verify files\n"); - message(" Number of files: %d\n", g_nfiles); - message(" Number deleted: %d\n", g_ndeleted); + printf("ERROR: Failed to verify files\n"); + printf(" Number of files: %d\n", g_nfiles); + printf(" Number deleted: %d\n", g_ndeleted); } else { #if CONFIG_EXAMPLES_SMART_VERBOSE != 0 - message("Verified!\n"); - message(" Number of files: %d\n", g_nfiles); - message(" Number deleted: %d\n", g_ndeleted); + printf("Verified!\n"); + printf(" Number of files: %d\n", g_nfiles); + printf(" Number deleted: %d\n", g_ndeleted); #endif } /* Delete some files */ - message("\n=== DELETING %u ============================\n", i); + printf("\n=== DELETING %u ============================\n", i); ret = smart_delfiles(); if (ret < 0) { - message("ERROR: Failed to delete files\n"); - message(" Number of files: %d\n", g_nfiles); - message(" Number deleted: %d\n", g_ndeleted); + printf("ERROR: Failed to delete files\n"); + printf(" Number of files: %d\n", g_nfiles); + printf(" Number deleted: %d\n", g_ndeleted); } else { - message("Deleted some files\n"); - message(" Number of files: %d\n", g_nfiles); - message(" Number deleted: %d\n", g_ndeleted); + printf("Deleted some files\n"); + printf(" Number of files: %d\n", g_nfiles); + printf(" Number deleted: %d\n", g_ndeleted); } /* Directory listing */ @@ -929,30 +921,30 @@ int smart_main(int argc, char *argv[]) ret = smart_verifyfs(); if (ret < 0) { - message("ERROR: Failed to verify files\n"); - message(" Number of files: %d\n", g_nfiles); - message(" Number deleted: %d\n", g_ndeleted); + printf("ERROR: Failed to verify files\n"); + printf(" Number of files: %d\n", g_nfiles); + printf(" Number deleted: %d\n", g_ndeleted); } else { #if CONFIG_EXAMPLES_SMART_VERBOSE != 0 - message("Verified!\n"); - message(" Number of files: %d\n", g_nfiles); - message(" Number deleted: %d\n", g_ndeleted); + printf("Verified!\n"); + printf(" Number of files: %d\n", g_nfiles); + printf(" Number deleted: %d\n", g_ndeleted); #endif } /* Show memory usage */ smart_loopmemusage(); - msgflush(); + fflush(stdout); } /* Delete all files then show memory usage again */ smart_delallfiles(); smart_endmemusage(); - msgflush(); + fflush(stdout); return 0; } diff --git a/apps/examples/thttpd/thttpd_main.c b/apps/examples/thttpd/thttpd_main.c index 4cad55b53..e2778093a 100644 --- a/apps/examples/thttpd/thttpd_main.c +++ b/apps/examples/thttpd/thttpd_main.c @@ -125,24 +125,6 @@ #define ROMFSDEV "/dev/ram0" #define MOUNTPT CONFIG_THTTPD_PATH -#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 - /**************************************************************************** * Private Data ****************************************************************************/ @@ -190,7 +172,7 @@ int thttp_main(int argc, char *argv[]) ret = slip_initialize(SLIP_DEVNO, CONFIG_NET_SLIPTTY); if (ret < 0) { - message("ERROR: SLIP initialization failed: %d\n", ret); + printf("ERROR: SLIP initialization failed: %d\n", ret); exit(1); } #endif @@ -198,7 +180,7 @@ int thttp_main(int argc, char *argv[]) /* Many embedded network interfaces must have a software assigned MAC */ #ifdef CONFIG_EXAMPLES_THTTPD_NOMAC - message("Assigning MAC\n"); + printf("Assigning MAC\n"); mac[0] = 0x00; mac[1] = 0xe0; @@ -211,7 +193,7 @@ int thttp_main(int argc, char *argv[]) /* Set up our host address */ - message("Setup network addresses\n"); + printf("Setup network addresses\n"); addr.s_addr = HTONL(CONFIG_THTTPD_IPADDR); netlib_sethostaddr(NET_DEVNAME, &addr); @@ -227,35 +209,35 @@ int thttp_main(int argc, char *argv[]) /* Initialize the NXFLAT binary loader */ - message("Initializing the NXFLAT binary loader\n"); + printf("Initializing the NXFLAT binary loader\n"); ret = nxflat_initialize(); if (ret < 0) { - message("ERROR: Initialization of the NXFLAT loader failed: %d\n", ret); + printf("ERROR: Initialization of the NXFLAT loader failed: %d\n", ret); exit(2); } /* Create a ROM disk for the ROMFS filesystem */ - message("Registering romdisk\n"); + printf("Registering romdisk\n"); ret = romdisk_register(0, (uint8_t*)romfs_img, NSECTORS(romfs_img_len), SECTORSIZE); if (ret < 0) { - message("ERROR: romdisk_register failed: %d\n", ret); + printf("ERROR: romdisk_register failed: %d\n", ret); nxflat_uninitialize(); exit(1); } /* Mount the file system */ - message("Mounting ROMFS filesystem at target=%s with source=%s\n", + printf("Mounting ROMFS filesystem at target=%s with source=%s\n", MOUNTPT, ROMFSDEV); ret = mount(ROMFSDEV, MOUNTPT, "romfs", MS_RDONLY, NULL); if (ret < 0) { - message("ERROR: mount(%s,%s,romfs) failed: %s\n", - ROMFSDEV, MOUNTPT, errno); + printf("ERROR: mount(%s,%s,romfs) failed: %s\n", + ROMFSDEV, MOUNTPT, errno); nxflat_uninitialize(); } @@ -264,10 +246,10 @@ int thttp_main(int argc, char *argv[]) g_thttpdsymtab = exports; g_thttpdnsymbols = NEXPORTS; - message("Starting THTTPD\n"); - msgflush(); + printf("Starting THTTPD\n"); + fflush(stdout); thttpd_main(1, &thttpd_argv); - message("THTTPD terminated\n"); - msgflush(); + printf("THTTPD terminated\n"); + fflush(stdout); return 0; } diff --git a/apps/examples/touchscreen/tc.h b/apps/examples/touchscreen/tc.h index 2a8dde203..a196d2d9b 100644 --- a/apps/examples/touchscreen/tc.h +++ b/apps/examples/touchscreen/tc.h @@ -91,26 +91,6 @@ # define CONFIG_EXAMPLES_TOUCHSCREEN_NSAMPLES 0 #endif -/* Debug ********************************************************************/ - -#ifdef CONFIG_CPP_HAVE_VARARGS -# ifdef CONFIG_DEBUG -# define message(...) syslog(__VA_ARGS__) -# define msgflush() -# else -# define message(...) printf(__VA_ARGS__) -# define msgflush() fflush(stdout) -# endif -#else -# ifdef CONFIG_DEBUG -# define message syslog -# define msgflush() -# else -# define message printf -# define msgflush() fflush(stdout) -# endif -#endif - /**************************************************************************** * Public Types ****************************************************************************/ diff --git a/apps/examples/touchscreen/tc_main.c b/apps/examples/touchscreen/tc_main.c index c9cf17787..53421b302 100644 --- a/apps/examples/touchscreen/tc_main.c +++ b/apps/examples/touchscreen/tc_main.c @@ -119,9 +119,9 @@ int tc_main(int argc, char *argv[]) { nsamples = strtol(argv[1], NULL, 10); } - message("tc_main: nsamples: %d\n", nsamples); + printf("tc_main: nsamples: %d\n", nsamples); #elif CONFIG_EXAMPLES_TOUCHSCREEN_NSAMPLES > 0 - message("tc_main: nsamples: %d\n", CONFIG_EXAMPLES_TOUCHSCREEN_NSAMPLES); + printf("tc_main: nsamples: %d\n", CONFIG_EXAMPLES_TOUCHSCREEN_NSAMPLES); #endif #ifdef CONFIG_EXAMPLES_TOUCHSCREEN_ARCHINIT @@ -129,11 +129,11 @@ int tc_main(int argc, char *argv[]) * external to this test. */ - message("tc_main: Initializing external touchscreen device\n"); + printf("tc_main: Initializing external touchscreen device\n"); ret = arch_tcinitialize(CONFIG_EXAMPLES_TOUCHSCREEN_MINOR); if (ret != OK) { - message("tc_main: arch_tcinitialize failed: %d\n", ret); + printf("tc_main: arch_tcinitialize failed: %d\n", ret); errval = 1; goto errout; } @@ -141,11 +141,11 @@ int tc_main(int argc, char *argv[]) /* Open the touchscreen device for reading */ - message("tc_main: Opening %s\n", CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH); + printf("tc_main: Opening %s\n", CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH); fd = open(CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH, O_RDONLY); if (fd < 0) { - message("tc_main: open %s failed: %d\n", + printf("tc_main: open %s failed: %d\n", CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH, errno); errval = 2; goto errout_with_tc; @@ -167,7 +167,7 @@ int tc_main(int argc, char *argv[]) * through the loop. */ - msgflush(); + fflush(stdout); #ifdef CONFIG_EXAMPLES_TOUCHSCREEN_MOUSE /* Read one sample */ @@ -183,30 +183,30 @@ int tc_main(int argc, char *argv[]) errval = errno; if (errval != EINTR) { - message("tc_main: read %s failed: %d\n", - CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH, errval); + printf("tc_main: read %s failed: %d\n", + CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH, errval); errval = 3; goto errout_with_dev; } - message("tc_main: Interrupted read...\n"); + printf("tc_main: Interrupted read...\n"); } else if (nbytes != sizeof(struct mouse_report_s)) { - message("tc_main: Unexpected read size=%d, expected=%d, Ignoring\n", - nbytes, sizeof(struct mouse_report_s)); + printf("tc_main: Unexpected read size=%d, expected=%d, Ignoring\n", + nbytes, sizeof(struct mouse_report_s)); } /* Print the sample data on successful return */ else { - message("Sample :\n"); - message(" buttons : %02x\n", sample.buttons); - message(" x : %d\n", sample.x); - message(" y : %d\n", sample.y); + printf("Sample :\n"); + printf(" buttons : %02x\n", sample.buttons); + printf(" x : %d\n", sample.x); + printf(" y : %d\n", sample.y); #ifdef CONFIG_MOUSE_WHEEL - message(" wheel : %d\n", sample.wheel); + printf(" wheel : %d\n", sample.wheel); #endif } #else @@ -223,34 +223,34 @@ int tc_main(int argc, char *argv[]) errval = errno; if (errval != EINTR) { - message("tc_main: read %s failed: %d\n", - CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH, errval); + printf("tc_main: read %s failed: %d\n", + CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH, errval); errval = 3; goto errout_with_dev; } - message("tc_main: Interrupted read...\n"); + printf("tc_main: Interrupted read...\n"); } else if (nbytes != sizeof(struct touch_sample_s)) { - message("tc_main: Unexpected read size=%d, expected=%d, Ignoring\n", - nbytes, sizeof(struct touch_sample_s)); + printf("tc_main: Unexpected read size=%d, expected=%d, Ignoring\n", + nbytes, sizeof(struct touch_sample_s)); } /* Print the sample data on successful return */ else { - message("Sample :\n"); - message(" npoints : %d\n", sample.npoints); - message("Point 1 :\n"); - message(" id : %d\n", sample.point[0].id); - message(" flags : %02x\n", sample.point[0].flags); - message(" x : %d\n", sample.point[0].x); - message(" y : %d\n", sample.point[0].y); - message(" h : %d\n", sample.point[0].h); - message(" w : %d\n", sample.point[0].w); - message(" pressure : %d\n", sample.point[0].pressure); + printf("Sample :\n"); + printf(" npoints : %d\n", sample.npoints); + printf("Point 1 :\n"); + printf(" id : %d\n", sample.point[0].id); + printf(" flags : %02x\n", sample.point[0].flags); + printf(" x : %d\n", sample.point[0].x); + printf(" y : %d\n", sample.point[0].y); + printf(" h : %d\n", sample.point[0].h); + printf(" w : %d\n", sample.point[0].w); + printf(" pressure : %d\n", sample.point[0].pressure); } #endif } @@ -264,7 +264,7 @@ errout_with_tc: errout: #endif - message("Terminating!\n"); - msgflush(); + printf("Terminating!\n"); + fflush(stdout); return errval; } diff --git a/apps/examples/udp/udp-client.c b/apps/examples/udp/udp-client.c index 297cde5f5..04ba5aaee 100644 --- a/apps/examples/udp/udp-client.c +++ b/apps/examples/udp/udp-client.c @@ -88,7 +88,7 @@ void send_client(void) sockfd = socket(PF_INET, SOCK_DGRAM, 0); if (sockfd < 0) { - message("client socket failure %d\n", errno); + printf("client socket failure %d\n", errno); exit(1); } @@ -106,21 +106,21 @@ void send_client(void) server.sin_port = HTONS(PORTNO); server.sin_addr.s_addr = HTONL(CONFIG_EXAMPLES_UDP_SERVERIP); - message("client: %d. Sending %d bytes\n", offset, SENDSIZE); + printf("client: %d. Sending %d bytes\n", offset, SENDSIZE); nbytes = sendto(sockfd, outbuf, SENDSIZE, 0, (struct sockaddr*)&server, sizeof(struct sockaddr_in)); - message("client: %d. Sent %d bytes\n", offset, nbytes); + printf("client: %d. Sent %d bytes\n", offset, nbytes); if (nbytes < 0) { - message("client: %d. sendto failed: %d\n", offset, errno); + printf("client: %d. sendto failed: %d\n", offset, errno); close(sockfd); exit(-1); } else if (nbytes != SENDSIZE) { - message("client: %d. Bad send length: %d Expected: %d\n", - offset, nbytes, SENDSIZE); + printf("client: %d. Bad send length: %d Expected: %d\n", + offset, nbytes, SENDSIZE); close(sockfd); exit(-1); } diff --git a/apps/examples/udp/udp-internal.h b/apps/examples/udp/udp-internal.h index 49439aedb..9dee4162d 100644 --- a/apps/examples/udp/udp-internal.h +++ b/apps/examples/udp/udp-internal.h @@ -56,25 +56,6 @@ # define HTONS(a) htons(a) # define HTONL(a) htonl(a) - - /* Used printf for debug output */ - -# define message(...) printf(__VA_ARGS__) - - /* Have SO_LINGER */ - -#else - - /* If debug is enabled, use the synchronous lowsyslog so that the - * program output does not get disassociated in the debug output. - */ - -# ifdef CONFIG_DEBUG -# define message(...) lowsyslog(__VA_ARGS__) -# else -# define message(...) printf(__VA_ARGS__) -# endif - #endif #define PORTNO 5471 diff --git a/apps/examples/udp/udp-server.c b/apps/examples/udp/udp-server.c index e16449b8d..f06e67593 100644 --- a/apps/examples/udp/udp-server.c +++ b/apps/examples/udp/udp-server.c @@ -69,7 +69,7 @@ static inline int check_buffer(unsigned char *buf) } if (buf[j] != ch) { - message("server: Buffer content error for offset=%d, index=%d\n", offset, j); + printf("server: Buffer content error for offset=%d, index=%d\n", offset, j); ret = 0; } } @@ -97,7 +97,7 @@ void recv_server(void) sockfd = socket(PF_INET, SOCK_DGRAM, 0); if (sockfd < 0) { - message("server: socket failure: %d\n", errno); + printf("server: socket failure: %d\n", errno); exit(1); } @@ -106,7 +106,7 @@ void recv_server(void) optval = 1; if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (void*)&optval, sizeof(int)) < 0) { - message("server: setsockopt SO_REUSEADDR failure: %d\n", errno); + printf("server: setsockopt SO_REUSEADDR failure: %d\n", errno); exit(1); } @@ -118,7 +118,7 @@ void recv_server(void) if (bind(sockfd, (struct sockaddr*)&server, sizeof(struct sockaddr_in)) < 0) { - message("server: bind failure: %d\n", errno); + printf("server: bind failure: %d\n", errno); exit(1); } @@ -126,47 +126,47 @@ void recv_server(void) for (offset = 0; offset < 256; offset++) { - message("server: %d. Receiving up 1024 bytes\n", offset); + printf("server: %d. Receiving up 1024 bytes\n", offset); addrlen = sizeof(struct sockaddr_in); nbytes = recvfrom(sockfd, inbuf, 1024, 0, (struct sockaddr*)&client, &addrlen); tmpaddr = ntohl(client.sin_addr.s_addr); - message("server: %d. Received %d bytes from %d.%d.%d.%d:%d\n", - offset, nbytes, - tmpaddr >> 24, (tmpaddr >> 16) & 0xff, - (tmpaddr >> 8) & 0xff, tmpaddr & 0xff, - ntohs(client.sin_port)); + printf("server: %d. Received %d bytes from %d.%d.%d.%d:%d\n", + offset, nbytes, + tmpaddr >> 24, (tmpaddr >> 16) & 0xff, + (tmpaddr >> 8) & 0xff, tmpaddr & 0xff, + ntohs(client.sin_port)); if (nbytes < 0) { - message("server: %d. recv failed: %d\n", offset, errno); + printf("server: %d. recv failed: %d\n", offset, errno); close(sockfd); exit(-1); } if (nbytes != SENDSIZE) { - message("server: %d. recv size incorrect: %d vs %d\n", offset, nbytes, SENDSIZE); + printf("server: %d. recv size incorrect: %d vs %d\n", offset, nbytes, SENDSIZE); close(sockfd); exit(-1); } if (offset < inbuf[0]) { - message("server: %d. %d packets lost, resetting offset\n", offset, inbuf[0] - offset); + printf("server: %d. %d packets lost, resetting offset\n", offset, inbuf[0] - offset); offset = inbuf[0]; } else if (offset > inbuf[0]) { - message("server: %d. Bad offset in buffer: %d\n", offset, inbuf[0]); + printf("server: %d. Bad offset in buffer: %d\n", offset, inbuf[0]); close(sockfd); exit(-1); } if (!check_buffer(inbuf)) { - message("server: %d. Bad buffer contents\n", offset); + printf("server: %d. Bad buffer contents\n", offset); close(sockfd); exit(-1); } diff --git a/apps/examples/usbserial/usbserial_main.c b/apps/examples/usbserial/usbserial_main.c index 33d6904fe..11dda6abc 100644 --- a/apps/examples/usbserial/usbserial_main.c +++ b/apps/examples/usbserial/usbserial_main.c @@ -107,24 +107,6 @@ #define TRACE_BITSET (TRACE_INIT_BITS|TRACE_ERROR_BITS|TRACE_CLASS_BITS|\ TRACE_TRANSFER_BITS|TRACE_CONTROLLER_BITS|TRACE_INTERRUPT_BITS) -#ifdef CONFIG_CPP_HAVE_VARARGS -# ifdef CONFIG_DEBUG -# define message(...) lowsyslog(__VA_ARGS__) -# define trmessage lowsyslog -# else -# define message(...) printf(__VA_ARGS__) -# define trmessage printf -# endif -#else -# ifdef CONFIG_DEBUG -# define message lowsyslog -# define trmessage lowsyslog -# else -# define message printf -# define trmessage printf -# endif -#endif - #ifdef CONFIG_CDCACM # define USBSER_DEVNAME "/dev/ttyACM0" #else @@ -181,7 +163,7 @@ static char g_iobuffer[IOBUFFER_SIZE]; #ifdef CONFIG_USBDEV_TRACE static int trace_callback(struct usbtrace_s *trace, void *arg) { - usbtrace_trprintf((trprintf_t)trmessage, trace->event, trace->value); + usbtrace_trprintf((trprintf_t)printf, trace->event, trace->value); return 0; } @@ -224,7 +206,7 @@ int usbserial_main(int argc, char *argv[]) /* Initialize the USB serial driver */ - message("usbserial_main: Registering USB serial driver\n"); + printf("usbserial_main: Registering USB serial driver\n"); #ifdef CONFIG_CDCACM ret = cdcacm_initialize(0, NULL); #else @@ -232,10 +214,10 @@ int usbserial_main(int argc, char *argv[]) #endif if (ret < 0) { - message("usbserial_main: ERROR: Failed to create the USB serial device: %d\n", -ret); + printf("usbserial_main: ERROR: Failed to create the USB serial device: %d\n", -ret); return 1; } - message("usbserial_main: Successfully registered the serial driver\n"); + printf("usbserial_main: Successfully registered the serial driver\n"); #if CONFIG_USBDEV_TRACE && CONFIG_USBDEV_TRACE_INITIALIDSET != 0 /* If USB tracing is enabled and tracing of initial USB events is specified, @@ -255,25 +237,25 @@ int usbserial_main(int argc, char *argv[]) #ifndef CONFIG_EXAMPLES_USBSERIAL_OUTONLY do { - message("usbserial_main: Opening USB serial driver\n"); + printf("usbserial_main: Opening USB serial driver\n"); outfd = open(USBSER_DEVNAME, O_WRONLY); if (outfd < 0) { int errcode = errno; - message("usbserial_main: ERROR: Failed to open " USBSER_DEVNAME " for writing: %d\n", errcode); + printf("usbserial_main: ERROR: Failed to open " USBSER_DEVNAME " for writing: %d\n", errcode); /* ENOTCONN means that the USB device is not yet connected */ if (errcode == ENOTCONN) { - message("usbserial_main: Not connected. Wait and try again.\n"); + printf("usbserial_main: Not connected. Wait and try again.\n"); sleep(5); } else { /* Give up on other errors */ - message("usbserial_main: Aborting\n"); + printf("usbserial_main: Aborting\n"); return 2; } } @@ -292,7 +274,7 @@ int usbserial_main(int argc, char *argv[]) infd = open(USBSER_DEVNAME, O_RDONLY|O_NONBLOCK); if (infd < 0) { - message("usbserial_main: ERROR: Failed to open " USBSER_DEVNAME " for reading: %d\n", errno); + printf("usbserial_main: ERROR: Failed to open " USBSER_DEVNAME " for reading: %d\n", errno); close(outfd); return 3; } @@ -303,20 +285,20 @@ int usbserial_main(int argc, char *argv[]) if (infd < 0) { int errcode = errno; - message("usbserial_main: ERROR: Failed to open " USBSER_DEVNAME " for reading: %d\n", errno); + printf("usbserial_main: ERROR: Failed to open " USBSER_DEVNAME " for reading: %d\n", errno); /* ENOTCONN means that the USB device is not yet connected */ if (errcode == ENOTCONN) { - message("usbserial_main: Not connected. Wait and try again.\n"); + printf("usbserial_main: Not connected. Wait and try again.\n"); sleep(5); } else { /* Give up on other errors */ - message("usbserial_main: Aborting\n"); + printf("usbserial_main: Aborting\n"); return 3; } } @@ -329,7 +311,7 @@ int usbserial_main(int argc, char *argv[]) #endif #endif - message("usbserial_main: Successfully opened the serial driver\n"); + printf("usbserial_main: Successfully opened the serial driver\n"); /* Send messages and get responses -- forever */ @@ -341,21 +323,21 @@ int usbserial_main(int argc, char *argv[]) #if !defined(CONFIG_EXAMPLES_USBSERIAL_ONLYBIG) && !defined(CONFIG_EXAMPLES_USBSERIAL_ONLYSMALL) if (count < 8) { - message("usbserial_main: Saying hello\n"); + printf("usbserial_main: Saying hello\n"); nbytes = write(outfd, g_shortmsg, sizeof(g_shortmsg)); count++; } else { - message("usbserial_main: Reciting QEI's speech of 1588\n"); + printf("usbserial_main: Reciting QEI's speech of 1588\n"); nbytes = write(outfd, g_longmsg, sizeof(g_longmsg)); count = 0; } #elif !defined(CONFIG_EXAMPLES_USBSERIAL_ONLYSMALL) - message("usbserial_main: Reciting QEI's speech of 1588\n"); + printf("usbserial_main: Reciting QEI's speech of 1588\n"); nbytes = write(outfd, g_longmsg, sizeof(g_longmsg)); #else /* !defined(CONFIG_EXAMPLES_USBSERIAL_ONLYBIG) */ - message("usbserial_main: Saying hello\n"); + printf("usbserial_main: Saying hello\n"); nbytes = write(outfd, g_shortmsg, sizeof(g_shortmsg)); #endif @@ -363,14 +345,14 @@ int usbserial_main(int argc, char *argv[]) if (nbytes < 0) { - message("usbserial_main: ERROR: write failed: %d\n", errno); + printf("usbserial_main: ERROR: write failed: %d\n", errno); #ifndef CONFIG_EXAMPLES_USBSERIAL_INONLY close(infd); #endif close(outfd); return 4; } - message("usbserial_main: %d bytes sent\n", nbytes); + printf("usbserial_main: %d bytes sent\n", nbytes); #endif /* CONFIG_EXAMPLES_USBSERIAL_OUTONLY */ /* Test OUT (host-to-device) messages */ @@ -378,7 +360,7 @@ int usbserial_main(int argc, char *argv[]) #ifndef CONFIG_EXAMPLES_USBSERIAL_INONLY /* Poll for incoming messages */ - message("usbserial_main: Polling for OUT messages\n"); + printf("usbserial_main: Polling for OUT messages\n"); for (i = 0; i < 5; i++) { memset(g_iobuffer, 'X', IOBUFFER_SIZE); @@ -388,7 +370,7 @@ int usbserial_main(int argc, char *argv[]) int errorcode = errno; if (errorcode != EAGAIN) { - message("usbserial_main: ERROR: read failed: %d\n", errno); + printf("usbserial_main: ERROR: read failed: %d\n", errno); close(infd); #ifndef CONFIG_EXAMPLES_USBSERIAL_OUTONLY close(outfd); @@ -398,58 +380,58 @@ int usbserial_main(int argc, char *argv[]) } else { - message("usbserial_main: Received %d bytes:\n", nbytes); + printf("usbserial_main: Received %d bytes:\n", nbytes); if (nbytes > 0) { for (j = 0; j < nbytes; j += 16) { - message("usbserial_main: %03x: ", j); + printf("usbserial_main: %03x: ", j); for (k = 0; k < 16; k++) { if (k == 8) { - message(" "); + printf(" "); } if (j+k < nbytes) { - message("%02x", g_iobuffer[j+k]); + printf("%02x", g_iobuffer[j+k]); } else { - message(" "); + printf(" "); } } - message(" "); + printf(" "); for (k = 0; k < 16; k++) { if (k == 8) { - message(" "); + printf(" "); } if (j+k < nbytes) { if (g_iobuffer[j+k] >= 0x20 && g_iobuffer[j+k] < 0x7f) { - message("%c", g_iobuffer[j+k]); + printf("%c", g_iobuffer[j+k]); } else { - message("."); + printf("."); } } else { - message(" "); + printf(" "); } } - message("\n"); + printf("\n"); } } } sleep(1); } #else /* CONFIG_EXAMPLES_USBSERIAL_INONLY */ - message("usbserial_main: Waiting\n"); + printf("usbserial_main: Waiting\n"); sleep(5); #endif /* CONFIG_EXAMPLES_USBSERIAL_INONLY */ diff --git a/apps/examples/usbterm/usbterm.h b/apps/examples/usbterm/usbterm.h index 560e55346..303d1b9f1 100644 --- a/apps/examples/usbterm/usbterm.h +++ b/apps/examples/usbterm/usbterm.h @@ -97,26 +97,6 @@ # define USBTERM_DEVNAME "/dev/ttyUSB0" #endif -/* Debug ********************************************************************/ - -#ifdef CONFIG_CPP_HAVE_VARARGS -# ifdef CONFIG_DEBUG -# define message(...) syslog(__VA_ARGS__) -# define trmessage syslog -# else -# define message(...) printf(__VA_ARGS__) -# define trmessage printf -# endif -#else -# ifdef CONFIG_DEBUG -# define message lowsyslog -# define trmessage lowsyslog -# else -# define message printf -# define trmessage printf -# endif -#endif - #define IOBUFFER_SIZE 256 /**************************************************************************** diff --git a/apps/examples/usbterm/usbterm_main.c b/apps/examples/usbterm/usbterm_main.c index 18d4733d5..3ec2a4a2b 100644 --- a/apps/examples/usbterm/usbterm_main.c +++ b/apps/examples/usbterm/usbterm_main.c @@ -128,7 +128,7 @@ static void dumptrace(void) static FAR void *usbterm_listener(FAR void *parameter) { - message("usbterm_listener: Waiting for remote input\n"); + printf("usbterm_listener: Waiting for remote input\n"); for (;;) { /* Display the prompt string on the remote USB serial connection -- only @@ -202,18 +202,18 @@ int usbterm_main(int argc, char *argv[]) */ #ifdef CONFIG_EXAMPLES_USBTERM_DEVINIT - message("usbterm_main: Performing external device initialization\n"); + printf("usbterm_main: Performing external device initialization\n"); ret = usbterm_devinit(); if (ret != OK) { - message("usbterm_main: usbterm_devinit failed: %d\n", ret); + printf("usbterm_main: usbterm_devinit failed: %d\n", ret); goto errout; } #endif /* Initialize the USB serial driver */ - message("usbterm_main: Registering USB serial driver\n"); + printf("usbterm_main: Registering USB serial driver\n"); #ifdef CONFIG_CDCACM ret = cdcacm_initialize(0, NULL); #else @@ -221,10 +221,10 @@ int usbterm_main(int argc, char *argv[]) #endif if (ret < 0) { - message("usbterm_main: ERROR: Failed to create the USB serial device: %d\n", -ret); + printf("usbterm_main: ERROR: Failed to create the USB serial device: %d\n", -ret); goto errout_with_devinit; } - message("usbterm_main: Successfully registered the serial driver\n"); + printf("usbterm_main: Successfully registered the serial driver\n"); #if CONFIG_USBDEV_TRACE && CONFIG_USBDEV_TRACE_INITIALIDSET != 0 /* If USB tracing is enabled and tracing of initial USB events is specified, @@ -243,20 +243,20 @@ int usbterm_main(int argc, char *argv[]) do { - message("usbterm_main: Opening USB serial driver\n"); + printf("usbterm_main: Opening USB serial driver\n"); g_usbterm.outstream = fopen(USBTERM_DEVNAME, "w"); if (g_usbterm.outstream == NULL) { int errcode = errno; - message("usbterm_main: ERROR: Failed to open " USBTERM_DEVNAME " for writing: %d\n", - errcode); + printf("usbterm_main: ERROR: Failed to open " USBTERM_DEVNAME " for writing: %d\n", + errcode); /* ENOTCONN means that the USB device is not yet connected */ if (errcode == ENOTCONN) { - message("usbterm_main: Not connected. Wait and try again.\n"); + printf("usbterm_main: Not connected. Wait and try again.\n"); sleep(5); } else @@ -280,20 +280,20 @@ int usbterm_main(int argc, char *argv[]) g_usbterm.instream = fopen(USBTERM_DEVNAME, "r"); if (g_usbterm.instream == NULL) { - message("usbterm_main: ERROR: Failed to open " USBTERM_DEVNAME " for reading: %d\n", errno); + printf("usbterm_main: ERROR: Failed to open " USBTERM_DEVNAME " for reading: %d\n", errno); goto errout_with_outstream; } - message("usbterm_main: Successfully opened the serial driver\n"); + printf("usbterm_main: Successfully opened the serial driver\n"); /* Start the USB term listener thread */ - message("usbterm_main: Starting the listener thread\n"); + printf("usbterm_main: Starting the listener thread\n"); ret = pthread_attr_init(&attr); if (ret != OK) { - message("usbterm_main: pthread_attr_init failed: %d\n", ret); + printf("usbterm_main: pthread_attr_init failed: %d\n", ret); goto errout_with_streams; } @@ -301,13 +301,13 @@ int usbterm_main(int argc, char *argv[]) usbterm_listener, (pthread_addr_t)0); if (ret != 0) { - message("usbterm_main: Error in thread creation: %d\n", ret); + printf("usbterm_main: Error in thread creation: %d\n", ret); goto errout_with_streams; } /* Send messages and get responses -- forever */ - message("usbterm_main: Waiting for local input\n"); + printf("usbterm_main: Waiting for local input\n"); for (;;) { /* Display the prompt string on stdout */ @@ -373,7 +373,7 @@ errout_with_devinit: usbterm_devuninit(); errout: #endif - message("usbterm_main: Aborting\n"); + printf("usbterm_main: Aborting\n"); return 1; } diff --git a/apps/examples/watchdog/watchdog.h b/apps/examples/watchdog/watchdog.h index dd4daebb9..c7ba9919b 100644 --- a/apps/examples/watchdog/watchdog.h +++ b/apps/examples/watchdog/watchdog.h @@ -85,26 +85,6 @@ # define CONFIG_EXAMPLES_WATCHDOG_TIMEOUT 2000 #endif -/* Debug ********************************************************************/ - -#ifdef CONFIG_CPP_HAVE_VARARGS -# ifdef CONFIG_DEBUG -# define message(...) syslog(__VA_ARGS__) -# define msgflush() -# else -# define message(...) printf(__VA_ARGS__) -# define msgflush() fflush(stdout) -# endif -#else -# ifdef CONFIG_DEBUG -# define message syslog -# define msgflush() -# else -# define message printf -# define msgflush() fflush(stdout) -# endif -#endif - /**************************************************************************** * Public Types ****************************************************************************/ diff --git a/apps/examples/watchdog/watchdog_main.c b/apps/examples/watchdog/watchdog_main.c index c38541262..cc6bf4784 100644 --- a/apps/examples/watchdog/watchdog_main.c +++ b/apps/examples/watchdog/watchdog_main.c @@ -90,18 +90,18 @@ struct wdog_example_s static void wdog_help(void) { - message("Usage: wdog [-h] [-d <pingtime] [-p <pingdelay>] [-t <timeout>]\n"); - message("\nInitialize the watchdog to the <timeout>. Start the watchdog\n"); - message("timer. Ping for the watchdog for <pingtime> seconds, then let it expire.\n"); - message("\nOptions include:\n"); - message(" [-d <pingtime>] = Selects the <delay> time in milliseconds. Default: %d\n", - CONFIG_EXAMPLES_WATCHDOG_PINGTIME); - message(" [-p <pingdelay] = Time delay between pings in milliseconds. Default: %d\n", - CONFIG_EXAMPLES_WATCHDOG_PINGDELAY); - message(" [-t timeout] = Time in milliseconds that the example will ping the watchdog\n"); - message(" before letting the watchdog expire. Default: %d\n", - CONFIG_EXAMPLES_WATCHDOG_TIMEOUT); - message(" [-h] = Shows this message and exits\n"); + printf("Usage: wdog [-h] [-d <pingtime] [-p <pingdelay>] [-t <timeout>]\n"); + printf("\nInitialize the watchdog to the <timeout>. Start the watchdog\n"); + printf("timer. Ping for the watchdog for <pingtime> seconds, then let it expire.\n"); + printf("\nOptions include:\n"); + printf(" [-d <pingtime>] = Selects the <delay> time in milliseconds. Default: %d\n", + CONFIG_EXAMPLES_WATCHDOG_PINGTIME); + printf(" [-p <pingdelay] = Time delay between pings in milliseconds. Default: %d\n", + CONFIG_EXAMPLES_WATCHDOG_PINGDELAY); + printf(" [-t timeout] = Time in milliseconds that the example will ping the watchdog\n"); + printf(" before letting the watchdog expire. Default: %d\n", + CONFIG_EXAMPLES_WATCHDOG_TIMEOUT); + printf(" [-h] = Shows this message and exits\n"); } /**************************************************************************** @@ -158,7 +158,7 @@ static void parse_args(FAR struct wdog_example_s *wdog, int argc, FAR char **arg ptr = argv[index]; if (ptr[0] != '-') { - message("Invalid options format: %s\n", ptr); + printf("Invalid options format: %s\n", ptr); exit(EXIT_SUCCESS); } @@ -168,7 +168,7 @@ static void parse_args(FAR struct wdog_example_s *wdog, int argc, FAR char **arg nargs = arg_decimal(&argv[index], &value); if (value < 1) { - message("Ping delay out of range: %ld\n", value); + printf("Ping delay out of range: %ld\n", value); exit(EXIT_FAILURE); } @@ -180,7 +180,7 @@ static void parse_args(FAR struct wdog_example_s *wdog, int argc, FAR char **arg nargs = arg_decimal(&argv[index], &value); if (value < 1 || value > 99) { - message("Ping time out of range: %ld\n", value); + printf("Ping time out of range: %ld\n", value); exit(EXIT_FAILURE); } @@ -192,7 +192,7 @@ static void parse_args(FAR struct wdog_example_s *wdog, int argc, FAR char **arg nargs = arg_decimal(&argv[index], &value); if (value < 1 || value > INT_MAX) { - message("Duration out of range: %ld\n", value); + printf("Duration out of range: %ld\n", value); exit(EXIT_FAILURE); } @@ -205,7 +205,7 @@ static void parse_args(FAR struct wdog_example_s *wdog, int argc, FAR char **arg exit(EXIT_SUCCESS); default: - message("Unsupported option: %s\n", ptr); + printf("Unsupported option: %s\n", ptr); wdog_help(); exit(EXIT_FAILURE); } @@ -245,7 +245,7 @@ int wdog_main(int argc, char *argv[]) ret = up_wdginitialize(); if (ret != OK) { - message("wdog_main: up_wdginitialize failed: %d\n", ret); + printf("wdog_main: up_wdginitialize failed: %d\n", ret); goto errout; } @@ -254,8 +254,8 @@ int wdog_main(int argc, char *argv[]) fd = open(CONFIG_EXAMPLES_WATCHDOG_DEVPATH, O_RDONLY); if (fd < 0) { - message("wdog_main: open %s failed: %d\n", - CONFIG_EXAMPLES_WATCHDOG_DEVPATH, errno); + printf("wdog_main: open %s failed: %d\n", + CONFIG_EXAMPLES_WATCHDOG_DEVPATH, errno); goto errout; } @@ -264,7 +264,7 @@ int wdog_main(int argc, char *argv[]) ret = ioctl(fd, WDIOC_SETTIMEOUT, (unsigned long)wdog.timeout); if (ret < 0) { - message("wdog_main: ioctl(WDIOC_SETTIMEOUT) failed: %d\n", errno); + printf("wdog_main: ioctl(WDIOC_SETTIMEOUT) failed: %d\n", errno); goto errout_with_dev; } @@ -273,7 +273,7 @@ int wdog_main(int argc, char *argv[]) ret = ioctl(fd, WDIOC_START, 0); if (ret < 0) { - message("wdog_main: ioctl(WDIOC_START) failed: %d\n", errno); + printf("wdog_main: ioctl(WDIOC_START) failed: %d\n", errno); goto errout_with_dev; } @@ -293,12 +293,12 @@ int wdog_main(int argc, char *argv[]) ret = ioctl(fd, WDIOC_GETSTATUS, (unsigned long)&status); if (ret < 0) { - message("wdog_main: ioctl(WDIOC_GETSTATUS) failed: %d\n", errno); + printf("wdog_main: ioctl(WDIOC_GETSTATUS) failed: %d\n", errno); goto errout_with_dev; } - message("wdog_main: flags=%08x timeout=%d timeleft=%d\n", - status.flags, status.timeout, status.timeleft); + printf("wdog_main: flags=%08x timeout=%d timeleft=%d\n", + status.flags, status.timeout, status.timeleft); #endif /* Then ping */ @@ -306,12 +306,12 @@ int wdog_main(int argc, char *argv[]) ret = ioctl(fd, WDIOC_KEEPALIVE, 0); if (ret < 0) { - message("wdog_main: ioctl(WDIOC_KEEPALIVE) failed: %d\n", errno); + printf("wdog_main: ioctl(WDIOC_KEEPALIVE) failed: %d\n", errno); goto errout_with_dev; } - message(" ping elapsed=%ld\n", elapsed); - msgflush(); + printf(" ping elapsed=%ld\n", elapsed); + fflush(stdout); } /* Then stop pinging */ @@ -330,15 +330,15 @@ int wdog_main(int argc, char *argv[]) ret = ioctl(fd, WDIOC_GETSTATUS, (unsigned long)&status); if (ret < 0) { - message("wdog_main: ioctl(WDIOC_GETSTATUS) failed: %d\n", errno); + printf("wdog_main: ioctl(WDIOC_GETSTATUS) failed: %d\n", errno); goto errout_with_dev; } - message("wdog_main: flags=%08x timeout=%d timeleft=%d\n", - status.flags, status.timeout, status.timeleft); + printf("wdog_main: flags=%08x timeout=%d timeleft=%d\n", + status.flags, status.timeout, status.timeleft); #endif - message(" NO ping elapsed=%ld\n", elapsed); - msgflush(); + printf(" NO ping elapsed=%ld\n", elapsed); + fflush(stdout); } /* We should not get here */ @@ -350,17 +350,17 @@ int wdog_main(int argc, char *argv[]) * support stopping the watchdog once it has been started. */ - message("wdog_main: ioctl(WDIOC_STOP) failed: %d\n", errno); + printf("wdog_main: ioctl(WDIOC_STOP) failed: %d\n", errno); goto errout_with_dev; } close(fd); - msgflush(); + fflush(stdout); return OK; errout_with_dev: close(fd); errout: - msgflush(); + fflush(stdout); return ERROR; } diff --git a/apps/examples/webserver/webserver_main.c b/apps/examples/webserver/webserver_main.c index a6ad05f68..30f805c22 100644 --- a/apps/examples/webserver/webserver_main.c +++ b/apps/examples/webserver/webserver_main.c @@ -81,23 +81,9 @@ #include "cgi.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ -#ifdef CONFIG_CPP_HAVE_VARARGS -# ifdef CONFIG_DEBUG -# define message(...) lowsyslog(__VA_ARGS__) -# else -# define message(...) printf(__VA_ARGS__) -# endif -#else -# ifdef CONFIG_DEBUG -# define message lowsyslog -# else -# define message (void) -# endif -#endif - /**************************************************************************** * Private Data ****************************************************************************/ diff --git a/nuttx/include/syslog.h b/nuttx/include/syslog.h index d033e06c2..ab0e6073c 100644 --- a/nuttx/include/syslog.h +++ b/nuttx/include/syslog.h @@ -1,7 +1,7 @@ /**************************************************************************** * include/syslog.h * - * Copyright (C) 2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2013-2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -49,6 +49,54 @@ /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ +/* The option argument to openlog() is an OR of any of these: + * + * LOG_CONS - Write directly to system console if there is an error + * while sending to system logger. + * LOG_NDELAY - Open the connection immediately (normally, the connection + * is opened when the first message is logged). + * LOG_NOWAIT - Don't wait for child processes that may have been created + * while logging the message. + * LOG_ODELAY - The converse of LOG_NDELAY; opening of the connection is + * delayed until syslog() is called. (This is the default, + * and need not be specified.) + * LOG_PERROR - (Not in POSIX.1-2001 or POSIX.1-2008.) Print to stderr + * as well (Linux). + * LOG_PID - Include PID with each message. + */ + +/* The facility argument is used to specify what type of program is logging + * the message. This lets the configuration file specify that messages from + * different facilities will be handled differently. + * + * LOG_AUTH - Security/authorization messages + * LOG_AUTHPRIV - Security/authorization messages (private) + * LOG_CRON - Clock daemon (cron and at) + * LOG_DAEMON - System daemons without separate facility value + * LOG_FTP - Ftp daemon + * LOG_KERN - Lernel messages (these can't be generated from user + * processes) + * LOG_LOCAL0 through LOG_LOCAL7 - Reserved for local use + * LOG_LPR - Line printer subsystem + * LOG_MAIL - Mail subsystem + * LOG_NEWS - USENET news subsystem + * LOG_SYSLOG - Messages generated internally by syslogd(8) + * LOG_USER - Generic user-level messages (default) + * LOG_UUCP - UUCP subsystem + */ + +/* This determines the importance of the message. The levels are, in order + * of decreasing importance: + */ + +#define LOG_EMERG 7 /* System is unusable */ +#define LOG_ALERT 6 /* Action must be taken immediately */ +#define LOG_CRIT 5 /* Critical conditions */ +#define LOG_ERR 4 /* Error conditions */ +#define LOG_WARNING 3 /* Warning conditions */ +#define LOG_NOTICE 2 /* Normal, but significant, condition */ +#define LOG_INFO 1 /* Informational message */ +#define LOG_DEBUG 0 /* Debug-level message */ /**************************************************************************** * Public Type Declarations @@ -67,6 +115,12 @@ extern "C" { #endif +#if 0 /* Not supported */ +void openlog(FAR const char *ident, int option, int facility); +void closelog(void); +int setlogmask(int mask); +#endif + /* These low-level debug APIs are provided by the NuttX library. These are * normally accessed via the macros in debug.h. If the cross-compiler's * C pre-processor supports a variable number of macro arguments, then those @@ -77,14 +131,14 @@ extern "C" int syslog(FAR const char *format, ...); int vsyslog(const char *src, va_list ap); -#ifdef CONFIG_ARCH_LOWPUTC +#ifdef CONFIG_ARCH_LOWPUTC /* Non-standard */ int lowsyslog(FAR const char *format, ...); -int lowvsyslog(const char *src, va_list ap); +int lowvsyslog(FAR const char *src, va_list ap); #endif /* Enable or disable syslog output */ -#ifdef CONFIG_SYSLOG_ENABLE +#ifdef CONFIG_SYSLOG_ENABLE /* Non-standard */ void syslog_enable(bool enable); #endif |