ia64/xen-unstable

changeset 11778:ab85c20d33e5

[TOOLS] Fixes to miniterm serial terminal utility.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@localhost.localdomain
date Mon Oct 09 23:34:00 2006 +0100 (2006-10-09)
parents fd80b7e1e333
children f028e3732803
files tools/misc/miniterm/miniterm.c
line diff
     1.1 --- a/tools/misc/miniterm/miniterm.c	Mon Oct 09 17:08:18 2006 +0100
     1.2 +++ b/tools/misc/miniterm/miniterm.c	Mon Oct 09 23:34:00 2006 +0100
     1.3 @@ -32,10 +32,11 @@
     1.4  #include <signal.h>
     1.5  #include <sys/types.h>
     1.6  #include <sys/wait.h>
     1.7 +#include <string.h>
     1.8  
     1.9  #define DEFAULT_BAUDRATE   115200
    1.10  #define DEFAULT_SERDEVICE  "/dev/ttyS0"
    1.11 -#define ENDMINITERM        2  /* ctrl-b to quit miniterm */
    1.12 +#define ENDMINITERM        0x1d
    1.13  
    1.14  volatile int stop = 0;
    1.15  
    1.16 @@ -76,7 +77,11 @@ int main(int argc, char **argv)
    1.17      char            *sername = DEFAULT_SERDEVICE;
    1.18      struct termios   oldsertio, newsertio, oldstdtio, newstdtio;
    1.19      struct sigaction sa;
    1.20 - 
    1.21 +    static char start_str[] = 
    1.22 +        "************ REMOTE CONSOLE: CTRL-] TO QUIT ********\r\n";
    1.23 +    static char end_str[] =
    1.24 +        "\n************ REMOTE CONSOLE EXITED *****************\n";
    1.25 +
    1.26      while ( --argc != 0 )
    1.27      {
    1.28          char *p = argv[argc];
    1.29 @@ -121,7 +126,7 @@ int main(int argc, char **argv)
    1.30      newsertio.c_iflag = IGNBRK | IGNPAR;
    1.31  
    1.32      /* Raw output. */
    1.33 -    newsertio.c_oflag = 0; 
    1.34 +    newsertio.c_oflag = OPOST;
    1.35  
    1.36      /* No echo and no signals. */
    1.37      newsertio.c_lflag = 0;
    1.38 @@ -137,7 +142,13 @@ int main(int argc, char **argv)
    1.39      /* next stop echo and buffering for stdin */
    1.40      tcgetattr(0,&oldstdtio);
    1.41      tcgetattr(0,&newstdtio); /* get working stdtio */
    1.42 -    newstdtio.c_lflag &= ~(ICANON | ECHO);
    1.43 +    newstdtio.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
    1.44 +    newstdtio.c_oflag &= ~OPOST;
    1.45 +    newstdtio.c_cflag &= ~(CSIZE | PARENB);
    1.46 +    newstdtio.c_cflag |= CS8;
    1.47 +    newstdtio.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);
    1.48 +    newstdtio.c_cc[VMIN]=1;
    1.49 +    newstdtio.c_cc[VTIME]=0;
    1.50      tcsetattr(0,TCSANOW,&newstdtio);
    1.51  
    1.52      /* Terminal settings done: now enter the main I/O loops. */
    1.53 @@ -145,7 +156,7 @@ int main(int argc, char **argv)
    1.54      {
    1.55      case 0:
    1.56          close(1); /* stdout not needed */
    1.57 -        for ( c = getchar(); c != ENDMINITERM ; c = getchar() ) 
    1.58 +        for ( c = (char)getchar(); c != ENDMINITERM; c = (char)getchar() )
    1.59              write(fd,&c,1);
    1.60          tcsetattr(fd,TCSANOW,&oldsertio);
    1.61          tcsetattr(0,TCSANOW,&oldstdtio);
    1.62 @@ -158,7 +169,7 @@ int main(int argc, char **argv)
    1.63          close(fd);
    1.64          exit(-1);
    1.65      default:
    1.66 -        printf("** ctrl-b quits miniterm **\n");
    1.67 +        write(1, start_str, strlen(start_str));
    1.68          close(0); /* stdin not needed */
    1.69          sa.sa_handler = child_handler;
    1.70          sa.sa_flags = 0;
    1.71 @@ -166,9 +177,11 @@ int main(int argc, char **argv)
    1.72          while ( !stop )
    1.73          {
    1.74              read(fd,&c,1); /* modem */
    1.75 +            c = (char)c;
    1.76              write(1,&c,1); /* stdout */
    1.77          }
    1.78          wait(NULL); /* wait for child to die or it will become a zombie */
    1.79 +        write(1, end_str, strlen(end_str));
    1.80          break;
    1.81      }
    1.82