B
B
belunix2013-07-31 23:37:41
Programming
belunix, 2013-07-31 23:37:41

Software detection of the COM port used by the 3g modem in Windows

Initial data:

WIN XP SP3 OS, Huawei 3G modem or Alcatel 3G modem, installed drivers for them and ready-made connections in the Network Connections folder

It is also known that when a modem is directly connected to a USB port, several virtual COM ports are created ( for different models, the number may be different, as a rule - from 2 to 4 ports).
Port numbers, of course, are arbitrary and can change with each connection.
One of these ports is recognized in the Device Manager under the "Modems" tab as a 3G modem, and the remaining ports are located in the "Ports (COM and LPT)" tab, and they are assigned any numbers.

In this case, the modem most often uses one of the COM ports for reading commands, and the other for writing responses.
Sometimes it happens that one COM port is used to read commands, and the response is written to several other COM ports at once.

Question: how to programmatically (using WINAPI, C / C ++ language) determine for a given connection which (which) ports for this modem to write to, and from which (from which) ports to read responses?

My idea was to programmatically get the name of the COM port from the Connections label (see Source Data), and then send a standard AT command, while looping through and listening to all free COM ports. Having received a response on any of them (or on several at once), consider that a pair of ports for writing-reading has been found.

The problem I faced is that I could not find a suitable WINAPI function, which, roughly speaking, by the input parameter "Connection_name" would return the "COM_port_name" corresponding to this connection.
At the same time, in the Connection shortcut itself, this COM port is quite clearly visible.
(For example, in the case of Megaphone, COM9 is indicated in its Connection, and COM10 is visible on the “Ports (COM and LPT)” tab, respectively, we write in COM9, read from COM10. And Alcatel generally opens 4 COM ports).
To solve this problem, I used a subset of RAS functions and structures from WINAPI, but, as I said above, I did not find a suitable function to return the name of the COM port.

Perhaps the problem should be solved in a different way. How to be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dummy2002, 2013-08-01
@belunix

I don’t know about GSM, but CDMA modems can create the following devices when turned on:
1) Modem COM port (the main port for receiving and transmitting, changing modem operating modes)
2) Diagnostic COM port (used to configure the device - change parameters of the Operator, receiving CDMA network diagnostic data, etc.)
3) GPS device COM port (NMEA and other protocols)
For example, the Huawey E176 device creates 2 COM ports “Huawey Mobile Connect - 3G Application Interface (COM4)” (modem) and "Huawey Mobile Connect - 3G PC UI Interface (COM5)" (diagnostics). At the same time, the “Huawey Mobile Connect - 3G Network Card” network card and the “Local Area Connection 3” network connection are also created, and the “Connect/Disconnect” process is controlled by the Mobile Partner software front-end.
Or do you have a device without front-end software, where the user manually creates and uses a standard Windows connection? What do you really have in the source data from the above?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question