diff options
Diffstat (limited to 'sdk/dev/speed.c')
-rw-r--r-- | sdk/dev/speed.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/sdk/dev/speed.c b/sdk/dev/speed.c new file mode 100644 index 0000000..f9fee56 --- /dev/null +++ b/sdk/dev/speed.c @@ -0,0 +1,75 @@ +/* + * Specify serial communications speed. + * $Id$ + * Copyright (c) 1997 by Tycho Softworks. + * For conditions of distribution and reuse see product license. + */ + +#include <dev/tty.h> +#ifndef TERMIOS_H_MISSING +#include <termios.h> +#endif + +int setspeed(stty_t tios, ulong speed) +{ + +#ifdef B38400 + int rate = B38400; +#else + int rate = B19200; +#endif + + switch(speed) + { + case 110: + rate = B110; + break; + case 300: + rate = B300; + break; + case 600: + rate = B600; + break; + case 1200: + rate = B1200; + break; + case 2400: + rate = B2400; + break; + case 4800: + rate = B4800; + break; + case 9600: + rate = B9600; + break; + case 19200: + rate = B19200; + break; +#ifdef B38400 + case 38400: + rate = B38400; + break; +#endif +#ifdef B57600 + case 57600: + rate = B57600; + break; +#endif +#ifdef B115200 + case 115200: + rate = B115200; + break; +#endif + } + +#ifndef TERMIOS_H_MISSING + cfsetospeed(tios, rate); + cfsetispeed(tios, rate); +#endif + return rate; +} + + + + + |