473,471 Members | 1,868 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to get specifik name of comport?

6 New Member
Hello.

My question is as follows:

I am making a little gui that uses COMPORTS to connect to a board. I want the program to be able to find the correct COMPORT by itself. This goes fine with try/catch as long as I dont have other devices that uses COMPORTS. My code so far is as follows:

Expand|Select|Wrap|Line Numbers
  1.   public void InitSerialPort()
  2.         {
  3.  
  4.             int i = 0;
  5.             bool comportSelect = false;
  6.  
  7.             while (comportSelect == false)
  8.             {
  9.                 try
  10.                 {
  11.                     if (i == 21)
  12.                     {
  13.                         Error(0);
  14.                         comportSelect = true;
  15.                     }
  16.                     else
  17.                     {
  18.                         mySerialPort = new SerialPort(("COM" + i.ToString()), 19200, Parity.None, 8, StopBits.Two);
  19.                         mySerialPort.DataReceived += new SerialDataReceivedEventHandler(Received);
  20.                         mySerialPort.Open();
  21.                         mySerialPort.
  22.                         MessageBox.Show(mySerialPort.PortName);
  23.                         comportSelect = true;
  24.                     }
  25.                 }
  26.                 catch
  27.                 {
  28.                     i++;
  29.                 }
  30.             }
  31.         }

This doesn't work when I have an other device using a lower COMPORT as the one for my gui. If I open device manager I can see different desciptions of the comports. The one I want to use is described as:

"USB Serial Port (COM3)"

Do you guys know a way to return this description so I can do a "chec" to see wheater I have selected the right COMPORT?

Thanks allready!

/Aske
Aug 2 '10 #1
3 1481
newb16
687 Contributor
There is a way to get some information about them using WMI (like in http://www.python-forum.org/pythonfo...t=7175&p=88622 )
Aug 2 '10 #2
Askelassen
6 New Member
I'm writing in c# in visual studio :) so can I use this?
Aug 3 '10 #3
newb16
687 Contributor
How can I know? If there is a way to access WMI from c# (I'm sure there is) then yes, I permit you to use this for whatever purposes.
Aug 3 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

23
by: stewart.midwinter | last post by:
No doubt I've overlooked something obvious, but here goes: Let's say I assign a value to a var, e.g.: myPlace = 'right here' myTime = 'right now' Now let's say I want to print out the two...
2
by: Ravi | last post by:
My XML looks like: <abc> <def type="apple"> 1 </def> <def type="peach"> 2 </def> <def type="orange"> 3 </def> <def type="banana"> 4 </def> <def type="plum"> 5 </def> </abc>
1
by: discomiller | last post by:
Mario Mueller: Hello *, radiobuttons belong to other radiobuttons by the "name="any_value"" attribut. Thats a fakt. I got the following XML:...
21
by: TheKeith | last post by:
I heard that the name attribute is deprecated in html 4.01 strict. Is it recommended that you use the ID attribute for images along with the getElementById method instead of the old way? Thanks.
12
by: CJ | last post by:
Why won't this work? I am passing the name of the form (I have two that use this validation script) but I keep getting an error. Error reads: "document.which_form.name is null or not an object" ...
11
by: Andrew Thompson | last post by:
I have written a few scripts to parse the URL arguments and either list them or allow access to the value of any parameter by name. <http://www.physci.org/test/003url/index.html>...
0
by: Jim dunn | last post by:
HI I am having problems with C# with regards to its compatibility with win32 API methods, I am trying to read from a windows CE comm port using C# and imported methods from coredll.dll, it seems...
3
by: mikeparlin7 | last post by:
hi this is mike can some one tell me how to simulate key board w/ c++ over serial comport? thanks
0
by: koh soo min | last post by:
Hi, Can anyone give me hints to write VB code for send and receive message between two computer using ComPort. Thanks.
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
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
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
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...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.