8 tlserial=class(tlasio)
\r
21 termio, // despite the name the fpc termio unit seems to be an interface to termios
\r
23 procedure tlserial.open;
\r
27 baudrateos : longint;
\r
29 fd := fpopen(device,O_RDWR or O_NOCTTY or O_NONBLOCK);
\r
31 if isatty(fd)=0 then begin
\r
32 writeln('not a tty');
\r
36 fillchar(config,sizeof(config),#0);
\r
37 config.c_cflag := CLOCAL or CREAD;
\r
40 50: baudrateos := B50;
\r
41 75: baudrateos := B75;
\r
42 110: baudrateos := B110;
\r
43 134: baudrateos := B134;
\r
44 150: baudrateos := B150;
\r
45 200: baudrateos := B200;
\r
46 300: baudrateos := B300;
\r
47 600: baudrateos := B600;
\r
48 1200: baudrateos := B1200;
\r
49 1800: baudrateos := B1800;
\r
50 2400: baudrateos := B2400;
\r
51 4800: baudrateos := B4800;
\r
52 9600: baudrateos := B9600;
\r
53 19200: baudrateos := B19200;
\r
54 38400: baudrateos := B38400;
\r
55 57600: baudrateos := B57600;
\r
56 115200: baudrateos := B115200;
\r
57 230400: baudrateos := B230400;
\r
58 else raise exception.create('unrecognised baudrate');
\r
60 cfsetispeed(config,baudrateos);
\r
61 cfsetospeed(config,baudrateos);
\r
62 config.c_cc[VMIN] := 1;
\r
63 config.c_cc[VTIME] := 0;
\r
64 if tcsetattr(fd,TCSAFLUSH,config) <0 then begin
\r
65 writeln('could not set termios attributes');
\r
69 closehandles := true;
\r