io ports

Posted on 2003-12-08
Medium Priority
Last Modified: 2010-04-05
i gather that the rtl stuff is depreciated. however i can't find any documentation on using streams to access the io ports. in  particular the serial and parallel ports, or maybe also usb.

please point me to the right documentation and maybe also 3rd party components that allow access to io ports.

Question by:andru
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 11

Expert Comment

ID: 9902653
There is no good reason to connect streams to IO ports because usually you want to use the Win32 API functions directly.
All COM port components work that way.
USB is impossible because the USB port is nonexistent. You always talk to devices.

Accepted Solution

mgazza earned 500 total points
ID: 9906285
you cant assess the usb without a device driver the computer doesnt know how to talk to the device

but you can talk to the com or parallel port
comm is a string with ither 'COM1' ect or 'LPT1'

close the handle when your finished with it

CommFile := CreateFile(pchar(comm), GENERIC_READ or GENERIC_WRITE, 0, Nil,
                                      FILE_ATTRIBUTE_NORMAL, 0);

   if CommFile = INVALID_HANDLE_VALUE then

you can read or write to the port using readfile or writefile
look at the microsoft documentation about this
if you want to setup a braud speed ect use

if not SetupComm(CommFile, RxBufferSize, TxBufferSize) then
   showmessage('Error 1');

if not GetCommState(CommFile, DCB) then
   showmessage('Error 2');

if not BuildCommDCB(@Config[1], DCB) then
   showmessage('Error 3');

if not SetCommState(CommFile, DCB) then
   showmessage('Error 4');

with CommTimeouts do
   ReadIntervalTimeout := 0;
   ReadTotalTimeoutMultiplier := 0;
   ReadTotalTimeoutConstant := 1000;
   WriteTotalTimeoutMultiplier := 0;
   WriteTotalTimeoutConstant := 1000;

if not SetCommTimeouts(CommFile, CommTimeouts) then
showmessage('Error 5');

that will all setup your comport for reading or writting
   CommFile: THandle;
   Config : String= 'baud=19200 parity=n data=8 stop=1' +#0 ;
   CommTimeouts : TCommTimeouts;
   Data:array [0..255] of word;
   RxBufferSize = 256;
   TxBufferSize = 256;

Expert Comment

ID: 9908078
I use Async Professional for Delphi and it works great for me.
I stopped on version 3, but they went open source as far as I know...
so just have a look at source forge for more information.

Author Comment

ID: 9915133
as i guessed, but wasn't sure bout parallel port.


Expert Comment

ID: 9915412
no problem :D glad to help

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month9 days, 9 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question