Proper use of READ_PORT_UCHAR and WRITE_PORT_UCHAR

From: ksmith (ksmith_at_discussions.microsoft.com)
Date: 03/01/05


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



Relevant Pages

  • Proper use of READ_PORT_UCHAR and WRITE_PORT_UCHAR
    ... I'm writing an application that needs to read from the IR port. ... used ReadFile but that proved to be too slow as this application is very time ... PVOID vAddr; ... UCHAR readChar = READ_PORT_UCHARvAddr); ...
    (microsoft.public.windowsce.embedded)
  • Re: can not delete excutable in Pocket PC [or WinCE]
    ... For serial I/O, as we've discussed in this group previously, you can close ... WriteFile() operation under way on the port to complete with an error. ... when it gets an error back from ReadFile or WriteFile, ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Reading from parallel port via ECP and DMA
    ... Is this parport.sys the driver that comes with WinXP or it is another binary ... What makes you think that ReadFile is not implemented? ... data are read from the port. ... not work with the parallel port. ...
    (microsoft.public.development.device.drivers)
  • Re: Threads and Socket Design problem
    ... Your call to ReadFile should also request ... ReadFile will do all the hard work for you, ... Your three tests for INVALID_HANDLE_VALUE look like an attempt to exit ... when another thread closes the port. ...
    (microsoft.public.vc.mfc)
  • Re: Threads and Socket Design problem
    ... >> Here is my data notify thread, how would you say I should do it? ... Your call to ReadFile should also request ... ReadFile will do all the hard work for you, ... > when another thread closes the port. ...
    (microsoft.public.vc.mfc)