]> gitweb.factorcode.org Git - factor.git/blob - extra/io/serial/linux/ffi/ffi.factor
io.serial.linux.ffi: Move M: linux lookup-baud to io.serial.linux
[factor.git] / extra / io / serial / linux / ffi / ffi.factor
1 ! Copyright (C) 2008 Doug Coleman.
2 ! See https://factorcode.org/license.txt for BSD license.
3 USING: alien.c-types alien.syntax classes.struct kernel system ;
4 IN: io.serial.linux.ffi
5
6 CONSTANT: NCCS 32
7
8 TYPEDEF: uchar cc_t
9 TYPEDEF: uint speed_t
10 TYPEDEF: uint tcflag_t
11
12 STRUCT: termios
13     { iflag tcflag_t }
14     { oflag tcflag_t }
15     { cflag tcflag_t }
16     { lflag tcflag_t }
17     { line cc_t }
18     { cc { cc_t NCCS } }
19     { ispeed speed_t }
20     { ospeed speed_t } ;
21
22 FUNCTION: speed_t cfgetispeed ( termios* t )
23 FUNCTION: speed_t cfgetospeed ( termios* t )
24 FUNCTION: int cfsetispeed ( termios* t, speed_t s )
25 FUNCTION: int cfsetospeed ( termios* t, speed_t s )
26 FUNCTION: int tcgetattr ( int i1, termios* t )
27 FUNCTION: int tcsetattr ( int i1, int i2, termios* t )
28 FUNCTION: int tcdrain ( int i1 )
29 FUNCTION: int tcflow ( int i1, int i2 )
30 FUNCTION: int tcflush ( int i1, int i2 )
31 FUNCTION: int tcsendbreak ( int i1, int i2 )
32 FUNCTION: void cfmakeraw ( termios* t )
33 FUNCTION: int cfsetspeed ( termios* t, speed_t s )
34
35 ! See /usr/include/bits/termios.h
36 CONSTANT: TCSANOW     0
37 CONSTANT: TCSADRAIN   1
38 CONSTANT: TCSAFLUSH   2
39
40 CONSTANT: TCIFLUSH    0
41 CONSTANT: TCOFLUSH    1
42 CONSTANT: TCIOFLUSH   2
43
44 CONSTANT: TCOOFF      0
45 CONSTANT: TCOON       1
46 CONSTANT: TCIOFF      2
47 CONSTANT: TCION       3
48
49 ! iflag
50 CONSTANT: IGNBRK  0o0000001
51 CONSTANT: BRKINT  0o0000002
52 CONSTANT: IGNPAR  0o0000004
53 CONSTANT: PARMRK  0o0000010
54 CONSTANT: INPCK   0o0000020
55 CONSTANT: ISTRIP  0o0000040
56 CONSTANT: INLCR   0o0000100
57 CONSTANT: IGNCR   0o0000200
58 CONSTANT: ICRNL   0o0000400
59 CONSTANT: IUCLC   0o0001000
60 CONSTANT: IXON    0o0002000
61 CONSTANT: IXANY   0o0004000
62 CONSTANT: IXOFF   0o0010000
63 CONSTANT: IMAXBEL 0o0020000
64 CONSTANT: IUTF8   0o0040000
65
66 ! oflag
67 CONSTANT: OPOST   0o0000001
68 CONSTANT: OLCUC   0o0000002
69 CONSTANT: ONLCR   0o0000004
70 CONSTANT: OCRNL   0o0000010
71 CONSTANT: ONOCR   0o0000020
72 CONSTANT: ONLRET  0o0000040
73 CONSTANT: OFILL   0o0000100
74 CONSTANT: OFDEL   0o0000200
75 CONSTANT: NLDLY  0o0000400
76 CONSTANT:   NL0  0o0000000
77 CONSTANT:   NL1  0o0000400
78 CONSTANT: CRDLY  0o0003000
79 CONSTANT:   CR0  0o0000000
80 CONSTANT:   CR1  0o0001000
81 CONSTANT:   CR2  0o0002000
82 CONSTANT:   CR3  0o0003000
83 CONSTANT: TABDLY 0o0014000
84 CONSTANT:   TAB0 0o0000000
85 CONSTANT:   TAB1 0o0004000
86 CONSTANT:   TAB2 0o0010000
87 CONSTANT:   TAB3 0o0014000
88 CONSTANT: BSDLY  0o0020000
89 CONSTANT:   BS0  0o0000000
90 CONSTANT:   BS1  0o0020000
91 CONSTANT: FFDLY  0o0100000
92 CONSTANT:   FF0  0o0000000
93 CONSTANT:   FF1  0o0100000
94
95 ! cflags
96 CONSTANT: CSIZE   0o0000060
97 CONSTANT:   CS5   0o0000000
98 CONSTANT:   CS6   0o0000020
99 CONSTANT:   CS7   0o0000040
100 CONSTANT:   CS8   0o0000060
101 CONSTANT: CSTOPB  0o0000100
102 CONSTANT: CREAD   0o0000200
103 CONSTANT: PARENB  0o0000400
104 CONSTANT: PARODD  0o0001000
105 CONSTANT: HUPCL   0o0002000
106 CONSTANT: CLOCAL  0o0004000
107 CONSTANT: CIBAUD  0o002003600000
108 CONSTANT: CRTSCTS 0o020000000000
109
110 ! lflags
111 CONSTANT: ISIG    0o0000001
112 CONSTANT: ICANON  0o0000002
113 CONSTANT: XCASE   0o0000004
114 CONSTANT: ECHO    0o0000010
115 CONSTANT: ECHOE   0o0000020
116 CONSTANT: ECHOK   0o0000040
117 CONSTANT: ECHONL  0o0000100
118 CONSTANT: NOFLSH  0o0000200
119 CONSTANT: TOSTOP  0o0000400
120 CONSTANT: ECHOCTL 0o0001000
121 CONSTANT: ECHOPRT 0o0002000
122 CONSTANT: ECHOKE  0o0004000
123 CONSTANT: FLUSHO  0o0010000
124 CONSTANT: PENDIN  0o0040000
125 CONSTANT: IEXTEN  0o0100000
126
127 ! c_cc characters
128 CONSTANT: VINTR 0
129 CONSTANT: VQUIT 1
130 CONSTANT: VERASE 2
131 CONSTANT: VKILL 3
132 CONSTANT: VEOF 4
133 CONSTANT: VTIME 5
134 CONSTANT: VMIN 6
135 CONSTANT: VSWTC 7
136 CONSTANT: VSTART 8
137 CONSTANT: VSTOP 9
138 CONSTANT: VSUSP 10
139 CONSTANT: VEOL 11
140 CONSTANT: VREPRINT 12
141 CONSTANT: VDISCARD 13
142 CONSTANT: VWERASE 14
143 CONSTANT: VLNEXT 15
144 CONSTANT: VEOL2 16