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