04-23-2010 11:38 AM
04-23-2010 11:49 AM - edited 04-23-2010 11:52 AM
04-23-2010 12:19 PM - edited 04-23-2010 12:20 PM
The 2nd attempt is better, but still too much code. All you need...
04-23-2010 01:08 PM - edited 04-23-2010 01:08 PM
04-23-2010 02:18 PM - edited 04-23-2010 02:19 PM
OK, but your loops don't make much sense to me - perhaps they are an artifact from something else you are doing and not showing. All you need is...
04-24-2010 08:16 AM
04-24-2010 09:05 PM
04-24-2010 10:22 PM
The port itself doesn't know if anything is connected.
You'd have to send out a test message to each com port and see if you get a response back. Some instruments respond to the IDN? command.
04-24-2010 10:49 PM
04-24-2010 11:38 PM
No. For one thing, why do you have a wire going into the bytes to read for the VISA read that comes from the return count of the VISA write?
I don't know what is the proper IDN code or if there is more than one variation that might work. If it is possible to have more than one, than you can try all combinations in a loop. Even then, you might have an instrument connected that doesn't respond to that code.
What is it you are really trying to do in the end? Why do you need to search for all your com ports and then determine if something is connected? It should be up to the user of your application to know which device they have connected to which com port.