comparison svr-chansession.c @ 312:24056a5eb75b ucc-axis-hack

serial works better. enable DSS.
author matt-ucc@ucc.asn.au
date Sun, 26 Mar 2006 13:05:31 +0000
parents 6e5f8ce73bf2
children fabcee551349
comparison
equal deleted inserted replaced
310:4b4478d0d2b9 312:24056a5eb75b
645 } 645 }
646 646
647 static void serial_connect(struct Channel *channel) { 647 static void serial_connect(struct Channel *channel) {
648 648
649 int serial_fd; 649 int serial_fd;
650 struct termios options;
650 651
651 TRACE(("enter serial_connect")) 652 TRACE(("enter serial_connect"))
652 653
653 serial_fd = open(SERIAL_DEVICE, O_RDWR | O_NOCTTY, 0); 654 serial_fd = open(SERIAL_DEVICE, O_RDWR | O_NOCTTY, 0);
654 TRACE(("serial_fd = %d", serial_fd)) 655 TRACE(("serial_fd = %d", serial_fd))
657 dropbear_exit("Failed opening '%s': %d %s", SERIAL_DEVICE, 658 dropbear_exit("Failed opening '%s': %d %s", SERIAL_DEVICE,
658 errno, strerror(errno)); 659 errno, strerror(errno));
659 } 660 }
660 661
661 TRACE(("success serial_connect")) 662 TRACE(("success serial_connect"))
662 /* XXX TODO - code to set the serial fd to the right baud/settings etc */ 663
664 /* set some serial options. XXX needs attention */
665 tcgetattr(serial_fd, &options);
666
667 cfsetispeed(&options, B9600);
668 cfsetospeed(&options, B9600);
669
670 options.c_cflag &= ~CSIZE; /* Mask the character size bits */
671 options.c_cflag |= CS8; /* Select 8 data bits */
672 options.c_cflag &= ~PARENB;
673 options.c_cflag &= ~CSTOPB;
674 options.c_cflag &= ~CSIZE;
675
676 options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
677 options.c_iflag |= (INPCK | ISTRIP);
678
679 tcsetattr(serial_fd, TCSANOW, &options);
680
663 681
664 ses.maxfd = MAX(serial_fd, channel->writefd); 682 ses.maxfd = MAX(serial_fd, channel->writefd);
665 setnonblocking(serial_fd); 683 setnonblocking(serial_fd);
666 684
667 channel->writefd = serial_fd; 685 channel->writefd = serial_fd;