04-01-2015 12:41 PM
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?
04-01-2015 12:53 PM
04-01-2015 12:58 PM
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?
04-01-2015 01:06 PM
@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.
04-01-2015 04:14 PM
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.
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.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord