View Issue Details

IDProjectCategoryView StatusLast Update
0036958FPCRTLpublic2020-05-01 14:11
ReporterRudolf Cornelissen Assigned ToSven Barth  
PrioritynormalSeverityminorReproducibilityalways
Status feedbackResolutionopen 
OSHaiku 
Product Version3.3.1 
Summary0036958: termios for Haiku is outdated fpc 3.2.0 and trunk (at least)
DescriptionPlease update rtl/haiku termios with the included version: the current version is very much outdated and prevents serial / USB-serial I/O on Haiku (all current versions) to actually work.
Steps To ReproduceOpen serial port, set for instance baudrate to something else than 9600, and try to communicate. Fails at all times.
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget-
Attached Files

Activities

Rudolf Cornelissen

2020-04-23 16:00

reporter  

haiku_termios_update_20200423.patch (19,881 bytes)   
Index: termios.inc
===================================================================
--- termios.inc	(revision 44513)
+++ termios.inc	(working copy)
@@ -3,6 +3,9 @@
    (c) 2000-2003 by Marco van de Voort
    member of the Free Pascal development team.
 
+   April 2020 Modifications by Rudolf Cornelissen
+   for Haiku. Tested with SynaSer on Haiku x64.
+
    See the file COPYING.FPC, included in this distribution,
    for details about the copyright.
 
@@ -17,12 +20,11 @@
 
 {
  * Special Control Characters
- *
  * Index into c_cc[] character array.
- *
  *      Name         Subscript  Enabled by
  }
- { control characters }
+
+{ control characters }
 VINTR	= 0;
 VQUIT	= 1;
 VERASE	= 2;
@@ -50,9 +52,6 @@
   end;
   TWinSize=winsize;
 
-// typedef unsigned long tcflag_t;
-// typedef unsigned char speed_t;
-// typedef unsigned char cc_t;
  tcflag_t = Cardinal;
  speed_t = byte;
  cc_t = char;
@@ -64,8 +63,8 @@
     c_cflag,
     c_lflag  : tcflag_t;
     c_line   : char;
-    c_ixxxxx : speed_t;
-    c_oxxxxx : speed_t;
+    c_ispeed : speed_t;
+    c_ospeed : speed_t;
     c_cc     : array[0..NCCS-1] of speed_t;
   end;
   TTermios=Termios;
@@ -74,13 +73,9 @@
 
 
  POSIX_VDISABLE=Chr($ff);
-{
 
-#define CCEQ(val, c)    ((c) == (val) ? (val) != _POSIX_VDISABLE : 0)
-}
-
-{ * Input flags - software input processing}
-
+ 
+{ Input flags - software input processing }
         IGNBRK          =       $1;     { ignore BREAK condition }
         BRKINT          =       $2;     { map BREAK to SIGINTR }
         IGNPAR          =       $4;     { ignore (discard) parity errors }
@@ -95,10 +90,7 @@
         IXANY           =     $800;     { enable input flow control }
         IXOFF           =    $1000;	    { any char will restart after stop }
 
-{
- * Output flags - software output processing
-}
-
+{ Output flags - software output processing }
 OPOST		= $01;		{ enable postprocessing of output }
 OLCUC		= $02;		{ maps lowercase to uppercase }
 ONLCR		= $04;		{ maps NL to CR-NL on output }
@@ -130,10 +122,7 @@
 FF0			= $0000;
 FF1			= $8000;
 
-{
-  c_cflag - control modes
-}
-
+{ c_cflag - control modes }
 CBAUD		= $1F;			{ line speed definitions }
 
 B0			= $00;
@@ -183,10 +172,7 @@
  * input flag.
  }
  
-{
-  c_lflag - local modes
-}
-
+{ c_lflag - local modes }
 ISIG		= $01;			{ enable signals }
 ICANON		= $02;			{ Canonical input }
 XCASE		= $04;			{ Canonical u/l case }
@@ -197,227 +183,98 @@
 NOFLSH		= $80;			{ Disable flush after int or quit }
 TOSTOP      = $100;         { stop bg processes that write to tty }
 IEXTEN      = $200;         { implementation defined extensions }
