From 0cc9b20c15460213e488bf5e70963b941482f628 Mon Sep 17 00:00:00 2001 From: William Harrington Date: Tue, 14 Jan 2025 16:06:02 -0600 Subject: Add source. --- sdk/dev/speed.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 sdk/dev/speed.c (limited to 'sdk/dev/speed.c') 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 +#ifndef TERMIOS_H_MISSING +#include +#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; +} + + + + + -- cgit v1.2.3-54-g00ecf