Newsgroups : Borland : borland.public.delphi.internet.winsock : 2005 Nov : Com Port Reading via TCP/IP
| Subject: | Com Port Reading via TCP/IP |
| Posted by: | "Allan Fernandes" (te..@ssmiths.com) |
| Date: | Thu, 3 Nov 2005 11:47:34 +0530 |
Hi,
Is it possible to access the serial ports 'COM1' or 'COM2' using
TServerSocket/TClientSocket
or any other component in Delphi.
Currently I am using the following logic, which is rather slow.
...
ComFile := CreateFile(DeviceName, GENERIC_READ or GENERIC_WRITE, 0, Nil,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
.....
if not SetupComm(ComFile, RxBufferSize, TxBufferSize) then
....
if not GetCommState(ComFile, DCB) then
....
Config := 'baud='+pBaudRate+' parity='+pParity+' data='+pDataBits+'
stop='+pStopBits ;
...
if not BuildCommDCB(@Config[1], DCB) then
...
if not SetCommState(ComFile, DCB) then
....
ReadFile ( ComFile, d, sizeof(d), BytesRead, Nil)
.....