+ECHOCTL		= $400;
+ECHOPRT		= $800;	
+ECHOKE		= $1000;
+FLUSHO		= $2000;
+PENDIN		= $4000;
 
-{
-  Event codes.  Returned from TCWAITEVENT
-}
+{ Event codes.  Returned from TCWAITEVENT }
 EV_RING			= $0001;
 EV_BREAK		= $0002;
 EV_CARRIER		= $0004;
 EV_CARRIERLOST	= $0008;
  
-{
- * Commands passed to tcsetattr() for setting the termios structure.
-}
 
 CONST
 
+{ options to tcsetattr() }
         TCSANOW         = $01;             { make change immediate }
         TCSADRAIN       = $02;             { drain output, then change }
         TCSAFLUSH       = $04;             { drain output, flush input }
-        
+
         // TCASOFT undefined under BeOS
         TCSASOFT        = $10;           { flag - don't alter h.w. state }
 
+{ values for tcflush() }
+        TCIFLUSH        = $01;             			{ flush pending input }
+        TCOFLUSH        = $02;						{ flush untransmitted output }
+        TCIOFLUSH       = (TCIFLUSH or TCOFLUSH);	{ flush both }
 
-        TCIFLUSH        = $01;
-        TCOFLUSH        = $02;
-        TCIOFLUSH       = (TCIFLUSH or TCOFLUSH);
-        TCOOFF          = $01;
-        TCOON           = $02;
-        TCIOFF          = $04;
-        TCION           = $08;
+{ actions for tcflow() }
+        TCOOFF          = $01;			{ suspend output }
+        TCOON           = $02;			{ restart output }
+        TCIOFF          = $04;			{ transmit STOP character, intended to stop input data }
+        TCION           = $08;			{ transmit START character, intended to resume input data }
 
-{
-#include <sys/cdefs.h>
 
-__BEGIN_DECLS
-speed_t cfgetispeed __P((const struct termios *));
-speed_t cfgetospeed __P((const struct termios *));
-int     cfsetispeed __P((struct termios *, speed_t));
-int     cfsetospeed __P((struct termios *, speed_t));
-int     tcgetattr __P((int, struct termios *));
-int     tcsetattr __P((int, int, const struct termios *));
-int     tcdrain __P((int));
-int     tcflow __P((int, int));
-int     tcflush __P((int, int));
-int     tcsendbreak __P((int, int));
+{ Bits for the TCGETBITS control }
+TCGB_CTS		= $01;
+TCGB_DSR		= $02;
+TCGB_RI			= $04;
+TCGB_DCD		= $08;
 
-#ifndef _POSIX_SOURCE
-void    cfmakeraw __P((struct termios *));
-int     cfsetspeed __P((struct termios *, speed_t));
-#endif { !_POSIX_SOURCE }
-__END_DECLS
 
-#endif { !_KERNEL }
+{ Bits for the TIOCMGET / TIOCMSET control }
+TIOCM_CTS		= TCGB_CTS;	{ clear to send }
+TIOCM_CD		= TCGB_DCD;	{ carrier detect }
+TIOCM_CAR		= TIOCM_CD;
+TIOCM_RI		= TCGB_RI;	{ ring indicator }
+TIOCM_RNG       = TIOCM_RI;
+TIOCM_DSR		= TCGB_DSR;	{ dataset ready }
+TIOCM_DTR		= $10;		{ data terminal ready }
+TIOCM_RTS		= $20;		{ request to send }
 
 
+TCGETA		    	= $8000;
+TCSETA		  		= TCGETA + 1;
+TCSETAF		  		= TCGETA + 2;
+TCSETAW		  		= TCGETA + 3;
+TCWAITEVENT	  		= TCGETA + 4;
+TCSBRK	      		= TCGETA + 5;
+TCFLSH	      		= TCGETA + 6;
+TCXONC				= TCGETA + 7;
+TCQUERYCONNECTED  	= TCGETA + 8;
+TCGETBITS	  		= TCGETA + 9;
+TCSETDTR          	= TCGETA + 10;
+TCSETRTS	  		= TCGETA + 11;
+TIOCGWINSZ	  		= TCGETA + 12;  (* pass in a struct winsize *)
+TIOCSWINSZ	  		= TCGETA + 13;  (* pass in a struct winsize *)
+TCVTIME		  		= TCGETA + 14;  (* pass in bigtime_t, old value saved *)
+TIOCGPGRP	  		= TCGETA + 15;	(* Gets the process group ID of the TTY device *)
+TIOCSPGRP	  		= TCGETA + 16;	(* Sets the process group ID ('pgid' in BeOS) *)
+TIOCSCTTY	  		= TCGETA + 17;	(* Become controlling TTY *)
+TIOCMGET	  		= TCGETA + 18;	(* get line state, like TCGETBITS *)
+TIOCMSET	  		= TCGETA + 19;	(* does TCSETDTR/TCSETRTS *)
+TIOCSBRK	  		= TCGETA + 20;	(* set txd pin *)
+TIOCCBRK	  		= TCGETA + 21;	(* both are a frontend to TCSBRK *)
+TIOCMBIS	  		= TCGETA + 22;	(* set bits in line state *)
+TIOCMBIC          	= TCGETA + 23;	(* clear bits in line state *)
 
-struct winsize {
-        unsigned short  ws_row;         { rows, in characters }
-        unsigned short  ws_col;         { columns, in characters }
-        unsigned short  ws_xpixel;      { horizontal size, pixels }
-        unsigned short  ws_ypixel;      { vertical size, pixels }
-};
 
-}
-(*       IOCTLREAD        = $40000000;
-       IOCTLWRITE       = $80000000;
-       IOCTLVOID        = $20000000;
-
-        TIOCMODG        = IOCTLREAD+$47400+ 3;  { get modem control state }
-        TIOCMODS        = IOCTLWRITE+$47400+ 4; { set modem control state }
-                TIOCM_LE        =$0001;         { line enable }
-                TIOCM_DTR       =$0002;         { data terminal ready }
-                TIOCM_RTS       =$0004;         { request to send }
-                TIOCM_ST        =$0010;         { secondary transmit }
-                TIOCM_SR        =$0020;         { secondary receive }
-                TIOCM_CTS       =$0040;         { clear to send }
-                TIOCM_CAR       =$0100;         { carrier detect }
-                TIOCM_CD        =TIOCM_CAR;
-                TIOCM_RNG       =$0200;         { ring }
-                TIOCM_RI        =TIOCM_RNG;
-                TIOCM_DSR       =$0400;         { data set ready }
-                                                { 8-10 compat }
-        TIOCEXCL         =IOCTLVOID+$7400+ 13;          { set exclusive use of tty }
-        TIOCNXCL         =IOCTLVOID+$7400+ 14;          { reset exclusive use of tty }
-*)                                                { 15 unused }
-//        TIOCFLUSH        =IOCTLWRITE+$47400+ 16;        { flush buffers }
-                                                { 17-18 compat }
-//        TIOCGETA         =IOCTLREAD+$2C7400+ 19; { get termios struct }
-//        TIOCSETA         =IOCTLWRITE+$2C7400+ 20; { set termios struct }
-//        TIOCSETAW        =IOCTLWRITE+$2C7400+ 21; { drain output, set }
-//        TIOCSETAF        =IOCTLWRITE+$2C7400+ 22; { drn out, fls in, set }
-//        TIOCGETD         =IOCTLREAD+$47400+ 26; { get line discipline }
-//        TIOCSETD         =IOCTLWRITE+$47400+ 27;        { set line discipline }
-	                                                { 127-124 compat }
-
-// BeOS values
-		TIOCGETA		= $8000;		
-		TIOCSETA		= TIOCGETA + 1;
-		TIOCSETAF		= TIOCGETA + 2;
-		TIOCSETAW		= TIOCGETA + 3;
-		TCWAITEVENT		= TIOCGETA + 4;
-		TIOCSBRK		= TIOCGETA + 5;
-		TIOCFLUSH		= TIOCGETA + 6;
-		TCXONC			= TIOCGETA + 7;
-		TCQUERYCONNECTED= TIOCGETA + 8;
-		TCGETBITS		= TIOCGETA + 9;
-		TIOCSDTR		= TIOCGETA + 10;
-		TCSETRTS		= TIOCGETA + 11;
-		TIOCGWINSZ		= TIOCGETA + 12;
-		TIOCSWINSZ		= TIOCGETA + 13;
-		TCVTIME			= TIOCGETA + 14;
-		
-		
-//		TIOCTIMESTAMP 	= TCVTIME;
-// end BeOS values
-(*		      
-//        TIOCSBRK         =IOCTLVOID+$7400+ 123;         { set break bit }
-        TIOCCBRK         =IOCTLVOID+$7400+ 122;         { clear break bit }
-//        TIOCSDTR         =IOCTLVOID+$7400+ 121;         { set data terminal ready }
-        TIOCCDTR         =IOCTLVOID+$7400+ 120;         { clear data terminal ready }
-        TIOCGPGRP        =IOCTLREAD+$47400+ 119;        { get pgrp of tty }
-        TIOCSPGRP        =IOCTLWRITE+$47400+ 118;       { set pgrp of tty }
-                                                { 117-116 compat }
-        TIOCOUTQ         =IOCTLREAD+$47400+ 115;        { output queue size }
-        TIOCSTI          =IOCTLWRITE+$17400+ 114;       { simulate terminal input }
-        TIOCNOTTY        =IOCTLVOID+$7400+ 113;         { void tty association }
-        TIOCPKT          =IOCTLWRITE+$47400+ 112;       { pty: set/clear packet mode }
-                TIOCPKT_DATA            =$00;   { data packet }
-                TIOCPKT_FLUSHREAD       =$01;   { flush packet }
-                TIOCPKT_FLUSHWRITE      =$02;   { flush packet }
-                TIOCPKT_STOP            =$04;   { stop output }
-                TIOCPKT_START           =$08;   { start output }
-                TIOCPKT_NOSTOP          =$10;   { no more ^S, ^Q }
-                TIOCPKT_DOSTOP          =$20;   { now do ^S ^Q }
-                TIOCPKT_IOCTL           =$40;   { state change of pty driver }
-        TIOCSTOP         =IOCTLVOID+$7400+ 111;         { stop output, like ^S }
-        TIOCSTART        =IOCTLVOID+$7400+ 110;         { start output, like ^Q }
-        TIOCMSET         =IOCTLWRITE+$47400+ 109;       { set all modem bits }
-        TIOCMBIS         =IOCTLWRITE+$47400+ 108;       { bis modem bits }
-        TIOCMBIC         =IOCTLWRITE+$47400+ 107;       { bic modem bits }
-        TIOCMGET         =IOCTLREAD+$47400+ 106;        { get all modem bits }
-        TIOCREMOTE       =IOCTLWRITE+$47400+ 105;       { remote input editing }
-//        TIOCGWINSZ       =IOCTLREAD+$87400+ 104;        { get window size }
-//        TIOCSWINSZ       =IOCTLWRITE+$87400+ 103;       { set window size }
-        TIOCUCNTL        =IOCTLWRITE+$47400+ 102;       { pty: set/clr usr cntl mode }
-        TIOCSTAT         =IOCTLVOID+$7400+ 101;         { simulate ^T status message }
-  //                       UIOCCMD(n)   _IO('u', n)     { usr cntl op "n" }
-        TIOCCONS         =IOCTLWRITE+$47400+ 98;        { become virtual console }
-        TIOCSCTTY        =IOCTLVOID+$7400+ 97;          { become controlling tty }
-        TIOCEXT          =IOCTLWRITE+$47400+ 96;        { pty: external processing }
-        TIOCSIG          =IOCTLVOID+$7400+ 95;          { pty: generate signal }
-        TIOCDRAIN        =IOCTLVOID+$7400+ 94;          { wait till output drained }
-        TIOCMSDTRWAIT    =IOCTLWRITE+$47400+ 91;        { modem: set wait on close }
-        TIOCMGDTRWAIT    =IOCTLREAD+$47400+ 90; { modem: get wait on close }
-//        TIOCTIMESTAMP    =IOCTLREAD+$87400+ 89;         { enable/get timestamp
-//                                                 * of last input event }
-        TIOCDCDTIMESTAMP =IOCTLREAD+$87400+ 88; { enable/get timestamp
-                                                 * of last DCd rise }
-        TIOCSDRAINWAIT   =IOCTLWRITE+$47400+ 87;        { set ttywait timeout }
-        TIOCGDRAINWAIT   =IOCTLREAD+$47400+ 86; { get ttywait timeout }
-
-        TTYDISC          =0;            { termios tty line discipline }
-        SLIPDISC         =4;            { serial IP discipline }
-        PPPDISC          =5;            { PPP discipline }
-        NETGRAPHDISC     =6;            { Netgraph tty node discipline }
-
-		// OCO 31/10/2005 For compatiblity (defined to compile ShiftState function
-		// in keyboard.pp)
-		// Maybe, it should not work but it compile at least...
-		TIOCLINUX        = $541C;
-
-*)
-{
- * Defaults on "first" open.
- }
-        TTYDEF_IFLAG     =(BRKINT       or ICRNL        or IXON or IXANY);
+{ Defaults on "first" open. }
+       TTYDEF_IFLAG      =(BRKINT       or ICRNL        or IXON or IXANY);
        TTYDEF_OFLAG      =(OPOST or ONLCR);
        TTYDEF_LFLAG      =(ECHO or ICANON or ISIG or IEXTEN or ECHOE );
-        TTYDEF_CFLAG     =(CREAD or CS8 or HUPCL);
+       TTYDEF_CFLAG      =(CREAD or CS8 or HUPCL);
        TTYDEF_SPEED      =(B9600);
 
 
-
-{
- * Control Character Defaults
- }
-(*        CtrlMask        = $1f;  {\037}
-        CEOF            =chr( ORD('d') and CtrlMask);
-        CEOL            =chr( $ff and CtrlMask);{ XXX avoid _POSIX_VDISABLE }
-        CERASE          =chr( $7F and CtrlMask);
-        CINTR           =chr(ORD('c') and CtrlMask);
-        CSTATUS         =chr(ORD('t') and CtrlMask);
-        CKILL           =chr(ORD('u') and CtrlMask);
-        CMIN            =chr(1);
-        CQUIT           =chr(034  and CtrlMask);        { FS, ^\ }
-        CSUSP           =chr(ORD('z') and CtrlMask);
-        CTIME           =chr(0);
-        CDSUSP          =chr(ORD('y') and CtrlMask);
-        CSTART          =chr(ORD('q') and CtrlMask);
-        CSTOP           =chr(ORD('s') and CtrlMask);
-        CLNEXT          =chr(ORD('v') and CtrlMask);
-        CDISCARD        =chr(ORD('o') and CtrlMask);
-        CWERASE         =chr(ORD('w') and CtrlMask);
-        CREPRINT        =chr(ORD('r') and CtrlMask);
-        CEOT            =CEOF;
-{ compat }
-        CBRK            =CEOL;
-        CRPRNT          =CREPRINT;
-        CFLUSH          =CDISCARD;
-*)
-
-{
- *        TTYDEFCHARS to include an array of default control characters.
-}
+{ TTYDEFCHARS to include an array of default control characters. }
     ttydefchars : array[0..NCCS-1] OF char =(
         Chr(VINTR), Chr(VQUIT), Chr(VERASE), Chr(VKILL), Chr(VEOF), Chr(VEOL),
         Chr(VEOL2), Chr(VSWTCH), Chr(VSTART), Chr(VSTOP), Chr(VSUSP));
 
-{
-  According to posix/sys/ioctl.h
-  /* these currently work only on sockets */	
-}
+{ According to posix/sys/ioctl.h /* these currently work only on sockets */	}
 	FIONBIO  = $be000000;
 	FIONREAD = $be000001;
\ No newline at end of file
Index: termiosproc.inc
===================================================================
--- termiosproc.inc	(revision 44513)
+++ termiosproc.inc	(working copy)
@@ -3,6 +3,9 @@
    (c) 2000-2003 by Marco van de Voort
    member of the Free Pascal development team.
 
+   April 2020 Modifications by Rudolf Cornelissen
+   for Haiku. Tested with SynaSer on Haiku x64.
+
    See the file COPYING.FPC, included in this distribution,
    for details about the copyright.
 
@@ -20,18 +23,18 @@
 
 Function TCGetAttr(fd:cint;var tios:TermIOS):cint;
 begin
-  TCGETAttr:=fpIoCtl(Fd,TIOCGETA,@tios);
+  TCGETAttr:=fpIoCtl(Fd,TCGETA,@tios);
 end;
 
 
 Function TCSetAttr(fd:cint;OptAct:cint;const tios:TermIOS):cint;
 var
-  nr: TIOCtlRequest;
+  nr:cint;
 begin
   case OptAct of
-   TCSANOW   : nr:=TIOCSETA;
-   TCSADRAIN : nr:=TIOCSETAW;
-   TCSAFLUSH : nr:=TIOCSETAF;
+   TCSANOW   : nr:=TCSETA;
+   TCSADRAIN : nr:=TCSETAW;
+   TCSAFLUSH : nr:=TCSETAF;
   else
    begin
      fpsetErrNo(ESysEINVAL);
@@ -45,19 +48,48 @@
 
 Procedure CFSetISpeed(var tios:TermIOS;speed:Cardinal);
 begin
-  // field unused under BeOS
-  tios.c_ixxxxx:=speed; 
+  (* Check for custom baudrates, which must be stored in the c_ispeed
+	 field instead of inlined in the flags.
+	 Note that errors from hardware device (unsupported baudrates, etc) are
+	 detected only when the tcsetattr() function is called *)
+
+  if speed > B31250 then
+	begin
+	  tios.c_cflag := tios.c_cflag or CBAUD;
+	  tios.c_ispeed := speed;
+	  exit;
+	end;
+
+  tios.c_cflag := tios.c_cflag and not CBAUD;
+  tios.c_cflag := tios.c_cflag or speed;
 end;
 
 
+(* Function CFGetISpeed not needed here? *)
+
+
 Procedure CFSetOSpeed(var tios:TermIOS;speed:Cardinal);
 begin
-  // field unused under BeOS
-  tios.c_oxxxxx:=speed;
+  (* Check for custom baudrates, which must be stored in the c_ospeed
+	 field instead of inlined in the flags.
+	 Note that errors from hardware device (unsupported baudrates, etc) are
+	 detected only when the tcsetattr() function is called *)
+
+  if speed > B31250 then
+	begin
+	  tios.c_cflag := tios.c_cflag or CBAUD;
+	  tios.c_ospeed := speed;
+	  exit;
+	end;
+
+  tios.c_cflag := tios.c_cflag and not CBAUD;
+  tios.c_cflag := tios.c_cflag or speed;
 end;
 
 
+(* Function CFGetOSpeed not needed here? *)
 
+
 Procedure CFMakeRaw(var tios:TermIOS);
 begin
   with tios do
@@ -75,16 +107,17 @@
    end;
 end;
 
+
 Function TCSendBreak(fd,duration:cint):cint;
 begin
+  (* Posix spec says this should take ~ 0.25 to 0.5 seconds.
+     As the interpretation of the duration is undefined, we'll just ignore it *)
   TCSendBreak:=fpIOCtl(fd,TIOCSBRK,nil);
 end;
 
+
 Function be_tcsetpgrp(fd, pgrpid : pid_t) : cint; cdecl; external 'root' name 'tcsetpgrp';
 Function be_tcgetpgrp(fd : cint) : pid_t; cdecl; external 'root' name 'tcgetpgrp';
-Function be_tcdrain(fd : cint) : cint; cdecl; external 'root' name 'tcdrain';
-Function be_tcflow(fd, action : cint) : cint; cdecl; external 'root' name 'tcflow';
-Function be_tcflush(fd, queue_selector : cint) : cint; cdecl; external 'root' name 'tcflush';
 
 
 Function TCSetPGrp(fd,id:cint):cint;
@@ -98,24 +131,48 @@
   id := be_tcgetpgrp(fd);
 end;
 
+
 Function TCDrain(fd:cint):cint;
+var
+  arg:cint;
 begin
-  TCDrain := be_tcdrain(fd);
+  (* Some termios implementations have a TIOCDRAIN command
+     expressly for this purpose (e.g. ioctl(fd, TIOCDRAIN, 0).
+     However, the BeOS implementation adheres to another
+     interface which uses a non-zero last parameter to the
+     TCSBRK ioctl to signify this functionality. *)
+  arg:= 1;	 
+  TCDrain := fpIoCtl(fd,TCSBRK, @arg);
 end;
 
 
 Function TCFlow(fd,act:cint):cint;
 begin
-  TCFlow := be_tcflow(fd, act);
+  case act of
+   TCIOFF,
+   TCION,
+   TCOOFF,
+   TCOON:  ;
+  else
+   begin
+     fpsetErrNo(ESysEINVAL);
+     TCFlow:=-1;
+     exit;
+   end;
+  end;
+  TCFlow:=fpIOCtl(fd,TCXONC,@act);
 end;
 
+
 Function TCFlush(fd,qsel:cint):cint;
 begin
-  TCFlush := be_tcflush(fd, qsel);
+  TCFlush := fpIoCtl(fd,TCFLSH,@qsel);
 end;
 
+
 Function BeOSIsATTY (Handle:cint):cint; cdecl; external 'root' name 'isatty';
 
+
 Function IsATTY (Handle:cint):cint;
 {
   Check if the filehandle described by 'handle' is a TTY (Terminal)
@@ -124,6 +181,7 @@
  IsAtty:= BeOSIsATTY(Handle);
 end;
 
+
 Function IsATTY(var f: text):cint;
 {
   Idem as previous, only now for text variables.
@@ -130,5 +188,4 @@
 }
 begin
   IsATTY:=IsaTTY(textrec(f).handle);
-end;
-
+end;
\ No newline at end of file

Rudolf Cornelissen

2020-04-25 11:11

reporter   ~0122404

BTW,

There's a thread on Haiku's forums where this thing is discussed. I've created patched FPC packages concerning termios in the meantime so I can work with serial ports on Haiku. We still have a TBlockSerial.Purge problem on Haiku, but I expect this is simply a missing feature inside our kernel serial drivers..

Look aprrox here in the discussion:
https://discuss.haiku-os.org/t/lazarus-1-9-trunk-qt4-and-qt5-interface-screenshots/5767/128

Sven Barth

2020-05-01 14:11

manager   ~0122576

Just a few points I'd like to have cleared up:
- in termios.inc it's essentially only the name of a few constants that were changed (and some added)?
- the only effective changes for termiosproc.inc are the changes in CFSetISpeed and CFSetOSpeed?
- is there a reason why you changed from using imports for tcflow(), tcflush() and tcdrain() to using fpIoCtl? From what I can see the code for them in libroot looks the same, but now we'd have the problem should these implementations be changed we'd have to update termiosproc.inc again as well

Issue History

Date Modified Username Field Change
2020-04-23 16:00 Rudolf Cornelissen New Issue
2020-04-23 16:00 Rudolf Cornelissen File Added: haiku_termios_update_20200423.patch
2020-04-25 11:11 Rudolf Cornelissen Note Added: 0122404
2020-05-01 14:11 Sven Barth Assigned To => Sven Barth
2020-05-01 14:11 Sven Barth Status new => feedback
2020-05-01 14:11 Sven Barth FPCTarget => -
2020-05-01 14:11 Sven Barth Note Added: 0122576