Click here to Skip to main content
15,902,786 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I develop my project for receive serial port data.
From my project i open comport 2 and when i want to get port name i am getting comport1 what is problem i don't know.
I muse this code:
var poname = comPort.PortName;
i use this code in another form with create object of form at when i open comport2.
comPort is my serial port.
And i want the port name of which is open in my project not in my computer.
Posted
Updated 8-Dec-11 0:48am
v2

The problem must be in the wrapper class you are using, C# only has a notion of System.IO.Ports.SerialPort. Here you can use GetPortNames (static method) to get the ports currently available on your system.
See for more info: SerialPort Class[^]

Cheers, AT
 
Share this answer
 
Comments
jaideepsinh 8-Dec-11 7:05am    
i don't want current available on system i only want which is open in my project which is i develop;
lukeer 8-Dec-11 7:24am    
If it's in your project, then you can store what ever you want in variables and use it afterwards.

I'd suggest using only one SerialPort instance. Set the PortName once and then use references to the same SerialPort instance every time you need to send or receive something.
Addy Tas 9-Dec-11 17:23pm    
I can only agree with your comment; data sources always need to have a McCloud attitude :). There shall be only one!

Having two ways of retrieving the same information can (and will) lead to ambiguity... ehhh errors in case you might misunderstand...
I solve it in my project at which form i set port detail i closed that page so i am not get real port name so now solution is to only hide that page and define public static serial port so i get same value at all form.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900