Solved

io ports

Posted on 2003-12-08
5
873 Views
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.

tia
0
Comment
Question by:andru
[X]
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
5 Comments
 
LVL 11

Expert Comment

by:robert_marquardt
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.
0
 
LVL 1

Accepted Solution

by:
mgazza earned 125 total points
ID: 9906285
hi,
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,
                                      OPEN_EXISTING,
                                      FILE_ATTRIBUTE_NORMAL, 0);

   if CommFile = INVALID_HANDLE_VALUE then
     application.Terminate;

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
begin
   ReadIntervalTimeout := 0;
   ReadTotalTimeoutMultiplier := 0;
   ReadTotalTimeoutConstant := 1000;
   WriteTotalTimeoutMultiplier := 0;
   WriteTotalTimeoutConstant := 1000;
end;

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

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

Expert Comment

by:delphized
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.
0
 

Author Comment

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

thanks
0
 
LVL 1

Expert Comment

by:mgazza
ID: 9915412
no problem :D glad to help
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

726 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