Reading from a communication port

Hai All,

I have written a driver which is loaded as other devices.
Can I read com1 port from this driver with the code shown below
ULONG portAddr = 0x03f8;
READ_PORT_UCHAR(&portAddr);

Is this correct?
My question is can we read from physical port even from any driver.

Any information is helpful,
Thanx in advance.
Kedar.

No, unless you want to introduce major problems. Each driver can write
to its own device only.

Max

----- Original Message -----
From: “kedar”
To: “NT Developers Interest List”
Sent: Wednesday, September 25, 2002 4:44 PM
Subject: [ntdev] Reading from a communication port

> Hai All,
>
> I have written a driver which is loaded as other devices.
> Can I read com1 port from this driver with the code shown below
> ULONG portAddr = 0x03f8;
> READ_PORT_UCHAR(&portAddr);
>
> Is this correct?
> My question is can we read from physical port even from any driver.
>
> Any information is helpful,
> Thanx in advance.
> Kedar.
>
> —
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to %%email.unsub%%
>

Why can’t you just open the com port through the standard serial driver and
access it that way?

Chris

“kedar” wrote in message news:xxxxx@ntdev…
>
> Hai All,
>
> I have written a driver which is loaded as other devices.
> Can I read com1 port from this driver with the code shown below
> ULONG portAddr = 0x03f8;
> READ_PORT_UCHAR(&portAddr);
>
> Is this correct?
> My question is can we read from physical port even from any driver.
>
> Any information is helpful,
> Thanx in advance.
> Kedar.
>
>

Yes. port number is physical, not virtual. But…

port 3f8 and 3fc are the ports to generate PCI configration cycle. Why do
you want to access this port directly? Use HalXXX instead.

Bi

-----Original Message-----
From: kedar [mailto:xxxxx@hotmail.com]
Sent: Wednesday, September 25, 2002 5:45 AM
To: NT Developers Interest List
Subject: [ntdev] Reading from a communication port

Hai All,

I have written a driver which is loaded as other devices.
Can I read com1 port from this driver with the code shown below
ULONG portAddr = 0x03f8;
READ_PORT_UCHAR(&portAddr);

Is this correct?
My question is can we read from physical port even from any driver.

Any information is helpful,
Thanx in advance.
Kedar.


You are currently subscribed to ntdev as: xxxxx@appstream.com
To unsubscribe send a blank email to %%email.unsub%%

Sorry. My memory is not as good as I thought it to be. Those ports are not
fro PCI configration cycle. I don’t have the spec. with me.

However, as Chris pointed out, you should open the driver "
\DosDevices\COM1 <file:> " to do serial port
communication. Since serial port like almost all the hardware is a state
machine and its driver is handle that state machine. If you read/write
something to the port, it generates an interrupt and serial port driver does
not expect this read/write and you may get a blue screen or something nasty.

Bi

-----Original Message-----
From: Bi Chen [mailto:xxxxx@AppStream.com]
Sent: Wednesday, September 25, 2002 10:23 AM
To: NT Developers Interest List
Subject: [ntdev] RE: Reading from a communication port

Yes. port number is physical, not virtual. But…

port 3f8 and 3fc are the ports to generate PCI configration cycle. Why do
you want to access this port directly? Use HalXXX instead.

Bi

-----Original Message-----
From: kedar [mailto:xxxxx@hotmail.com mailto:xxxxx]
Sent: Wednesday, September 25, 2002 5:45 AM
To: NT Developers Interest List
Subject: [ntdev] Reading from a communication port

Hai All,

I have written a driver which is loaded as other devices.
Can I read com1 port from this driver with the code shown below
ULONG portAddr = 0x03f8;
READ_PORT_UCHAR(&portAddr);

Is this correct?
My question is can we read from physical port even from any driver.

Any information is helpful,
Thanx in advance.
Kedar.


You are currently subscribed to ntdev as: xxxxx@appstream.com
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntdev as: xxxxx@appstream.com
To unsubscribe send a blank email to %%email.unsub%%</mailto:xxxxx></file:>

Hi,

Sure, you can. It works fine without any probs. I would recommend the driver
to be a non-PnP model.

A word of caution. If you are working on a new H/W (the ones with PnP H/W &&
the OS being 2K and above), then while opening the port(obtaining a handle,
that gets passed to ur driver)in ur application, use " \\.\COM1 ",
rather than the conventional “COM1”(as said in msdn), in the CreateFile()
api. It is because when the H/W is PnP, using the syntax \\.\ also “wakes
up” the device.

I request others to correct me if am wrong. This is because, when i wrote a
smiliar driver(which reads all the registers of a COM), i opened the port
like CreateFile(“COM1”,…), which worked fine on NT and 2K with the H/W
that does not support PnP, but not on 2K with a H/W supporting PnP(older
model machines). Spent annoying 3 months time to find out why the same
driver and code worked fine on NT and 2K in old machines, but not on 2K on
New machines.

Expecting your comments.

regards,

Venkat Raghavulu A.R
Zensar Technologies. Ltd,
Nagar Road,
Pune - 411 014. India.
Ph: 020-6632102/3/4-extn 513


The most wasted day of all is one in which you have not Laughed.

Subject: Reading from a communication port

From: “kedar”

Date: Wed, 25 Sep 2002 08:44:47 -0400

X-Message-Number: 10

Hai All,

I have written a driver which is loaded as other devices.

Can I read com1 port from this driver with the code shown below

ULONG portAddr = 0x03f8;

READ_PORT_UCHAR(&portAddr);

Is this correct?

My question is can we read from physical port even from any driver.

Any information is helpful,

Thanx in advance.

Kedar.



ZenSar Technologies Ltd. Mail Disclaimer: This e-mail and any files
transmitted with it are confidential and the views expressed in the same are
not necessarily the views of ZenSar Technologies Ltd., and its directors,
management or employees. This communication represents the originator’s
personal views and opinions. If you are not the intended recipient or the
person responsible for delivering the e-mail to the intended recipient, be
advised that you have received this e-mail by error, and that any use,
dissemination, forwarding, printing, or copying of this e-mail is strictly
prohibited. You shall be under obligation to keep the contents of this
e-mail, strictly confidential and shall not disclose, disseminate or divulge
the same to any Person, Company, Firm or Entity. Please ensure you have
adequate virus protection before you open or detach any documents from this
transmission. ZenSar Technologies Ltd. does not accept any liability for
viruses. If you received this e-mail in error, please immediately notify
xxxxx@zensar.com. The rights to monitor all e-mail communication
through our network are reserved with us.