Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to set and clear RTS in a 32-bit Delphi4 (pascal) console app

Status
Not open for further replies.

Cantor3

Programmer
Dec 2, 2011
4
0
0
US
Hello.

I am trying to write a very simple Delphi4 32-bit console application {$APPTYPE CONSOLE} which sets and clears the RTS pin of the COM1 RS232 serial port.

What is the simplest way to do this?

I tried writing asm code (see below) but not surprisingly I got a run-time exception (see below).

Does Delphi4 have built-in support for setting/clearing RTS? I could not find it.

Thank you.


---------begin code--------------
procedure SetRTS;
asm
mov dx, 03fch; {get COM1 MCR}
in al,dx;
or al, 2; {set RTS}
out dx, al;
end;

procedure ClearRTS;
asm
mov dx, 03fch;
in al,dx;
and al, 0fdh;
out dx, al;
end;
---------end code-------------


-------begin runtime error message-------------
Exception EPrivilege in module z.exe at 00008254.
Privileged instruction.[/QUOTE]
-------end runtime error message-------------


 
You can't use privileged instructions within Windows NT class operating systems in writing 32-bit windows programs. To access hardware functions, you need to go through the Win32 API. See below link which describes it for serial ports.


For future reference, the Delphi forum is here: forum102

It is not possible for anyone to acknowledge truth when their salary depends on them not doing it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top