LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Determine Devices Connected to Com Ports (USB to Serial, Win API)

I have a three Roboteq DC Motor Controllers that are identical models, but each control very different things.
These three Roboteq controllers are connected to a FTDI 4-in-1 USB to serial adapter, which in turn is connected to my PC via USB (obviously.)

When I plug in this USB to Serial adapter these four COM Ports, the first three of which are connected to my Motor Controllers, are usually assigned to the same ports, but as you might expect they are not always the same. This is certianly true if I connect it to another computer.

I'm trying to find out if there's a way to code my program such that my VI can determine which controller is connected to which COM port automatically. This is very similar to the problem discussed in this post: http://forums.ni.com/t5/LabVIEW/How-do-I-pragmmatically-determine-what-comm-ports-my-serial/m-p/1992...

The key difference though is that if I communicate to the Robotoeq Cotnrollers, there appears to be no way to distinguish one from the other. I can't determine which controller is which by sending it some command or query.

One idea I've been mulling is based off the fact that the controllers are always going to be plugged into the same USB-Serial converter. My idea was to maybe use the Windows API to search for each of the USB to Serial converter's serial number, but I'm a pretty novice developer so I'm a little fuzzy on how to approach the problem.

If I look in device manager the "Device Instance Path" string  under Com Port properties seems to contain the serial number among other things. Below are the four "Device Instance Path" strings for each of the USB to Serial converters:

FTDIBUS\VID_0403+PID_6011+FTXYYBS7A\0000
FTDIBUS\VID_0403+PID_6011+FTXYYBS7B\0000
FTDIBUS\VID_0403+PID_6011+FTXYYBS7C\0000
FTDIBUS\VID_0403+PID_6011+FTXYYBS7D\0000

I'm guessing the "FTXYYBS7_" is a serial number or something equally identifable because it is the same no matter what computer is hooked up to it.
Is there some Windows API DLL contaning a function I can use to find the "Device Instance Path" strings?

Is there any good resource for finding said functions? (I had some difficulty trying to wade through the MSDN pages.)
Is there some other Com port property I should use instead?
Is there an easier approach to solve my problem?

0 Kudos
Message 1 of 5
(4,261 Views)

Microsoft's DevCon command-line utility

http://support.microsoft.com/en-us/kb/311272

Omar
0 Kudos
Message 2 of 5
(4,247 Views)

Is there a way for me to determine which API functions the DevCon utility uses and instead call them from within my VI, meaning I wouldn't need to include DevCon.exe everytime I run the VI?

0 Kudos
Message 3 of 5
(4,243 Views)

 


@Oredigger wrote:

Is there a way for me to determine which API functions the DevCon utility uses and instead call them from within my VI, meaning I wouldn't need to include DevCon.exe everytime I run the VI?


Posting on a MS Windows forums someone could give you the hooks into the under workings of Windows.

Omar
0 Kudos
Message 4 of 5
(4,238 Views)

Not sure how you feel about hacky solutions, but I have one for you.  In the past someone asked for a uncompress function that was more versitile.  I like 7-zip so I suggested that and wrote a VI that has the 7-zip command line program embedded in the VI file.  Then when the VI runs it extracts the EXE to a temp location and runs it.  Here is that example.

 

https://lavag.org/topic/16513-can-we-prevent-zlib-compress-dir-from-replacing-accented-characters/#e...

 

So you could include DevCon in a VI so that it is transparent to the user of the VI that it is even using that utility.  Now there is a legal aspect because you are now distributing a binary in a way that the original author might not authorize.  To try to save myself I included the 7-zip copyright on the block diagram of the VI.

0 Kudos
Message 5 of 5
(4,209 Views)