Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 76915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:44:53+00:00 2026-05-10T20:44:53+00:00

I have a GSM modem connected via USB. The modem creates 2 serial ports.

  • 0

I have a GSM modem connected via USB. The modem creates 2 serial ports. The first is automatically attached to the modem, the second shows in Device Manager as ‘HUAWEI Mobile Connect – 3G PC UI Interface (COM6)’

The second port is used to get vital information from the modem, such as signal quality; to send and receive text messages; and a whole host of other functions.

I am writing an application that will wrap up some of the features provided by the second port. What I need is a sure fire method of identifying which COM port is the spare one. Iterating the ports and checking a response to ‘ATE0’ is not sufficient. The modem’s port is usually the lower numbered one, and when a dial up connection is not active, it will respond to ‘ATE0’ the same as the second port.

What I was thinking of doing is iterating the ports and checking their friendly name, as it shows in Device Manager. That way I can link the port in my application to the port labelled ‘HUAWEI Mobile Connect – 3G PC UI Interface (COM6)’ in Device Manager. I’ve just not found any information yet that will allow me to get that name programmatically.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T20:44:54+00:00Added an answer on May 10, 2026 at 8:44 pm

    The information posted by Will Dean was most helpful. This is the code that eventually worked for me. Everything in the PInvoke class was taken verbatim from http://www.pinvoke.net . I did have to change a data type here or there to make it work (like when using an enum instead of a uint) but it should be easy to figure out.

    internal static string GetComPortByDescription(string Description) {     string Result = string.Empty;     Guid guid = PInvoke.GUID_DEVCLASS_PORTS;     uint nDevice = 0;     uint nBytes = 300;     byte[] retval = new byte[nBytes];     uint RequiredSize = 0;     uint PropertyRegDataType = 0;      PInvoke.SP_DEVINFO_DATA devInfoData = new PInvoke.SP_DEVINFO_DATA();     devInfoData.cbSize = Marshal.SizeOf(typeof(PInvoke.SP_DEVINFO_DATA));      IntPtr hDeviceInfo = PInvoke.SetupDiGetClassDevs(         ref guid,          null,          IntPtr.Zero,          PInvoke.DIGCF.DIGCF_PRESENT);      while (PInvoke.SetupDiEnumDeviceInfo(hDeviceInfo, nDevice++, ref devInfoData))     {         if (PInvoke.SetupDiGetDeviceRegistryProperty(                 hDeviceInfo,                  ref devInfoData,                  PInvoke.SPDRP.SPDRP_FRIENDLYNAME,                 out PropertyRegDataType,                  retval,                  nBytes,                  out RequiredSize))         {             if (System.Text.Encoding.Unicode.GetString(retval).Substring(0, Description.Length).ToLower() ==                 Description.ToLower())             {                 string tmpstring = System.Text.Encoding.Unicode.GetString(retval);                 Result = tmpstring.Substring(tmpstring.IndexOf('COM'),tmpstring.IndexOf(')') - tmpstring.IndexOf('COM'));             } // if retval == description         } // if (PInvoke.SetupDiGetDeviceRegistryProperty( ... SPDRP_FRIENDLYNAME ...     } // while (PInvoke.SetupDiEnumDeviceInfo(hDeviceInfo, nDevice++, ref devInfoData))      PInvoke.SetupDiDestroyDeviceInfoList(hDeviceInfo);     return Result; } 

    I think the line Result = tmpstring.Substring(tmpstring.IndexOf('COM'),tmpstring.IndexOf(')') - tmpstring.IndexOf('COM')); is a little clumsy, suggestions on how to clean it up would be appreciated.

    Thanks for your help with this matter Will, without you, I’d still be searching google.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a GSM modem with 6 ports and each port inserted a
I have a USB GSM device which I use for Internet connection as well
Background I have a GSM modem connected through a COM port. I open the
I have one GSM Modem Series 900. I want to test it for sending
I have got a Wavecom Supreme GSM modem. I wrote a simple application that
Is it possible to use an Android mobile device as a GSM modem? I
I'm working on the Telit GL-865 GSM/GPRS Modem kit for research purposes. I have
I want to send messages from php by using a GSM modem. I have
I have successfully interfacted Telit GL 865 GSM/GPRS modem to my Atmel microprocessor. My
What all would be the requirements for the following scenario: A GSM modem connected

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.