473,396 Members | 1,599 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 9467
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: willie | last post by:
Hi, I'm writing a program which requires the use of three serial ports and one parallel port. My application has a scanning devices on each port, which I can access fine with pyserial. ...
21
by: The Man With The Harmonica | last post by:
Hi All, What kind of commands can I use to control the serial and parallel port of my pc. I want to use my laptop instead of microcontrollers and write my software in ANSI C to be used for...
4
by: joe bloggs | last post by:
I am writing a mobile application to interface with a legacy system and I am planning to use web services to communicate with this system. The legacy system receives data through a serial port. ...
1
by: henrycortezwu | last post by:
Hi All, I'm trying to connect to a virtual port (COM19, OUTGOING, "Bluetooth Serial Port") using VS2005 System.IO.Ports. When I ran the ff code below here's what happens. 1) VS2005 Compiles w/o...
5
by: Franklin M. Gauer III | last post by:
Hi All, I've written an ASP.NET application (webservice) that does simple serial communications via the .NET 2.0 SerialComm object. The application runs fine on my development machine. The...
38
by: shussai2 | last post by:
Hi, I am trying to access Serial Port in XP. I am using Dev-C++ IDE that uses Mingw as a compiler. I just want to know how I can open up serial port on COM1 and write some data. I have searched...
2
by: joaquimfpinto | last post by:
Dear All, I made an app in c# that uses several serial ports. For the serial ports I use a pnp Sunix board, some with 8 serial ports other with 4 or even 2 serial ports. Whenever I use the...
2
by: Lou | last post by:
I have a class that creates an instance of the seril Port. Every thing works fine except whenever I receive data I cannot display the recieved data. I get no errors but the recived data seems to...
3
by: naveen.sabapathy | last post by:
Hi, I am trying to use virtual serial ports to develop/test my serial communication program. Running in to trouble... I am using com0com to create the virtual ports. The virtual ports seem to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.