09-05-2008 08:08 AM
hello, guys
i am working on a program which communicate with a signal generator via USB/GPIB adapter, i want to add a timeout handler.
Accidently if someone disconnect the cable when program require signal from Visa read block, the system will not be dead, it can jump out automaticlly and reiteration the loop when timeout handler take place, it there any solution, i tried timed loop, and visa timeout, they did not work.
thanks a lot
09-05-2008 08:29 AM
"i tried timed loop, and visa timeout, they did not work."
Doesn't your VISA returns an error when a timeout occurs ?
09-05-2008 09:07 AM
Assuming that the question is a continuation of this thread, I don't think that adding a timeout will be of any use as you are already getting an error return from your VISA commands, presumably because when you disconnect the USB cable, the device driver is no longer available and the referece has become invalid.
You can DETECT this condition (as you already seem to do) from the error wire. How you react to the error depends on how the hardware and drivers behave after reconnection. (You have the hardware so you should be able to tell) Most probably you will need to put up a message to tell the user to check the connections. You MAY then be able to close the session in error and restart the VISA session with a fresh VISA open.
A timeout will generally happen when all the hardware is operating correctly but doesn't send the number of characters you have requested within the timeout period (Look on the VISA advanced palette for setting the timeout). If a serial (RS-232) connection is disconnected you might see a timeout, but a USB being disconnected causes the OS to detect the change and to (possibly) unload drivers.
Rod.
09-05-2008 09:26 AM