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 /apps/examples/i2schar | |
parent | 1753a0251a941fa4d1a5b95aec631209e9957670 (diff) | |
download | nuttx-fdb1d0a4df496e7a3232a950d5c72231363cf67a.tar.gz nuttx-fdb1d0a4df496e7a3232a950d5c72231363cf67a.tar.bz2 nuttx-fdb1d0a4df496e7a3232a950d5c72231363cf67a.zip |
Remove non-portable references to syslog from apps/examples
Diffstat (limited to 'apps/examples/i2schar')
-rw-r--r-- | apps/examples/i2schar/i2schar.h | 20 | ||||
-rw-r--r-- | apps/examples/i2schar/i2schar_main.c | 46 | ||||
-rw-r--r-- | apps/examples/i2schar/i2schar_receiver.c | 12 | ||||
-rw-r--r-- | apps/examples/i2schar/i2schar_transmitter.c | 12 |
4 files changed, 35 insertions, 55 deletions
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); |