Proper use of READ_PORT_UCHAR and WRITE_PORT_UCHAR
From: ksmith (ksmith_at_discussions.microsoft.com)
Date: 03/01/05
- Next message: Paul G. Tobey [eMVP]: "Re: SANDISK Compact FLash"
- Previous message: John Spaith [MS]: "Re: Gateway NAT use locking up OS"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 1 Mar 2005 13:21:02 -0800
Hi,
I'm writing an application that needs to read from the IR port. Initially I
used ReadFile but that proved to be too slow as this application is very time
dependent. This brought me to READ_PORT_UCHAR. I figured if I could read from
the port directly I would loose the overhead of ReadFile and my timing
problems would be resolved.
However, I have not been able to get READ_PORT_UCHAR or WRITE_PORT_UCHAR to
work. Basically I went to the registry and found the iobase of my device. In
this case it is Serial_FIR on COM2:
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Serial_FIR]
"IoBase"=dword:ae700000
"Dll"="Serial_FIR.Dll"
"Tsp"="Unimodem.dll"
"Irq"=dword:00000013
"IoLen"=dword:00000024
"DeviceArrayIndex"=dword:00000000
"Prefix"="COM"
"Order"=dword:00000002
"Index"=dword:00000002
"DeviceType"=dword:00000000
"FriendlyName"=hex(7):\ 49,6e,66,72,61,72,65,64,20,50,6f,72,74,00,00,00,00
"DevConfig"=hex:\
10,00,00,00,05,00,00,00,00,01,00,00,00,4b,00,00,00,00,08,00,00,00,00,00,00
I used the IoBase and IoLen to map the physical address to a virtual one
that I can use for in my application:
ULONG len = 36;
PHYSICAL_ADDRESS physAddr = {0xAE7, 0};
ULONG addressspace = 1;
PVOID vAddr;
TransBusAddrToVirtual(Isa, 0, physAddr, 36, &addressspace, &vAddr);
Now that I have my virtual address setup I use it by calling READ_PORT_UCHAR:
UCHAR byte = READ_PORT_UCHAR( (PUCHAR) vAddr );
But I do not receive anything. No matter what I do I always get a 0 '' for
my byte. I have also tried to WRITE_PORT_UCHAR to see if I could write
something to the port, then read it:
WRITE_PORT_UCHAR((PUCHAR)0xAE70, 'K');
UCHAR readChar = READ_PORT_UCHAR( (PUCHAR) vAddr );
And again I get 0 '' for readChar. This occurs even if I loop on the read.
What am I doing wrong?
Kyle
- Next message: Paul G. Tobey [eMVP]: "Re: SANDISK Compact FLash"
- Previous message: John Spaith [MS]: "Re: Gateway NAT use locking up OS"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|