mirror of
git://projects.qi-hardware.com/wernermisc.git
synced 2024-11-21 20:45:54 +02:00
neocon/neocon.c: new option -L for local line editing (for Contiki)
This commit is contained in:
parent
8b40af7770
commit
412d605f84
@ -22,6 +22,10 @@ with the option "-e escape".
|
||||
|
||||
To manually switch to the next device, enter "~n".
|
||||
|
||||
The option -L switches console input from character-by-character
|
||||
(raw) mode to local line editing (cooked). Edited lines are sent
|
||||
with \n termination.
|
||||
|
||||
|
||||
Known issues
|
||||
------------
|
||||
|
@ -74,7 +74,7 @@ static speed_t bps_to_speed(int bps)
|
||||
}
|
||||
|
||||
|
||||
static void make_raw(int fd, struct termios *old, int cr)
|
||||
static void make_raw(int fd, struct termios *old, int cr, int local_edit)
|
||||
{
|
||||
struct termios t;
|
||||
long flags;
|
||||
@ -85,7 +85,8 @@ static void make_raw(int fd, struct termios *old, int cr)
|
||||
}
|
||||
if (old)
|
||||
*old = t;
|
||||
cfmakeraw(&t);
|
||||
if (local_edit)
|
||||
return;
|
||||
if (fd) {
|
||||
t.c_iflag &= ~(IXON | IXOFF);
|
||||
t.c_cflag |= CLOCAL;
|
||||
@ -128,7 +129,7 @@ static int open_next_tty(void)
|
||||
break;
|
||||
}
|
||||
if (fd >= 0)
|
||||
make_raw(fd, &tty, 0);
|
||||
make_raw(fd, &tty, 0, 0);
|
||||
return fd;
|
||||
}
|
||||
|
||||
@ -281,16 +282,17 @@ static void cleanup(void)
|
||||
static void usage(const char *name)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"usage: %s [-b bps] [-c] [-e escape] [-l logfile [-a] [-T]] [-t delay_ms] "
|
||||
"tty ...\n\n"
|
||||
"usage: %s [-b bps] [-c] [-e escape] [-l logfile [-a] [-T]] [-L]\n"
|
||||
" %*s [-t delay_ms] tty ...\n\n"
|
||||
" -a append to the log file if it already exists\n"
|
||||
" -b bps set the TTY to the specified bit rate\n"
|
||||
" -c add carriage return before newline (on console)\n"
|
||||
" -e escape set the escape character (default: ~)\n"
|
||||
" -l logfile log all output to the specified file\n"
|
||||
" -L enable local line editing\n"
|
||||
" -t delay_ms wait the specified amount of time between input characters\n"
|
||||
" -T add timestamps to the log file\n"
|
||||
, name);
|
||||
, name, (int) strlen(name), "");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -299,13 +301,14 @@ int main(int argc, char *const *argv)
|
||||
{
|
||||
char *end;
|
||||
int c, bps, cr = 0;
|
||||
int local_edit = 0;
|
||||
int fd = -1;
|
||||
int append = 0;
|
||||
const char *logfile = NULL;
|
||||
int throttle_us = 0;
|
||||
int throttle = 0;
|
||||
|
||||
while ((c = getopt(argc, argv, "ab:ce:l:t:T")) != EOF)
|
||||
while ((c = getopt(argc, argv, "ab:ce:l:Lt:T")) != EOF)
|
||||
switch (c) {
|
||||
case 'a':
|
||||
append = 1;
|
||||
@ -327,6 +330,9 @@ int main(int argc, char *const *argv)
|
||||
case 'l':
|
||||
logfile = optarg;
|
||||
break;
|
||||
case 'L':
|
||||
local_edit = 1;
|
||||
break;
|
||||
case 't':
|
||||
throttle_us = strtoul(optarg, &end, 0)*1000;
|
||||
if (*end)
|
||||
@ -350,7 +356,7 @@ int main(int argc, char *const *argv)
|
||||
setlinebuf(log);
|
||||
}
|
||||
|
||||
make_raw(0, &console, cr);
|
||||
make_raw(0, &console, cr, local_edit);
|
||||
atexit(cleanup);
|
||||
while (1) {
|
||||
struct timeval tv;
|
||||
|
Loading…
Reference in New Issue
Block a user