471,601 Members | 1,210 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,601 software developers and data experts.

Determine the available Serial Port on a system

Hello,

Is there a way, in .NET, to determine what are the avialable Serial
(Communications) Ports on a Windows OS and is there a way to determine
that port isn't being use other than attempting to opening the Serial
Port and catching the associated exception? Thanks

If there isn't a way to determine the Serial Port within .NET I would
be willing, I guess, to use a WinAPI is that was the only way.

Mark
Nov 16 '06 #1
5 9299
The System.IO.Ports namespace contains classes for controlling serial
ports. The most important class, SerialPort, provides a framework for
synchronous and event-driven I/O, access to pin and break states, and
access to serial driver properties. It can be used to wrap a Stream
objects, allowing the serial port to be accessed by classes that use
streams.

http://msdn2.microsoft.com/en-us/lib...erialport.aspx

Hope that covers your requirements.

Have a great one.

Austin

On Nov 16, 2:10 am, LongBow <p...@mud.poolwrote:
Hello,

Is there a way, in .NET, to determine what are the avialable Serial
(Communications) Ports on a Windows OS and is there a way to determine
that port isn't being use other than attempting to opening the Serial
Port and catching the associated exception? Thanks

If there isn't a way to determine the Serial Port within .NET I would
be willing, I guess, to use a WinAPI is that was the only way.

Mark
Nov 16 '06 #2
Besides noted there, I'd add that u can use WMI class "Win32_SerialPort" and
check the Availability property
See MSDN for more details

--
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche


"LongBow" wrote:
Hello,

Is there a way, in .NET, to determine what are the avialable Serial
(Communications) Ports on a Windows OS and is there a way to determine
that port isn't being use other than attempting to opening the Serial
Port and catching the associated exception? Thanks

If there isn't a way to determine the Serial Port within .NET I would
be willing, I guess, to use a WinAPI is that was the only way.

Mark
Nov 16 '06 #3

Your_Persona wrote:
The System.IO.Ports namespace contains classes for controlling serial
ports. The most important class, SerialPort, provides a framework for
synchronous and event-driven I/O, access to pin and break states, and
access to serial driver properties. It can be used to wrap a Stream
objects, allowing the serial port to be accessed by classes that use
streams.

http://msdn2.microsoft.com/en-us/lib...erialport.aspx

Hope that covers your requirements.

Have a great one.

Austin

On Nov 16, 2:10 am, LongBow <p...@mud.poolwrote:
Hello,

Is there a way, in .NET, to determine what are the avialable Serial
(Communications) Ports on a Windows OS and is there a way to determine
that port isn't being use other than attempting to opening the Serial
Port and catching the associated exception? Thanks

If there isn't a way to determine the Serial Port within .NET I would
be willing, I guess, to use a WinAPI is that was the only way.

Mark

Austin,

Thanks for the info and I am currently using the System.IO.Ports
class for the serial communications, but what I want is a way to
determine the available ports that are present on the current system.

The Serial Port namespace is pretty nice, though I don't like how the
data is buffered, and props goes to the intern at Microsoft that
initially created the class.

I will give the WMI a go as Michael indicated in his post. So from my
current understanding this is no native .NET way of determining the
enumerated list of available ports on a system. Hopefully Microsoft
might add that feature in the future.

Mark

Nov 16 '06 #4
JR
SerialPort.GetPortNames ();

JR

<Lo*****@hotmail.comwrote in message
news:11**********************@e3g2000cwe.googlegro ups.com...
>
Your_Persona wrote:
>The System.IO.Ports namespace contains classes for controlling serial
ports. The most important class, SerialPort, provides a framework for
synchronous and event-driven I/O, access to pin and break states, and
access to serial driver properties. It can be used to wrap a Stream
objects, allowing the serial port to be accessed by classes that use
streams.

http://msdn2.microsoft.com/en-us/lib...erialport.aspx

Hope that covers your requirements.

Have a great one.

Austin

On Nov 16, 2:10 am, LongBow <p...@mud.poolwrote:
Hello,

Is there a way, in .NET, to determine what are the avialable Serial
(Communications) Ports on a Windows OS and is there a way to determine
that port isn't being use other than attempting to opening the Serial
Port and catching the associated exception? Thanks

If there isn't a way to determine the Serial Port within .NET I would
be willing, I guess, to use a WinAPI is that was the only way.

Mark


Austin,

Thanks for the info and I am currently using the System.IO.Ports
class for the serial communications, but what I want is a way to
determine the available ports that are present on the current system.

The Serial Port namespace is pretty nice, though I don't like how the
data is buffered, and props goes to the intern at Microsoft that
initially created the class.

I will give the WMI a go as Michael indicated in his post. So from my
current understanding this is no native .NET way of determining the
enumerated list of available ports on a system. Hopefully Microsoft
might add that feature in the future.

Mark

Nov 16 '06 #5
JR,

Thanks A LOT! I didn't even see the static GetPortNames() from the
Serial Class. Thanks!!!!

Mark

JR wrote:
SerialPort.GetPortNames ();

JR

<Lo*****@hotmail.comwrote in message
news:11**********************@e3g2000cwe.googlegro ups.com...

Your_Persona wrote:
The System.IO.Ports namespace contains classes for controlling serial
ports. The most important class, SerialPort, provides a framework for
synchronous and event-driven I/O, access to pin and break states, and
access to serial driver properties. It can be used to wrap a Stream
objects, allowing the serial port to be accessed by classes that use
streams.

http://msdn2.microsoft.com/en-us/lib...erialport.aspx

Hope that covers your requirements.

Have a great one.

Austin

On Nov 16, 2:10 am, LongBow <p...@mud.poolwrote:
Hello,

Is there a way, in .NET, to determine what are the avialable Serial
(Communications) Ports on a Windows OS and is there a way to determine
that port isn't being use other than attempting to opening the Serial
Port and catching the associated exception? Thanks

If there isn't a way to determine the Serial Port within .NET I would
be willing, I guess, to use a WinAPI is that was the only way.

Mark

Austin,

Thanks for the info and I am currently using the System.IO.Ports
class for the serial communications, but what I want is a way to
determine the available ports that are present on the current system.

The Serial Port namespace is pretty nice, though I don't like how the
data is buffered, and props goes to the intern at Microsoft that
initially created the class.

I will give the WMI a go as Michael indicated in his post. So from my
current understanding this is no native .NET way of determining the
enumerated list of available ports on a system. Hopefully Microsoft
might add that feature in the future.

Mark
Nov 16 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by willie | last post: by
21 posts views Thread by The Man With The Harmonica | last post: by
1 post views Thread by henrycortezwu | last post: by
5 posts views Thread by Franklin M. Gauer III | last post: by
38 posts views Thread by shussai2 | last post: by
2 posts views Thread by joaquimfpinto | last post: by
3 posts views Thread by naveen.sabapathy | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by MichaelMortimer | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.