03-06-2014 04:42 AM
I am trying to determine what COM port my USB device is using Automatically. The device includes a built in USB to Serial converter, so it comes up in VISA as COM7.
I could make it an ini file entry like the old serial, but USB is supposed to "make it easy"
I know that the Vendor ID is 0x2047 and the PID is 0x0002. I found an example of how to search the registry to see if the device is connected, and that works just fine. But the expression "USB\VID_2047&PID_0002\00" does not convert to COM7 that VISA is expecting.
Then I found this post: http://forums.ni.com/t5/LabVIEW/determining-which-COM-port-is-the-quot-right-one-quot/m-p/755802/hig...
The problem is that 3 of the 4 devices on the computer do not have anything for the "Interface Description", and of course the device I want is blank.
So then I changed the property to Manf ID, and it throws an error that the information is not availible for all the devices.
I have also tried using the VISA Find Resources with the expression "?*{VI_ATTR_MANF_ID == 0x}?*" trying to search for any devices with Man ID 0x2047, but that throws an invalid expression error.
03-06-2014 07:08 AM
Look in to Devcon
classes List all device setup classes.
find Find devices that match the specific hardware or instance ID.
03-06-2014 07:09 AM
Sorry, yes I have seen DevCon before, but I cannot redistribute it, and the program will be going out to a number of suppliers.
03-06-2014 04:26 PM
Kenny,
Your own comments may provide a clue to a possible solution: ...it throws an error...
Consider that any time you try to communicate with a serial port with an unknown device connected or no connection to the port, you have several possible results. You get an error if Manf ID is not available. You get some information from Interface Description, but it is not unique for your desired device. If no device is connected you may get a timeout error or an immediate return with null values, depending on what you attempt to do. If you attempt to communicate with a port which is being used by a different application, you get another error.
Examine the errors you get. If the error is one of the above, that tells you that the port you tried is not the one you want. Cancel the error and try the next port. You may need to do a combination of checking several properties to uniquely identify the device you want. Once you have located the desired device, just pass that VISA session ID around via a shift register, regardless of what it is. Do you really care what it is called or what it looks like, as long as you can communicate?
Lynn
03-06-2014 05:07 PM