Ejemplo n.º 1
0
/* handle a single escape character */
static void help_set_speed(struct ios_ops *ios, char c)
{
    speed_t speed[] = {
        B1200,
        B2400,
        B4800,
        B9600,
        B19200,
        B38400,
        B57600,
        B115200,
        B230400,
        B460800
    };


    if (c < 'a' && c > 'j') {
        if (c == '~') {
            help_speed();
            return;
        } else if (c == 'q') {
            in_escape = 0;
            help_state = 0;
        }
        write(ios->fd, &c, 1);
        return;
    }

    ios->set_speed(ios, speed[c - 'a']);

    in_escape = 0;
    help_state = 0;
    help_done();
}
Ejemplo n.º 2
0
/* process function for help_state=1 */
static void help_set_terminal(struct ios_ops *ios, char c)
{
    struct termios pts;	/* termios settings on port */
    tcgetattr(ios->fd, &pts);
    switch (c) {
    case 'm':		/* CR/NL mapping */
        in_escape = 0;	/* get it out from escape state */
        help_state = 0;
        if (crnl_mapping) {
            pts.c_oflag &= ~ONLCR;
            crnl_mapping = 0;
        } else {
            pts.c_oflag |= ONLCR;
            crnl_mapping = 1;
        }
        tcsetattr(ios->fd, TCSANOW, &pts);
        break;
    case 'p':		/* port speed */
        in_escape = 1;
        help_state = 2;
        help_speed();
        break;
    case 'h':		/* hardware flow control */
        in_escape = 0;	/* get it out from escape state */
        help_state = 0;
        ios->set_flow(ios, FLOW_HARD);
        /* hardware flow control */
        break;
    case 's':		/* software flow contrlol */
        in_escape = 0;	/* get it out from escape state */
        help_state = 0;
        ios->set_flow(ios, FLOW_SOFT);
        /* software flow control */
        break;
    case 'n':		/* no flow control */
        in_escape = 0;	/* get it out from escape state */
        help_state = 0;
        /* no flow control */
        ios->set_flow(ios, FLOW_NONE);
        break;
    case '~':
    case 'q':
        in_escape = 0;
        help_state = 0;
        break;
    default:
        /* pass the character through */
        /* "C-\ C-\" sends "C-\" */
        write(ios->fd, &c, 1);
        break;
    }

    if (in_escape == 0)
        help_done();

    return;
}
Ejemplo n.º 3
0
/* handle a single escape character */
static void help_set_speed(int fd, char c) { 
  struct  termios pts;  /* termios settings on port */
  speed_t speed[] = {
    B1200,
    B2400,
    B4800,
    B9600,
    B19200,
    B38400,
    B57600,
    B115200,
    B230400,
    B460800
  };

  if (c < 'a' && c > 'j') {
    if (c == '~') {
      help_speed();
      return;
    }
    else if (c == 'q') {
      in_escape = 0;
      help_state = 0;
    }
    write(fd, &c, 1);
    return;
  }

  tcgetattr(fd, &pts);
  cfsetospeed(&pts, speed[c - 'a']);
  cfsetispeed(&pts, speed[c - 'a']);
  tcsetattr(fd, TCSANOW, &pts);
  in_escape = 0;
  help_state = 0;
  help_done();
}
Ejemplo n.º 4
0
/* process function for help_state=1 */
static void help_set_terminal(int fd, char c) { 
  struct  termios pts;  /* termios settings on port */
  tcgetattr(fd, &pts);
  switch (c) {
  case 'm': /* CR/NL mapping */
    in_escape = 0; /* get it out from escape state */
    help_state = 0;
    if (crnl_mapping) {
      pts.c_oflag &= ~ONLCR;
      crnl_mapping = 0;      
    } else { 
      pts.c_oflag |= ONLCR;
      crnl_mapping = 1;
    }
    DEBUG_MSG("Map CarriageReturn to NewLine on output = %d",crnl_mapping);
    tcsetattr(fd, TCSANOW, &pts);
    break;
  case 'p': /* port speed */
    in_escape = 1;
    help_state = 2;
    help_speed();
    break;
  case 'h': /* hardware flow control */
    in_escape = 0; /* get it out from escape state */
    help_state = 0;
    /* hardware flow control */
    pts.c_cflag |= CRTSCTS;
    pts.c_iflag &= ~(IXON | IXOFF | IXANY);
    tcsetattr(fd, TCSANOW, &pts);
    break;
  case 's': /* software flow contrlol */
    in_escape = 0; /* get it out from escape state */
    help_state = 0;
    /* software flow control */
    pts.c_cflag &= ~CRTSCTS;
    pts.c_iflag |= IXON | IXOFF | IXANY;
    tcsetattr(fd, TCSANOW, &pts);
    break;
  case 'n': /* no flow control */
    in_escape = 0; /* get it out from escape state */
    help_state = 0;
    /* no flow control */
    pts.c_cflag &= ~CRTSCTS;
    pts.c_iflag &= ~(IXON | IXOFF | IXANY);
    tcsetattr(fd, TCSANOW, &pts);
    break;
  case '~':
  case 'q':
    in_escape = 0;
    help_state = 0;
    break;
  default:
    /* pass the character through */
    /* "C-\ C-\" sends "C-\" */
    write(fd, &c, 1);
    break;
  }

  if (in_escape == 0)
    help_done();

  return;
}