> I am planning to improve, if possible, the serial units for both Linux > and Windows, but have a few questions before I proceed any further: > > 1- I guess the unit rtl\win\wininc\struct.inc has 2 bugs: > a- bm_DCB_fRtsControl = $3000. It should be $2000. > b- bm_DCB_fDtrControl = $30. It should be $20. > Can anybody confirm this?
No, they are correct. If you look into the headers you'll see: DWORD DCBlength; /* sizeof(DCB) */ DWORD BaudRate; /* Baudrate at which running */ DWORD fBinary: 1; /* Binary Mode (skip EOF check) */ DWORD fParity: 1; /* Enable parity checking */ DWORD fOutxCtsFlow:1; /* CTS handshaking on output */ DWORD fOutxDsrFlow:1; /* DSR handshaking on output */ DWORD fDtrControl:2; /* DTR Flow control */ DWORD fDsrSensitivity:1; /* DSR Sensitivity */ DWORD fTXContinueOnXoff: 1; /* Continue TX when Xoff sent */ DWORD fOutX: 1; /* Enable output X-ON/X-OFF */ DWORD fInX: 1; /* Enable input X-ON/X-OFF */ DWORD fErrorChar: 1; /* Enable Err Replacement */ DWORD fNull: 1; /* Enable Null stripping */ DWORD fRtsControl:2; /* Rts Flow control */ DWORD fAbortOnError:1; /* Abort all reads and writes on Error */ DWORD fDummy2:17; /* Reserved */ WORD wReserved; /* Not currently used */ WORD XonLim; /* Transmit X-ON threshold */ WORD XoffLim; /* Transmit X-OFF threshold */ BYTE ByteSize; /* Number of bits/byte, 4-8 */ BYTE Parity; /* 0-4=None,Odd,Even,Mark,Space */ BYTE StopBits; /* 0,1,2 = 1, 1.5, 2 */ char XonChar; /* Tx and Rx X-ON character */ char XoffChar; /* Tx and Rx X-OFF character */ char ErrorChar; /* Error replacement char */ char EofChar; /* End of Input character */ char EvtChar; /* Received Event character */ WORD wReserved1; /* Fill for now. */ } DCB, *LPDCB; Note the :2 with frts and fdtr. These are two bit values, not one bit, so a mask that masks 2 bits makes sense > 2- I will define TSerialFlags = set of (XOnXOffFlowControl, > RtsCtsFlowControl); > What flags do we have to set in Linux to have XOnXOff handshaking? The > number of parameters in tios is mind boggling. Well the existance of flags are named "IXON", "IXOFF" and "IXANY" might provide a clue when googled. > 3- The Linux SerOpen function (based on fpopen) claims to return 0 if > the device could not be found. Shouldn't it be -1? Probably. In 1.0.x times FPC unix functions had own error conventions. > 4- Windows SerOpen function (based on CreateFile) returns an > INVALID_HANDLE_VALUE if the device could not be found. How to unify for > both Linux & Windows? Is it safe to return instead -1 (as in the Linux > case)? See Tomas, it is define > > 5- Is it OK to designate serial ports by COMx fow Windows and /dev/ttySx > for Linux? No, since e.g a serial port on some other device might have a different state. And strictly, this is even possible for Windows. Always keep naming configurable and overridable. Those series are extremely common, but not that Also note that serial.pp is a general unix unit, not just linux. So it needs to work on FreeBSD too. (and maybe Mac, but I have no serial on my mac anymore) I've acquired a serial device suitable for testing with FreeBSD if needed. > 6- Is it OK for TSerialState to include DCB for Windows and tios for Linux? I don't understand what you mean with this. _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal