Browse Source

+ added the win16api comm support functions

git-svn-id: trunk@31823 -
nickysn 10 years ago
parent
commit
5cb89fba9e
3 changed files with 229 additions and 0 deletions
  1. 31 0
      rtl/win16/win31.pp
  2. 35 0
      rtl/win16/winprocsh.inc
  3. 163 0
      rtl/win16/wintypes.inc

+ 31 - 0
rtl/win16/win31.pp

@@ -738,6 +738,34 @@ const
   SDS_DIALOG      = $0008;
   SDS_TASKLOCKED  = $0010;
 
+{ Comm support }
+{ new escape functions }
+  GETMAXLPT     = 8;
+  GETMAXCOM     = 9;
+  GETBASEIRQ    = 10;
+
+{ Comm Baud Rate indices }
+  CBR_110       = $FF10;
+  CBR_300       = $FF11;
+  CBR_600       = $FF12;
+  CBR_1200      = $FF13;
+  CBR_2400      = $FF14;
+  CBR_4800      = $FF15;
+  CBR_9600      = $FF16;
+  CBR_14400     = $FF17;
+  CBR_19200     = $FF18;
+  CBR_38400     = $FF1B;
+  CBR_56000     = $FF1F;
+  CBR_128000    = $FF23;
+  CBR_256000    = $FF27;
+
+{ notifications passed in low word of lParam on WM_COMMNOTIFY messages }
+  CN_RECEIVE    = $0001;
+  CN_TRANSMIT   = $0002;
+  CN_EVENT      = $0004;
+
+  WM_COMMNOTIFY = $0044;
+
 function GetFreeSystemResources(SysResource: UINT): UINT; external 'USER';
 
 procedure LogError(err: UINT; lpInfo: FarPointer); external 'KERNEL';
@@ -952,6 +980,9 @@ function QuerySendMessage(h1, h2, h3: HANDLE; lpmsg: LPMSG): BOOL; external 'USE
 function LockInput(h1: HANDLE; hwndInput: HWND; fLock: BOOL): BOOL; external 'USER';
 function GetSystemDebugState: LONG; external 'USER';
 
+{ Comm support }
+function EnableCommNotification(idComDev: SmallInt; hwnd: HWND; cbWriteNotify, cbOutQueue: SmallInt): BOOL; external 'USER';
+
 implementation
 
 end.

+ 35 - 0
rtl/win16/winprocsh.inc

@@ -1262,3 +1262,38 @@ function WaitSoundState(fnState: SmallInt): SmallInt; external 'SOUND';
 
 function SyncAllVoices: SmallInt; external 'SOUND';
 function CountVoiceNotes(nvoice: SmallInt): SmallInt; external 'SOUND';
+
+{ Comm support }
+
+function BuildCommDCB(lpszDef: LPCSTR; lpdcb: LPDCB): SmallInt; external 'USER';
+{$ifdef VAR_PARAMS_ARE_FAR}
+function BuildCommDCB(lpszDef: LPCSTR; var dcb: DCB): SmallInt; external 'USER';
+{$endif}
+
+function OpenComm(lpszDevControl: LPCSTR; cbInQueue, cbOutQueue: UINT): SmallInt; external 'USER';
+function CloseComm(idComDev: SmallInt): SmallInt; external 'USER';
+
+function ReadComm(idComDev: SmallInt; lpvBuf: FarPointer; cbRead: SmallInt): SmallInt; external 'USER';
+function ReadComm(idComDev: SmallInt; lpvBuf: PFarChar; cbRead: SmallInt): SmallInt; external 'USER';
+function WriteComm(idComDev: SmallInt; lpvBuf: FarPointer; cbWrite: SmallInt): SmallInt; external 'USER';
+function WriteComm(idComDev: SmallInt; lpvBuf: PFarChar; cbWrite: SmallInt): SmallInt; external 'USER';
+function UngetCommChar(idComDev: SmallInt; chUnget: char): SmallInt; external 'USER';
+function FlushComm(idComDev, fnQueue: SmallInt): SmallInt; external 'USER';
+function TransmitCommChar(idComDev: SmallInt; chTransmit: char): SmallInt; external 'USER';
+
+function SetCommState(lpdcb: LPDCB): SmallInt; external 'USER';
+function GetCommState(idComDev: SmallInt; lpdcb: LPDCB): SmallInt; external 'USER';
+function GetCommError(idComDev: SmallInt; lpStat: LPCOMSTAT): SmallInt; external 'USER';
+{$ifdef VAR_PARAMS_ARE_FAR}
+function SetCommState(var dcb: DCB): SmallInt; external 'USER';
+function GetCommState(idComDev: SmallInt; var dcb: DCB): SmallInt; external 'USER';
+function GetCommError(idComDev: SmallInt; var Stat: COMSTAT): SmallInt; external 'USER';
+{$endif}
+
+function SetCommBreak(idComDev: SmallInt): SmallInt; external 'USER';
+function ClearCommBreak(idComDev: SmallInt): SmallInt; external 'USER';
+
+function SetCommEventMask(idComDev: SmallInt; fuEvtMask: UINT): LPUINT; external 'USER';
+function GetCommEventMask(idComDev, fnEvtClear: SmallInt): UINT; external 'USER';
+
+function EscapeCommFunction(idComDev, nFunction: SmallInt): LONG; external 'USER';

+ 163 - 0
rtl/win16/wintypes.inc

@@ -2767,3 +2767,166 @@ const
   S_SERDDR       = (-14);
   S_SERDSR       = (-15);
   S_SERDST       = (-16);
