# HG changeset patch # User Mychaela Falconia # Date 1506036302 0 # Node ID fb577c31e960dda2129f7a33c123658f623165a3 # Parent 8c011177adb9fbb75abbd3abb4940c652bfc16c7 fc-serterm converted to use libserial diff -r 8c011177adb9 -r fb577c31e960 miscutil/Makefile --- a/miscutil/Makefile Thu Sep 21 23:07:01 2017 +0000 +++ b/miscutil/Makefile Thu Sep 21 23:25:02 2017 +0000 @@ -9,7 +9,7 @@ FR2TCH_OBJS= fc-fr2tch.o gsm0610.o GSM2VM_OBJS= fc-gsm2vm.o gsm0610.o TCH2FR_OBJS= fc-tch2fr.o gsm0610.o -SERTERM_OBJS= fc-serterm.o openport.o ttypassthru.o +SERTERM_OBJS= fc-serterm.o ttypassthru.o ../libserial/libserial.a fc-fr2tch: ${FR2TCH_OBJS} ${CC} ${CFLAGS} -o $@ ${FR2TCH_OBJS} diff -r 8c011177adb9 -r fb577c31e960 miscutil/fc-serterm.c --- a/miscutil/fc-serterm.c Thu Sep 21 23:07:01 2017 +0000 +++ b/miscutil/fc-serterm.c Thu Sep 21 23:25:02 2017 +0000 @@ -9,8 +9,6 @@ #include #include -int target_fd; - main(argc, argv) char **argv; { @@ -18,7 +16,8 @@ fprintf(stderr, "usage: %s ttyname baudrate\n", argv[0]); exit(1); } - open_target_serial(argv[1], argv[2]); + open_serial_port(argv[1]); + set_fixed_baudrate(argv[2]); tty_passthru(); exit(0); } diff -r 8c011177adb9 -r fb577c31e960 miscutil/openport.c --- a/miscutil/openport.c Thu Sep 21 23:07:01 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -/* - * Serial port opening code for fc-serterm - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -extern int target_fd; - -static struct baudrate { - char *name; - speed_t termios_code; -} baud_rate_table[] = { - {"19200", B19200}, - {"38400", B38400}, - {"57600", B57600}, - {"115200", B115200}, - /* non-standard high baud rates "remapped" by CP2102 usb2serial IC */ - {"203125", B230400}, - {"406250", B460800}, - {"812500", B921600}, - /* table search terminator */ - {NULL, B0} -}; - -open_target_serial(ttydev, baudname) - char *ttydev, *baudname; -{ - struct termios target_termios; - struct baudrate *br; - - for (br = baud_rate_table; br->name; br++) - if (!strcmp(br->name, baudname)) - break; - if (!br->name) { - fprintf(stderr, "baud rate \"%s\" unknown/unsupported\n", - baudname); - exit(1); - } - target_fd = open(ttydev, O_RDWR|O_NONBLOCK); - if (target_fd < 0) { - perror(ttydev); - exit(1); - } - target_termios.c_iflag = IGNBRK; - target_termios.c_oflag = 0; - target_termios.c_cflag = CLOCAL|HUPCL|CREAD|CS8; - target_termios.c_lflag = 0; - target_termios.c_cc[VMIN] = 1; - target_termios.c_cc[VTIME] = 0; - cfsetispeed(&target_termios, br->termios_code); - cfsetospeed(&target_termios, br->termios_code); - if (tcsetattr(target_fd, TCSAFLUSH, &target_termios) < 0) { - perror("initial tcsetattr on target"); - exit(1); - } - return 0; -}