Re: DTR _outp( 0x3F8 + 4, 1 )
From: Kurtis Martin (kurtis_at_ncat.edu)
Date: 10/12/03
- Next message: Richard Heathfield: "Re: Clipboard manager"
- Previous message: Willem: "Re: Blackjack program, help needed C"
- In reply to: kdog: "DTR _outp( 0x3F8 + 4, 1 )"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 12 Oct 2003 19:59:00 GMT
Got an answer. I don't have to use anything special to gain direct access
to the port, so giveio is not needed. I must use the correct functions.
Here is how to turn DTR line on for 10 seconds:
#include "stdafx.h"
#include <stdio.h>
#include <conio.h>
#include <windows.h>
int main( int argc, char **argv )
{
HANDLE h;
h = CreateFile("\\\\.\\COM1",GENERIC_WRITE,0,NULL,OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,NULL);
EscapeCommFunction(h,SETDTR);
//_outp(0x02F8 + 4,1); Replaced by EscapeCommFunction.
Sleep(10000); // allow DTR to be set for 10 seconds.
CloseHandle(h);
return 0;
}
"kdog" <kurtis@ncat.edu> wrote in message
news:0yIhb.44493$5r1.5636@twister.southeast.rr.com...
> Environment:
> - WinXP
> - VisualC++ .net
> - 2 wires hooked up to serial port between DTR and ground
> - giveio
>
> Problem:
>
> Trying to write a C/C++ program to change the state of the DTR line on
> COM 1. I thought the only thing I had to do was:
>
> _outp( 0x3F8 + 4, 1)
>
> I've already got pass the user mode permission exception using giveio.sys.
> I'm certain my application can directly access the ports, because I'm able
> to run the sample that came with giveio which writes to low-level memory
> addresses to play a song on the computers internal speaker. I'm trying to
> toggle
> the voltage between DTR and ground from +12V to -12V. I thought this is
> done by _outp( 0x3F8 + 4, 1) and _outp( 0x3F8 + 4, 0 ). That simple.
> Unfortunately, it doesn't work. The voltage stays at +12V.
> Of course If checked to make sure 3F8 is the address of COM1. Do I have
to
> initialize the port? What am I missing?
>
>
>
- Next message: Richard Heathfield: "Re: Clipboard manager"
- Previous message: Willem: "Re: Blackjack program, help needed C"
- In reply to: kdog: "DTR _outp( 0x3F8 + 4, 1 )"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|