1

I'm using gsmcomm library and Huawei GSM modem. The has two ports. if I list the ports and loop to auto connect into it, I'm having a problem connecting to the specific port which is functional to sending message which is the COM6 and COM5 is not the right port. (Image link attach below for more info)

So is there any way to get the whole name of that port? any way to connect to that specific port and avoid the other port?

Please check this image of they show up in the device manager as reference of my question.

enter image description here

Alex K.
  • 171,639
  • 30
  • 264
  • 288
Itsumo Kokoro
  • 169
  • 4
  • 14
  • WMI can enumerate the display captions that exist for USB emulated ports a la Device Manager, see http://stackoverflow.com/questions/2837985/getting-serial-port-information – Alex K. Feb 12 '15 at 14:12
  • why this object wont appear --> ManagementObjectSearcher? i added using System.Management but still dont appear – Itsumo Kokoro Feb 12 '15 at 14:21
  • You need to add a reference to System.Management and `using System.Management;` – Alex K. Feb 12 '15 at 14:23
  • thank you. i added it to reference and it works. – Itsumo Kokoro Feb 12 '15 at 14:25
  • I can't yet fully understand the code. can you help me with the error? if (queryObj["Caption"].ToString().StartsWith("serial port")) error: An unhandled exception of type 'System.NullReferenceException' occurred in gsmtest.exe Additional information: Object reference not set to an instance of an object. – Itsumo Kokoro Feb 12 '15 at 14:35
  • 1
    Make sure `queryObj["Caption"]` is not null before calling ToString() on it. – Alex K. Feb 12 '15 at 14:38
  • why caption is null? i thought it will get the port description but it null. i check device manager and the port COM6 and COM5 is there but why it is null? – Itsumo Kokoro Feb 12 '15 at 14:43
  • Seeking for help. it does not return the port that i need. – Itsumo Kokoro Feb 13 '15 at 11:46
  • Instead of "Caption" try "Description" (still checking for null) A list of possible property names for queryObj[] is here; https://msdn.microsoft.com/en-us/library/aa394413%28v=vs.85%29.aspx – Alex K. Feb 13 '15 at 11:48
  • thank you. it works for the description. but how can i include the port name? description and port name... i can't see option for port name – Itsumo Kokoro Feb 13 '15 at 11:58
  • 1
    Your the best.! your a savior. My smile reflects at the monitor screen.. thank you sir Alex – Itsumo Kokoro Feb 13 '15 at 12:03
  • Hi. when it detects 3G application interface, it will not display the 3g pc ui interface(base on the image). only one port it will detect. – Itsumo Kokoro Feb 13 '15 at 13:30

0 Answers0