aboutsummaryrefslogtreecommitdiffstats
path: root/sdk/dev/format.c
diff options
context:
space:
mode:
authorWilliam Harrington <kb0iic@berzerkula.org>2025-01-14 16:06:02 -0600
committerWilliam Harrington <kb0iic@berzerkula.org>2025-01-14 16:06:02 -0600
commit0cc9b20c15460213e488bf5e70963b941482f628 (patch)
treebb0143245583ec846630f39bfa2258dba640ccd7 /sdk/dev/format.c
parent0e084ade5069756d487b5c948c48b777e37c00c9 (diff)
Add source.
Diffstat (limited to 'sdk/dev/format.c')
-rw-r--r--sdk/dev/format.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/sdk/dev/format.c b/sdk/dev/format.c
new file mode 100644
index 0000000..508ec6c
--- /dev/null
+++ b/sdk/dev/format.c
@@ -0,0 +1,64 @@
+/*
+ * Specify serial port data line format.
+ * $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 setformat(stty_t stty, char *format)
+{
+#ifndef TERMIOS_H_MISSING
+ struct termios *tios = stty;
+
+ tios->c_cflag &= ~CSIZE;
+ if(format[2] == '1')
+ tios->c_cflag &= ~CSTOPB;
+ else
+ tios->c_cflag |= CSTOPB;
+
+ switch(format[0])
+ {
+ case '5':
+ tios->c_cflag |= CS5;
+ break;
+ case '6':
+ tios->c_cflag |= CS6;
+ break;
+ case '7':
+ tios->c_cflag |= CS7;
+ break;
+ case '8':
+ tios->c_cflag |= CS8;
+ break;
+ }
+
+ switch(format[1])
+ {
+ case 'n':
+ case 'N':
+ tios->c_cflag &= ~(PARODD | PARENB);
+ break;
+ case 'e':
+ case 'E':
+ tios->c_cflag |= PARENB;
+ tios->c_cflag &= ~PARODD;
+ break;
+ case 'o':
+ case 'O':
+ tios->c_cflag |= (PARENB | PARODD);
+ break;
+ }
+
+#endif
+ return 0;
+}
+
+
+
+
+