Hello,

For something that appears relatively simple I'm having a hell of a time
getting it to work. Basically I'm trying to read in from COM2 (Native IR)
using READ_PORT_UCHAR but so far I've never been able to get any data.

I am attempting to use TransBusAddrToVirtual to map the physical address to
a virtual one; then I use that address with READ_PORT_UCHAR to read the data.
Here's how I am going about this:


** CODE **

PVOID vAddr;
ULONG addressspace = TRUE;
PHYSICAL_ADDRESS temp = {0xAE7, 0}; // See IoBase in Reg below
if(!TransBusAddrToVirtual(Isa, 0, temp, 1, &addressspace, &vAddr))
return NULL;

if (waitRtn = WaitCommEvent(m_hIRPort, &commEvent, NULL))
{
while (bufNdx < 1000)
{
buffer2[bufNdx] = READ_PORT_UCHAR((PUCHAR)vAddr);
QueryPerformanceCounter(&time);
times[bufNdx] = time;
bufNdx++;
}
}


** REG **

[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


Now, I've run the above code using ReadFile and a handle to COM2: created by
CreateFile. This works but it is too slow for my needs. This is why I went
about the READ_PORT_UCHAR method and it is much faster but I haven't been
able to get any data.

I have a few questions for you guys:

1) Is IoBase the physical address of com2? I've tried the above code using
0x2F8, 0x3E8 and 0xAE7 but none of them work.

2) Is IoLen the Length parameter in TransBusAddrToVirtual? Right now I have
Length = 1 since I am only interested in reading in the data a byte at a time.


Any insights as to why this isn't working would be helpful.



Thanks in advance,

Kyle




** Function **

BOOL TransBusAddrToVirtual(
INTERFACE_TYPE InterfaceType,
ULONG BusNumber,
PHYSICAL_ADDRESS BusAddress,
ULONG Length,
PULONG AddressSpace,
PPVOID MappedAddress
);

Re: READ_PORT_UCHAR and COM2 by Wally

Wally
Tue Mar 01 01:44:43 CST 2005


Do you already have a COM2 driver?
If so could it be reading the data (on interrupt) before you read it.

"ksmith" <ksmith@discussions.microsoft.com> wrote in message
news:9B3BB788-AB7A-49F6-A4E9-820C31115DEA@microsoft.com...
> Hello,
>
> For something that appears relatively simple I'm having a hell of a time
> getting it to work. Basically I'm trying to read in from COM2 (Native IR)
> using READ_PORT_UCHAR but so far I've never been able to get any data.
>
> I am attempting to use TransBusAddrToVirtual to map the physical address
> to
> a virtual one; then I use that address with READ_PORT_UCHAR to read the
> data.
> Here's how I am going about this:
>
>
> ** CODE **
>
> PVOID vAddr;
> ULONG addressspace = TRUE;
> PHYSICAL_ADDRESS temp = {0xAE7, 0}; // See IoBase in Reg below
> if(!TransBusAddrToVirtual(Isa, 0, temp, 1, &addressspace, &vAddr))
> return NULL;
>
> if (waitRtn = WaitCommEvent(m_hIRPort, &commEvent, NULL))
> {
> while (bufNdx < 1000)
> {
> buffer2[bufNdx] = READ_PORT_UCHAR((PUCHAR)vAddr);
> QueryPerformanceCounter(&time);
> times[bufNdx] = time;
> bufNdx++;
> }
> }
>
>
> ** REG **
>
> [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
>
>
> Now, I've run the above code using ReadFile and a handle to COM2: created
> by
> CreateFile. This works but it is too slow for my needs. This is why I went
> about the READ_PORT_UCHAR method and it is much faster but I haven't been
> able to get any data.
>
> I have a few questions for you guys:
>
> 1) Is IoBase the physical address of com2? I've tried the above code using
> 0x2F8, 0x3E8 and 0xAE7 but none of them work.
>
> 2) Is IoLen the Length parameter in TransBusAddrToVirtual? Right now I
> have
> Length = 1 since I am only interested in reading in the data a byte at a
> time.
>
>
> Any insights as to why this isn't working would be helpful.
>
>
>
> Thanks in advance,
>
> Kyle
>
>
>
>
> ** Function **
>
> BOOL TransBusAddrToVirtual(
> INTERFACE_TYPE InterfaceType,
> ULONG BusNumber,
> PHYSICAL_ADDRESS BusAddress,
> ULONG Length,
> PULONG AddressSpace,
> PPVOID MappedAddress
> );
>



