473,721 Members | 2,254 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 9495
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.poolw rote:
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_SerialPo rt" 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.poolw rote:
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.GetP ortNames ();

JR

<Lo*****@hotmai l.comwrote in message
news:11******** **************@ e3g2000cwe.goog legroups.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.poolw rote:
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.GetP ortNames ();

JR

<Lo*****@hotmai l.comwrote in message
news:11******** **************@ e3g2000cwe.goog legroups.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.poolw rote:
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
13191
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. However, I'm unsure of how exactly I should be designing the program, I thought I could use threading to start class: class scanner(Thread): def __init__(self,port):
21
2983
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 control purposes of sensors and other electronic devices. I haven't done any C for a while now so I would assume my knowledge is that of a beginner now.
4
11199
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. What I would like to do is make the serial port accessible via a web service. The web service and the legacy application would be running on the same machine. The mobile application would access the web service via a network connection. It...
1
10917
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 errors 2) My Nokia 6600 prompted me the message "Accept Connection request from DEMON?" note: DEMON is my computers name. 3) Using my Nokia 6600, I hit the button that refers to the "Yes"
5
2334
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 problem is when we try to deploy it to another machine we receive: ACCESS IS DENIED TO COM1 PORT. We have tried unsuccessfully to get this to work. We have tried the following: 1) Assign the IUSR.... account to Administrators
38
9657
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 quite a bit over the web and could not find anything useful. I don't want to use Visual C++ or Cygwin, linux, etc. If any of you guys have some little tid bit of code that would be great to look at.
2
3957
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 development computer I don't have ay problem with my application.
2
6184
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 just go no where. I can see the recived data in my serial receive function but when I either raise an event with it or try to display it in a text box nothing happens. I do use beginInvoke on the text box. If I trace the code through it all...
3
11622
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 be working fine when I test it with Hyperterminal . I am using the example program that comes with pyserial, as below. --------------- import serial
0
8730
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9367
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9215
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9064
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8007
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5981
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4484
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2130
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.