summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-12-13 13:11:06 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-12-13 13:11:06 -0600
commitcc3ccf9e7489b77759c0b2df64904f92719ab1e8 (patch)
tree0f9a1d0bf8d49f2a8ea61f3651b589e101df78ad /apps
parentfef451758ac702e7c859cc7ccc473333711eb4af (diff)
downloadnuttx-cc3ccf9e7489b77759c0b2df64904f92719ab1e8.tar.gz
nuttx-cc3ccf9e7489b77759c0b2df64904f92719ab1e8.tar.bz2
nuttx-cc3ccf9e7489b77759c0b2df64904f92719ab1e8.zip
apps/system/cu: Add a some configurable defaults (only to reduce my keystrokes in repetitive testing)
Diffstat (limited to 'apps')
-rw-r--r--apps/system/cu/Kconfig15
-rw-r--r--apps/system/cu/cu.h9
-rw-r--r--apps/system/cu/cu_main.c18
3 files changed, 35 insertions, 7 deletions
diff --git a/apps/system/cu/Kconfig b/apps/system/cu/Kconfig
index c1400b58d..3c3007b59 100644
--- a/apps/system/cu/Kconfig
+++ b/apps/system/cu/Kconfig
@@ -18,6 +18,21 @@ config SYSTEM_CUTERM
if SYSTEM_CUTERM
+config SYSTEM_CUTERM_DEFAULT_DEVICE
+ string "Default serial device"
+ default "/dev/ttyS0"
+ ---help---
+ Normally, the serial device to be used is provided on the command line.
+ If no device is provided then this is the default device that will be\
+ used.
+
+config SYSTEM_CUTERM_DEFAULT_BAUD
+ int "Default serial baud"
+ default 115200
+ ---help---
+ Normally, the BAUD to be used is provided on the command line. If no
+ BAUD is provided then this is the default device that will be used.
+
config SYSTEM_CUTERM_STACKSIZE
int "CU terminal stack size"
default 2048
diff --git a/apps/system/cu/cu.h b/apps/system/cu/cu.h
index 98b656f72..768efa87c 100644
--- a/apps/system/cu/cu.h
+++ b/apps/system/cu/cu.h
@@ -49,6 +49,15 @@
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
+/* Configuration ***********************************************************/
+
+#ifndef CONFIG_SYSTEM_CUTERM_DEFAULT_DEVICE
+# define CONFIG_SYSTEM_CUTERM_DEFAULT_DEVICE "/dev/ttyS0"
+#endif
+
+#ifndef CONFIG_SYSTEM_CUTERM_DEFAULT_BAUD
+# define CONFIG_SYSTEM_CUTERM_DEFAULT_BAUD 115200
+#endif
/****************************************************************************
* Public Types
diff --git a/apps/system/cu/cu_main.c b/apps/system/cu/cu_main.c
index 909c7f2ed..5cce8e1a8 100644
--- a/apps/system/cu/cu_main.c
+++ b/apps/system/cu/cu_main.c
@@ -217,12 +217,14 @@ static int set_baudrate(int fd, int rate, enum parity_mode parity, int rtscts)
static void print_help(void)
{
printf("Usage: cu [options]\n"
- " -l: Use named device (e.g. /dev/ttyS1)\n"
+ " -l: Use named device (default %s)\n"
" -e: Set even parity\n"
" -o: Set odd parity\n"
- " -s: Use given speed\n"
+ " -s: Use given speed (default %d)\n"
" -r: Disable RTS/CTS flow control (default: on)\n"
- " -?: This help\n");
+ " -?: This help\n",
+ CONFIG_SYSTEM_CUTERM_DEFAULT_DEVICE,
+ CONFIG_SYSTEM_CUTERM_DEFAULT_BAUD);
}
static void print_escape_help(void)
@@ -269,14 +271,15 @@ int cu_main(int argc, FAR char *argv[])
{
pthread_attr_t attr;
struct sigaction sa;
- FAR char *devname = NULL;
- int baudrate = 0;
+ FAR char *devname = CONFIG_SYSTEM_CUTERM_DEFAULT_DEVICE;
+ int baudrate = CONFIG_SYSTEM_CUTERM_DEFAULT_BAUD;
enum parity_mode parity = PARITY_NONE;
int rtscts = 1;
int option;
int ret;
int bcmd;
int start_of_line = 1;
+ int exitval = EXIT_FAILURE;
/* Initialize global data */
@@ -378,7 +381,7 @@ int cu_main(int argc, FAR char *argv[])
if (start_of_line == 1 && ch == '~')
{
- /* we've seen and escape (~) character, echo it to local
+ /* We've seen and escape (~) character, echo it to local
* terminal and read the next char from serial
*/
@@ -418,6 +421,7 @@ int cu_main(int argc, FAR char *argv[])
pthread_cancel(g_cu.listener);
pthread_attr_destroy(&attr);
+ exitval = EXIT_SUCCESS;
/* Error exits */
@@ -426,5 +430,5 @@ errout_with_fds:
errout_with_outfd:
close(g_cu.outfd);
errout_with_devinit:
- return EXIT_FAILURE;
+ return exitval;
}