Re: READ_PORT_UCHAR and COM2 by ksmith

ksmith
Tue Mar 01 11:45:03 CST 2005

Wally,

I don't believe there is anything sitting on com2, at least not according to
the registry. I am using a standard iPAQ hx47000 so maybe it has a driver I
don't know about. The only references I see are in
HKEY_LOCAL_MACHINE\Comm\Irsir1\Parms\Port = 2 and
Drivers\BuiltIn\Serial_FIR\Prefix = COM & Index = 2.

Serial, Serial_BTUR, Serial_External and Serial_FIR all share IRQ 19.

Do you know if my code looks sound? I'm not sure I'm using iobase and iolen
correctly.

Kyle

"Wally" wrote:

>
> Do you already have a COM2 driver?
> If so could it be reading the data (on interrupt) before you read it.
>


Re: READ_PORT_UCHAR and COM2 by Steve

Steve
Wed Mar 02 16:32:52 CST 2005

Um, hang on. What are you calling COM2: that is a device name that
technically only has meaning on a specific device. On a PC it has a bit more
specific meaning in most cases but on other devices it's wide open.

Where does the m_hIRPort handle come from? are you certain there really is
hardware at the physical address you specified? Keep in mind that
PHYSICAL_ADDRESS is a 64 bit value so the address you are using is really:
0x0000000000000AE7

--
Steve Maillet
EmbeddedFusion
www.EmbeddedFusion.com
smaillet at EmbeddedFusion dot com



Re: READ_PORT_UCHAR and COM2 by ksmith

ksmith
Wed Mar 02 20:35:02 CST 2005

Just to make things clearer â?? I am working with an iPAQ hx4705. COM2 is what
I pull from the registry as port number from
[HKEY_LOCAL_MACHINE\Comm\Irsir1\Parms].

The m_hIRPort handle is created using:
str.append(_T("COM2:"));
m_hIRPort = CreateFile(str.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, 0, NULL);

I can read and write using this handle just fine but the speed at which I
read from it is too slow for my needs. This is why I am trying the
READ_PORT_UCHAR route. Please note that all this code is in my program and
not a driver.

As for the hardware address, that I am not sure about. Since Intelâ??s PXA27x
Developers Manual link is dead I canâ??t get the PDF of the registers and
addresses so I am playing around with the values in the registry.

The actual registry value is iobase = 0xAE700000 so I guess the physical
address is 0x00000000AE700000 and Iâ??ve tried creating it using both

PHYSICAL_ADDRESS temp = {0xAE7, 0}
And
PHYSICAL_ADDRESS temp = {0xAE700000, 0}

But neither of these work. The latter locks up the device when I call
READ_PORT_UCHAR.

Going back to what Wally said about the current COM2 driver getting to the
data before my READ_PORT_UCHAR call, would temporarily disabling the COM2
interrupt be a viable work around?

Kyle


"Steve Maillet (eMVP)" wrote:

> Um, hang on. What are you calling COM2: that is a device name that
> technically only has meaning on a specific device. On a PC it has a bit more
> specific meaning in most cases but on other devices it's wide open.
>
> Where does the m_hIRPort handle come from? are you certain there really is
> hardware at the physical address you specified? Keep in mind that
> PHYSICAL_ADDRESS is a 64 bit value so the address you are using is really:
> 0x0000000000000AE7
>
> --
> Steve Maillet
> EmbeddedFusion
> www.EmbeddedFusion.com
> smaillet at EmbeddedFusion dot com
>
>
>

Re: READ_PORT_UCHAR and COM2 by Steve

Steve
Thu Mar 03 00:14:35 CST 2005

disabling the interrupt might do the trick though this is all a bit of a
nasty hack. What exactly is it you are trying to do? (Big picture?)

--
Steve Maillet
EmbeddedFusion
www.EmbeddedFusion.com
smaillet at EmbeddedFusion dot com