# HG changeset patch # User Mychaela Falconia # Date 1583438071 0 # Node ID fd7b447b99e3ae51b05c5f914080ba2581f48603 # Parent b343849910942929382c06db1d7bb5ecd9b44208 libserial rename The version that was previously named libserial-newlnx is now libserial-linux, and the version that was previosly named libserial-orig is now libserial-posix. This new naming is more in line with the objective reality of the difference, moving away from naming based on our project history. diff -r b34384991094 -r fd7b447b99e3 libserial --- a/libserial Wed Mar 04 06:51:52 2020 +0000 +++ b/libserial Thu Mar 05 19:54:31 2020 +0000 @@ -1,1 +1,1 @@ -libserial-newlnx \ No newline at end of file +libserial-linux \ No newline at end of file diff -r b34384991094 -r fd7b447b99e3 libserial-linux/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libserial-linux/Makefile Thu Mar 05 19:54:31 2020 +0000 @@ -0,0 +1,13 @@ +CC= gcc +CFLAGS= -O2 +OBJS= baudtab.o nonblock.o openport.o setbaud.o setbyname.o +LIB= libserial.a + +all: ${LIB} + +${LIB}: ${OBJS} + ar rcu $@ ${OBJS} + ranlib $@ + +clean: + rm -f *.[oa] errs diff -r b34384991094 -r fd7b447b99e3 libserial-linux/baudrate.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libserial-linux/baudrate.h Thu Mar 05 19:54:31 2020 +0000 @@ -0,0 +1,9 @@ +/* this header file defines the data structure for baud rate machinations */ + +struct baudrate { + char *name; + int termios_code; + int nonstd_speed; + int bootrom_code; + int xram_records; +}; diff -r b34384991094 -r fd7b447b99e3 libserial-linux/baudtab.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libserial-linux/baudtab.c Thu Mar 05 19:54:31 2020 +0000 @@ -0,0 +1,43 @@ +/* + * This module contains the table of baud rates supported + * by this implementation of FreeCalypso libserial. + */ + +#include +#include +#include +#include +#include +#include "baudrate.h" + +struct baudrate baud_rate_table[] = { + /* the first listed rate will be our default */ + {"115200", B115200, 0, 0, 100}, + {"57600", B57600, 0, 1, 100}, + {"38400", B38400, 0, 2, 100}, + {"19200", B19200, 0, 4, 50}, + /* Non-standard high baud rates */ + {"812500", BOTHER, 812500, -1, 1000}, + {"406250", BOTHER, 406250, -1, 500}, + {"203125", BOTHER, 203125, -1, 250}, + /* table search terminator */ + {NULL, B0, 0, -1, 0}, +}; + +struct baudrate * +find_baudrate_by_name(srch_name) + char *srch_name; +{ + struct baudrate *br; + + for (br = baud_rate_table; br->name; br++) + if (!strcmp(br->name, srch_name)) + break; + if (br->name) + return(br); + else { + fprintf(stderr, "error: baud rate \"%s\" not known\n", + srch_name); + return(NULL); + } +} diff -r b34384991094 -r fd7b447b99e3 libserial-linux/nonblock.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libserial-linux/nonblock.c Thu Mar 05 19:54:31 2020 +0000 @@ -0,0 +1,15 @@ +/* + * This module contains the set_serial_nonblock() function. + */ + +#include +#include +#include + +extern int target_fd; + +set_serial_nonblock(state) + int state; +{ + ioctl(target_fd, FIONBIO, &state); +} diff -r b34384991094 -r fd7b447b99e3 libserial-linux/openport.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libserial-linux/openport.c Thu Mar 05 19:54:31 2020 +0000 @@ -0,0 +1,24 @@ +/* + * This module implements the basic serial port opening operation. + */ + +#include +#include +#include +#include +#include +#include + +int target_fd; + +open_serial_port(ttyport) + char *ttyport; +{ + target_fd = open(ttyport, O_RDWR|O_NONBLOCK); + if (target_fd < 0) { + perror(ttyport); + exit(1); + } + ioctl(target_fd, TIOCEXCL); + return 0; +} diff -r b34384991094 -r fd7b447b99e3 libserial-linux/setbaud.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libserial-linux/setbaud.c Thu Mar 05 19:54:31 2020 +0000 @@ -0,0 +1,37 @@ +/* + * This module implements the termios/ioctl setting of the baud rate. + */ + +#include +#include +#include +#include +#include +#include +#include +#include "baudrate.h" + +extern int target_fd; + +struct baudrate *current_baud_rate; + +set_serial_baudrate(br) + struct baudrate *br; +{ + struct termios2 target_termios; + + target_termios.c_iflag = IGNBRK; + target_termios.c_oflag = 0; + target_termios.c_cflag = br->termios_code | CLOCAL|HUPCL|CREAD|CS8; + target_termios.c_lflag = 0; + target_termios.c_cc[VMIN] = 1; + target_termios.c_cc[VTIME] = 0; + target_termios.c_ispeed = br->nonstd_speed; + target_termios.c_ospeed = br->nonstd_speed; + if (ioctl(target_fd, TCSETSF2, &target_termios) < 0) { + perror("TCSETSF2"); + exit(1); + } + current_baud_rate = br; + return 0; +} diff -r b34384991094 -r fd7b447b99e3 libserial-linux/setbyname.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libserial-linux/setbyname.c Thu Mar 05 19:54:31 2020 +0000 @@ -0,0 +1,21 @@ +/* + * This module contains the wrapper function (used by loadtools) + * that looks up a baud rate by name and calls set_serial_baud(). + */ + +#include +#include +#include "baudrate.h" + +extern struct baudrate *find_baudrate_by_name(); + +set_fixed_baudrate(baudname) + char *baudname; +{ + struct baudrate *br; + + br = find_baudrate_by_name(baudname); + if (!br) + exit(1); /* error msg already printed */ + set_serial_baudrate(br); +} diff -r b34384991094 -r fd7b447b99e3 libserial-newlnx/Makefile --- a/libserial-newlnx/Makefile Wed Mar 04 06:51:52 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -CC= gcc -CFLAGS= -O2 -OBJS= baudtab.o nonblock.o openport.o setbaud.o setbyname.o -LIB= libserial.a - -all: ${LIB} - -${LIB}: ${OBJS} - ar rcu $@ ${OBJS} - ranlib $@ - -clean: - rm -f *.[oa] errs diff -r b34384991094 -r fd7b447b99e3 libserial-newlnx/baudrate.h --- a/libserial-newlnx/baudrate.h Wed Mar 04 06:51:52 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ -/* this header file defines the data structure for baud rate machinations */ - -struct baudrate { - char *name; - int termios_code; - int nonstd_speed; - int bootrom_code; - int xram_records; -}; diff -r b34384991094 -r fd7b447b99e3 libserial-newlnx/baudtab.c --- a/libserial-newlnx/baudtab.c Wed Mar 04 06:51:52 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -/* - * This module contains the table of baud rates supported - * by this implementation of FreeCalypso libserial. - */ - -#include -#include -#include -#include -#include -#include "baudrate.h" - -struct baudrate baud_rate_table[] = { - /* the first listed rate will be our default */ - {"115200", B115200, 0, 0, 100}, - {"57600", B57600, 0, 1, 100}, - {"38400", B38400, 0, 2, 100}, - {"19200", B19200, 0, 4, 50}, - /* Non-standard high baud rates */ - {"812500", BOTHER, 812500, -1, 1000}, - {"406250", BOTHER, 406250, -1, 500}, - {"203125", BOTHER, 203125, -1, 250}, - /* table search terminator */ - {NULL, B0, 0, -1, 0}, -}; - -struct baudrate * -find_baudrate_by_name(srch_name) - char *srch_name; -{ - struct baudrate *br; - - for (br = baud_rate_table; br->name; br++) - if (!strcmp(br->name, srch_name)) - break; - if (br->name) - return(br); - else { - fprintf(stderr, "error: baud rate \"%s\" not known\n", - srch_name); - return(NULL); - } -} diff -r b34384991094 -r fd7b447b99e3 libserial-newlnx/nonblock.c --- a/libserial-newlnx/nonblock.c Wed Mar 04 06:51:52 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -/* - * This module contains the set_serial_nonblock() function. - */ - -#include -#include -#include - -extern int target_fd; - -set_serial_nonblock(state) - int state; -{ - ioctl(target_fd, FIONBIO, &state); -} diff -r b34384991094 -r fd7b447b99e3 libserial-newlnx/openport.c --- a/libserial-newlnx/openport.c Wed Mar 04 06:51:52 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -/* - * This module implements the basic serial port opening operation. - */ - -#include -#include -#include -#include -#include -#include - -int target_fd; - -open_serial_port(ttyport) - char *ttyport; -{ - target_fd = open(ttyport, O_RDWR|O_NONBLOCK); - if (target_fd < 0) { - perror(ttyport); - exit(1); - } - ioctl(target_fd, TIOCEXCL); - return 0; -} diff -r b34384991094 -r fd7b447b99e3 libserial-newlnx/setbaud.c --- a/libserial-newlnx/setbaud.c Wed Mar 04 06:51:52 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -/* - * This module implements the termios/ioctl setting of the baud rate. - */ - -#include -#include -#include -#include -#include -#include -#include -#include "baudrate.h" - -extern int target_fd; - -struct baudrate *current_baud_rate; - -set_serial_baudrate(br) - struct baudrate *br; -{ - struct termios2 target_termios; - - target_termios.c_iflag = IGNBRK; - target_termios.c_oflag = 0; - target_termios.c_cflag = br->termios_code | CLOCAL|HUPCL|CREAD|CS8; - target_termios.c_lflag = 0; - target_termios.c_cc[VMIN] = 1; - target_termios.c_cc[VTIME] = 0; - target_termios.c_ispeed = br->nonstd_speed; - target_termios.c_ospeed = br->nonstd_speed; - if (ioctl(target_fd, TCSETSF2, &target_termios) < 0) { - perror("TCSETSF2"); - exit(1); - } - current_baud_rate = br; - return 0; -} diff -r b34384991094 -r fd7b447b99e3 libserial-newlnx/setbyname.c --- a/libserial-newlnx/setbyname.c Wed Mar 04 06:51:52 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -/* - * This module contains the wrapper function (used by loadtools) - * that looks up a baud rate by name and calls set_serial_baud(). - */ - -#include -#include -#include "baudrate.h" - -extern struct baudrate *find_baudrate_by_name(); - -set_fixed_baudrate(baudname) - char *baudname; -{ - struct baudrate *br; - - br = find_baudrate_by_name(baudname); - if (!br) - exit(1); /* error msg already printed */ - set_serial_baudrate(br); -} diff -r b34384991094 -r fd7b447b99e3 libserial-orig/Makefile --- a/libserial-orig/Makefile Wed Mar 04 06:51:52 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -CC= gcc -CFLAGS= -O2 -OBJS= baudtab.o nonblock.o openport.o setbaud.o setbyname.o -LIB= libserial.a - -all: ${LIB} - -${LIB}: ${OBJS} - ar rcu $@ ${OBJS} - ranlib $@ - -clean: - rm -f *.[oa] errs diff -r b34384991094 -r fd7b447b99e3 libserial-orig/baudrate.h --- a/libserial-orig/baudrate.h Wed Mar 04 06:51:52 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -/* this header file defines the data structure for baud rate machinations */ - -struct baudrate { - char *name; - int termios_code; - int bootrom_code; - int xram_records; -}; diff -r b34384991094 -r fd7b447b99e3 libserial-orig/baudtab.c --- a/libserial-orig/baudtab.c Wed Mar 04 06:51:52 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* - * This module contains the table of baud rates supported - * by this implementation of FreeCalypso libserial. - */ - -#include -#include -#include -#include -#include -#include "baudrate.h" - -struct baudrate baud_rate_table[] = { - /* the first listed rate will be our default */ - {"115200", B115200, 0, 100}, - {"57600", B57600, 1, 100}, - {"38400", B38400, 2, 100}, - {"19200", B19200, 4, 50}, - /* - * Non-standard high baud rates remapped by CP2102 EEPROM programming - * or by a hacky patch to the ftdi_sio Linux kernel driver to work - * with FTDI adapters. - */ - {"812500", B921600, -1, 1000}, - {"406250", B460800, -1, 500}, - {"203125", B230400, -1, 250}, - /* table search terminator */ - {NULL, B0, -1}, -}; - -struct baudrate * -find_baudrate_by_name(srch_name) - char *srch_name; -{ - struct baudrate *br; - - for (br = baud_rate_table; br->name; br++) - if (!strcmp(br->name, srch_name)) - break; - if (br->name) - return(br); - else { - fprintf(stderr, "error: baud rate \"%s\" not known\n", - srch_name); - return(NULL); - } -} diff -r b34384991094 -r fd7b447b99e3 libserial-orig/nonblock.c --- a/libserial-orig/nonblock.c Wed Mar 04 06:51:52 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -/* - * This module contains the set_serial_nonblock() function. - */ - -#include -#include -#include - -extern int target_fd; - -set_serial_nonblock(state) - int state; -{ - ioctl(target_fd, FIONBIO, &state); -} diff -r b34384991094 -r fd7b447b99e3 libserial-orig/openport.c --- a/libserial-orig/openport.c Wed Mar 04 06:51:52 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -/* - * This module implements the basic serial port opening operation. - */ - -#include -#include -#include -#include -#include -#include - -int target_fd; - -open_serial_port(ttyport) - char *ttyport; -{ - target_fd = open(ttyport, O_RDWR|O_NONBLOCK); - if (target_fd < 0) { - perror(ttyport); - exit(1); - } - ioctl(target_fd, TIOCEXCL); - return 0; -} diff -r b34384991094 -r fd7b447b99e3 libserial-orig/setbaud.c --- a/libserial-orig/setbaud.c Wed Mar 04 06:51:52 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -/* - * This module implements the termios/ioctl setting of the baud rate. - */ - -#include -#include -#include -#include -#include -#include -#include "baudrate.h" - -extern int target_fd; - -struct baudrate *current_baud_rate; - -set_serial_baudrate(br) - struct baudrate *br; -{ - struct termios target_termios; - - 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("tcsetattr"); - exit(1); - } - current_baud_rate = br; - return 0; -} diff -r b34384991094 -r fd7b447b99e3 libserial-orig/setbyname.c --- a/libserial-orig/setbyname.c Wed Mar 04 06:51:52 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -/* - * This module contains the wrapper function (used by loadtools) - * that looks up a baud rate by name and calls set_serial_baud(). - */ - -#include -#include -#include "baudrate.h" - -extern struct baudrate *find_baudrate_by_name(); - -set_fixed_baudrate(baudname) - char *baudname; -{ - struct baudrate *br; - - br = find_baudrate_by_name(baudname); - if (!br) - exit(1); /* error msg already printed */ - set_serial_baudrate(br); -} diff -r b34384991094 -r fd7b447b99e3 libserial-posix/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libserial-posix/Makefile Thu Mar 05 19:54:31 2020 +0000 @@ -0,0 +1,13 @@ +CC= gcc +CFLAGS= -O2 +OBJS= baudtab.o nonblock.o openport.o setbaud.o setbyname.o +LIB= libserial.a + +all: ${LIB} + +${LIB}: ${OBJS} + ar rcu $@ ${OBJS} + ranlib $@ + +clean: + rm -f *.[oa] errs diff -r b34384991094 -r fd7b447b99e3 libserial-posix/baudrate.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libserial-posix/baudrate.h Thu Mar 05 19:54:31 2020 +0000 @@ -0,0 +1,8 @@ +/* this header file defines the data structure for baud rate machinations */ + +struct baudrate { + char *name; + int termios_code; + int bootrom_code; + int xram_records; +}; diff -r b34384991094 -r fd7b447b99e3 libserial-posix/baudtab.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libserial-posix/baudtab.c Thu Mar 05 19:54:31 2020 +0000 @@ -0,0 +1,47 @@ +/* + * This module contains the table of baud rates supported + * by this implementation of FreeCalypso libserial. + */ + +#include +#include +#include +#include +#include +#include "baudrate.h" + +struct baudrate baud_rate_table[] = { + /* the first listed rate will be our default */ + {"115200", B115200, 0, 100}, + {"57600", B57600, 1, 100}, + {"38400", B38400, 2, 100}, + {"19200", B19200, 4, 50}, + /* + * Non-standard high baud rates remapped by CP2102 EEPROM programming + * or by a hacky patch to the ftdi_sio Linux kernel driver to work + * with FTDI adapters. + */ + {"812500", B921600, -1, 1000}, + {"406250", B460800, -1, 500}, + {"203125", B230400, -1, 250}, + /* table search terminator */ + {NULL, B0, -1}, +}; + +struct baudrate * +find_baudrate_by_name(srch_name) + char *srch_name; +{ + struct baudrate *br; + + for (br = baud_rate_table; br->name; br++) + if (!strcmp(br->name, srch_name)) + break; + if (br->name) + return(br); + else { + fprintf(stderr, "error: baud rate \"%s\" not known\n", + srch_name); + return(NULL); + } +} diff -r b34384991094 -r fd7b447b99e3 libserial-posix/nonblock.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libserial-posix/nonblock.c Thu Mar 05 19:54:31 2020 +0000 @@ -0,0 +1,15 @@ +/* + * This module contains the set_serial_nonblock() function. + */ + +#include +#include +#include + +extern int target_fd; + +set_serial_nonblock(state) + int state; +{ + ioctl(target_fd, FIONBIO, &state); +} diff -r b34384991094 -r fd7b447b99e3 libserial-posix/openport.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libserial-posix/openport.c Thu Mar 05 19:54:31 2020 +0000 @@ -0,0 +1,24 @@ +/* + * This module implements the basic serial port opening operation. + */ + +#include +#include +#include +#include +#include +#include + +int target_fd; + +open_serial_port(ttyport) + char *ttyport; +{ + target_fd = open(ttyport, O_RDWR|O_NONBLOCK); + if (target_fd < 0) { + perror(ttyport); + exit(1); + } + ioctl(target_fd, TIOCEXCL); + return 0; +} diff -r b34384991094 -r fd7b447b99e3 libserial-posix/setbaud.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libserial-posix/setbaud.c Thu Mar 05 19:54:31 2020 +0000 @@ -0,0 +1,36 @@ +/* + * This module implements the termios/ioctl setting of the baud rate. + */ + +#include +#include +#include +#include +#include +#include +#include "baudrate.h" + +extern int target_fd; + +struct baudrate *current_baud_rate; + +set_serial_baudrate(br) + struct baudrate *br; +{ + struct termios target_termios; + + 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("tcsetattr"); + exit(1); + } + current_baud_rate = br; + return 0; +} diff -r b34384991094 -r fd7b447b99e3 libserial-posix/setbyname.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libserial-posix/setbyname.c Thu Mar 05 19:54:31 2020 +0000 @@ -0,0 +1,21 @@ +/* + * This module contains the wrapper function (used by loadtools) + * that looks up a baud rate by name and calls set_serial_baud(). + */ + +#include +#include +#include "baudrate.h" + +extern struct baudrate *find_baudrate_by_name(); + +set_fixed_baudrate(baudname) + char *baudname; +{ + struct baudrate *br; + + br = find_baudrate_by_name(baudname); + if (!br) + exit(1); /* error msg already printed */ + set_serial_baudrate(br); +}