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

Home Posts Topics Members FAQ

How to find which COM port a particular device is installed on

Hi there,

I've got a problem that should be easy to solve, but I'm having a
nightmare in doing so.

We have an app deployed to a large number of laptops and I've
discovered a problem. We've made an assumption that the GPRS card will
always been on COM4. This isn't always the case and I need to code
something that dynamically sets the correct value in the app before
trying to dial.

The client app is in C#. I've been looking at Win32 APIs, such as
SetupDiEnumDeviceInfo and GetDefaultCommConfig, but I can't see how
these are going to help.

I've managed to get a list of all COM ports using a ManagementObject. I
know I can disregard COM1, but I could be left with more than 1 other
port, so need a way of establishing if it's the correct device. Does
anyone have any ideas how I could programatically identify a particular
piece of hardware on these COM ports?

The old VB code the app was translated from just took a list of COM
ports, disregarded COM1 and tried to open a stream on each remaining
one, 'assuming' that the first to respond was the GPRS card. This is
not reliable and I'm not happy replicating that in my code.

It's late, i'm stuck for ideas and really want to get this out the door
tomorrow. Can anyone suggest anything please that ideally doesn't
involve tons of calls to Win32 APIs, although if they're going to bring
something to the table then I'll happily go down that route.

Many thanks,
Michael.

Jan 16 '07 #1
2 8495
JR
SerialPort.GetPortNames (); gives the valid com ports.

Then try each one for valid pins (CtsHolding, DsrHolding, CDHolding and
RtsEnable) according to your device, and if acceptable see if it gives you
the data you expect.

JR

"Michael_Burgess" <mi**@marsh-hall-studios.co.ukwrote in message
news:11*********************@11g2000cwr.googlegrou ps.com...
Hi there,

I've got a problem that should be easy to solve, but I'm having a
nightmare in doing so.

We have an app deployed to a large number of laptops and I've
discovered a problem. We've made an assumption that the GPRS card will
always been on COM4. This isn't always the case and I need to code
something that dynamically sets the correct value in the app before
trying to dial.

The client app is in C#. I've been looking at Win32 APIs, such as
SetupDiEnumDeviceInfo and GetDefaultCommConfig, but I can't see how
these are going to help.

I've managed to get a list of all COM ports using a ManagementObject. I
know I can disregard COM1, but I could be left with more than 1 other
port, so need a way of establishing if it's the correct device. Does
anyone have any ideas how I could programatically identify a particular
piece of hardware on these COM ports?

The old VB code the app was translated from just took a list of COM
ports, disregarded COM1 and tried to open a stream on each remaining
one, 'assuming' that the first to respond was the GPRS card. This is
not reliable and I'm not happy replicating that in my code.

It's late, i'm stuck for ideas and really want to get this out the door
tomorrow. Can anyone suggest anything please that ideally doesn't
involve tons of calls to Win32 APIs, although if they're going to bring
something to the table then I'll happily go down that route.

Many thanks,
Michael.

Jan 17 '07 #2
Thanks for the response. In the end I managed to use the
"Win32_POTSModem" class in the WMI and from that am able to determine
all the attached modems. I can disregard the internal modem as the
'DeviceType' property states 'Internal Modem' and then pass an AT
signal strength query to the device in question and work it out from
the response.

Jan 17 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: mimisam | last post by:
hi, I am using Win XP and writing an application to check POS devices (printer and cash drawer).In the application I need to choose the port which the device is connected to. If the port chosen...
8
by: collinm | last post by:
hi we use linux and c language under bash i do echo -e \\000\\000\\000\\000\000\\001Z00\\002AA LINUX \\004 >/dev/ttyS2 that send command to a led display (alpha sign communication)
5
by: Darrell Wesley | last post by:
Is there a good source of information on how to read a USB port, in particular reading data from a BarCode reader?
3
by: Scott M. | last post by:
VS.NET 2003 / 1.1 Framework I have a piece of hardware that sends signals over an Ethernet cable through a USB adapter and into the PC. The USB adapter acts as a COM port for the PC. The...
2
by: Jason | last post by:
Hello I'm about ready to attempt writting a simple TCP server in C# in which all I need to do is send out some data to a particular IP and port, and the end device will send it back to me. ...
2
by: mmrasheed | last post by:
Hi, I am newbie in python. I am working on Telit GM862 GPS/GPRS module which has python interpreter built in. But it seems this problem is pretty much related to general python structure. I...
4
by: JDS | last post by:
I have an application that interfaces with a USB device using the .Net serial port. The code works fine, displaying live data on the screen; that is until the USB lead is pulled out from the PC...
3
by: sakthikumarb | last post by:
Hi.. In local system, under universal serial bus controllers in Device manager.We can enable and disable the particular USB port. How can we do the enable and disable the particular USB port in...
29
by: Praki | last post by:
Greetings All, i think this is the right group to post this question. i am working on client server model. in this model the client is sending request in thousands in number. for example per...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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: 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.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.