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

Re: Proper use of READ_PORT_UCHAR and WRITE_PORT_UCHAR by Bruce

Bruce
Tue Mar 01 17:09:02 CST 2005

What makes you think that register is both read and write? Do you know
anything about the hardware that you are using? Something tells me that the
address that you read from the registry is actually a virtual address, but
knowing nothing about your hardware, I don't know.

This certainly does not write and read to the same address. Which is
actually good, since the read and write buffer addresses are usually
different.
> WRITE_PORT_UCHAR((PUCHAR)0xAE70, 'K');
> UCHAR readChar = READ_PORT_UCHAR( (PUCHAR) vAddr );

Is the driver that you were using still loaded? If so, you probably will
never read data.

How were you reading data when you were using the driver? You may be able
to fix that code easier than re-writing the code to control the hardware.

--
Bruce Eitman (eMVP)
Senior Engineer
beitman AT applieddata DOT net

Applied Data Systems
www.applieddata.net
An ISO 9001:2000 Registered Company
Microsoft WEP Gold-level Member


"ksmith" <ksmith@discussions.microsoft.com> wrote in message
news:657855B6-3D8F-4F47-9CEC-665DD4DD2A7F@microsoft.com...
> 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



Re: Proper use of READ_PORT_UCHAR and WRITE_PORT_UCHAR by news

news
Wed Mar 02 01:23:06 CST 2005

What is your CPU type?
I think you may try virtualalloc and virtualcopy instead of
TransBusAddrToVirtual.
Good luck.

Lee
"ksmith" <ksmith@discussions.microsoft.com> wrote in message
news:657855B6-3D8F-4F47-9CEC-665DD4DD2A7F@microsoft.com...
> 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



Re: Proper use of READ_PORT_UCHAR and WRITE_PORT_UCHAR by ksmith

ksmith
Wed Mar 02 19:47:04 CST 2005

Bruce,

As you can tell I am in the dark here. Hopefully you can shed some light on
my approach and maybe give me a new path to pursue. That being said let me
tell you about my problem and why I am doing things this way.

I need to write â??somethingâ?? that will allow me to read in IR data as
accurately as possible. That something may be a driver or just some lower
level code thrown into my application. I want this to run on as many
handhelds as possible so Iâ??m looking for a solution that gives me the precise
timing Iâ??m looking for implemented as easily as possible.

Originally I was creating a handle to COM2 and using ReadFile() to get the
bytes as they were read. However, since this wasnâ??t fast enough Iâ??ve been
looking for a way to read in the data as fast as possible. I have tried
CeSetThreadPriority(hIRThread, 0) but that wasnâ??t good enough either.

This brings me to where I am now and my attempt to use READ_PORT_UCHAR
rather than ReadFile(). Currently I am trying to implement this directly in
my application and not a driver. I donâ??t know if this is the correct way to
go about it so please correct me here.

As for my knowledge of the hardware, that too is weak. I am using an HP
HX4705 which runs on an Intel PXA270 processor. T