+
+{ Comm support }
+
+  NOPARITY      = 0;
+  ODDPARITY     = 1;
+  EVENPARITY    = 2;
+  MARKPARITY    = 3;
+  SPACEPARITY   = 4;
+
+  ONESTOPBIT    = 0;
+  ONE5STOPBITS  = 1;
+  TWOSTOPBITS   = 2;
+
+  IGNORE        = 0;
+  INFINITE      = $FFFF;
+
+{ Error Flags }
+  CE_RXOVER     = $0001;
+  CE_OVERRUN    = $0002;
+  CE_RXPARITY   = $0004;
+  CE_FRAME      = $0008;
+  CE_BREAK      = $0010;
+  CE_CTSTO      = $0020;
+  CE_DSRTO      = $0040;
+  CE_RLSDTO     = $0080;
+  CE_TXFULL     = $0100;
+  CE_PTO        = $0200;
+  CE_IOE        = $0400;
+  CE_DNS        = $0800;
+  CE_OOP        = $1000;
+  CE_MODE       = $8000;
+
+  IE_BADID      = (-1);
+  IE_OPEN       = (-2);
+  IE_NOPEN      = (-3);
+  IE_MEMORY     = (-4);
+  IE_DEFAULT    = (-5);
+  IE_HARDWARE   = (-10);
+  IE_BYTESIZE   = (-11);
+  IE_BAUDRATE   = (-12);
+
+{ Events }
+  EV_RXCHAR     = $0001;
+  EV_RXFLAG     = $0002;
+  EV_TXEMPTY    = $0004;
+  EV_CTS        = $0008;
+  EV_DSR        = $0010;
+  EV_RLSD       = $0020;
+  EV_BREAK      = $0040;
+  EV_ERR        = $0080;
+  EV_RING       = $0100;
+  EV_PERR       = $0200;
+  EV_CTSS       = $0400;
+  EV_DSRS       = $0800;
+  EV_RLSDS      = $1000;
+  EV_RingTe     = $2000;
+//  EV_RINGTE     = EV_RingTe;
+
+{ Escape Functions }
+  SETXOFF       = 1;
+  SETXON        = 2;
+  SETRTS        = 3;
+  CLRRTS        = 4;
+  SETDTR        = 5;
+  CLRDTR        = 6;
+  RESETDEV      = 7;
+
+  LPTx          = $80;
+
+type
+  PDCB = ^DCB;
+  LPDCB = ^DCB; far;
+  DCB = record
+    Id: BYTE;
+    BaudRate: UINT;
+    ByteSize: BYTE;
+    Parity: BYTE;
+    StopBits: BYTE;
+    RlsTimeout: UINT;
+    CtsTimeout: UINT;
+    DsrTimeout: UINT;
+
+    Flags: Word;
+{    UINT fBinary        :1;
+    UINT fRtsDisable    :1;
+    UINT fParity        :1;
+    UINT fOutxCtsFlow   :1;
+    UINT fOutxDsrFlow   :1;
+    UINT fDummy         :2;
+    UINT fDtrDisable    :1;
+
+    UINT fOutX          :1;
+    UINT fInX           :1;
+    UINT fPeChar        :1;
+    UINT fNull          :1;
+    UINT fChEvt         :1;
+    UINT fDtrflow       :1;
+    UINT fRtsflow       :1;
+    UINT fDummy2        :1;}
+
+    XonChar: char;
+    XoffChar: char;
+    XonLim: UINT;
+    XoffLim: UINT;
+    PeChar: char;
+    EofChar: char;
+    EvtChar: char;
+    TxDelay: UINT;
+  end;
+  TDCB = DCB;
+
+const
+  DCB_Binary      = $0001;
+  DCB_RtsDisable  = $0002;
+  DCB_Parity      = $0004;
+  DCB_OutxCtsFlow = $0008;
+  DCB_OutxDsrFlow = $0010;
+  DCB_Dummy       = $0060;
+  DCB_DtrDisable  = $0080;
+
+  DCB_OutX        = $0100;
+  DCB_InX         = $0200;
+  DCB_PeChar      = $0400;
+  DCB_Null        = $0800;
+  DCB_ChEvt       = $1000;
+  DCB_Dtrflow     = $2000;
+  DCB_Rtsflow     = $4000;
+  DCB_Dummy2      = $8000;
+
+type
+  PCOMSTAT = ^COMSTAT;
+  LPCOMSTAT = ^COMSTAT; far;
+  COMSTAT = record
+    case Integer of
+      0: (
+           status: BYTE;
+           cbInQue: UINT;
+           cbOutQue: UINT;
+         );
+      1: (
+           { BP7 compatible field name, overlaid on top of 'status' }
+           Flags: Byte
+         );
+  end;
+  TComStat = COMSTAT;
+
+const
+  CSTF_CTSHOLD  = $01;
+  CSTF_DSRHOLD  = $02;
+  CSTF_RLSDHOLD = $04;
+  CSTF_XOFFHOLD = $08;
+  CSTF_XOFFSENT = $10;
+  CSTF_EOF      = $20;
+  CSTF_TXIM     = $40;
+
+  { BP7 compatibility constants }
+  COM_CtsHold   = $01;
+  COM_DsrHold   = $02;
+  COM_RlsdHold  = $04;
+  COM_XoffHold  = $08;
+  COM_XoffSent  = $10;
+  COM_Eof       = $20;
+  COM_Txim      = $40;