954,529 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Set RTS with Delphi4 console app

Hello.

I am trying to write a very simple Delphi4 32-bit console app which toggles 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:

Exception EPrivilege in module z.exe at 00008254. Privileged instruction.

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

Thank you.

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;
Pirsig
Newbie Poster
2 posts since Dec 2011
Reputation Points: 10
Solved Threads: 0
 
pritaeas
Posting Expert
Moderator
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 874
 
This may help: http://mc-computing.com/languages/delphi/delphi_serialio.htm

Thanks for the reference. There was no mention in there how to access the modem control register to toggle RTS... but there were quite a few external links; I haven't yet looked at them all but I will.

Pirsig
Newbie Poster
2 posts since Dec 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You